From: mquinson Date: Sun, 31 Oct 2010 13:12:48 +0000 (+0000) Subject: Don't mess with MSG internals from ruby, but use the public interface. Good idea... X-Git-Tag: v3_5~332 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/97c7d15d4bca89da2422089e17de8afac009160b Don't mess with MSG internals from ruby, but use the public interface. Good idea when the internals are about to change git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8493 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/bindings/ruby/rb_application_handler.c b/src/bindings/ruby/rb_application_handler.c index 3225e8757d..63d3d4c5f3 100644 --- a/src/bindings/ruby/rb_application_handler.c +++ b/src/bindings/ruby/rb_application_handler.c @@ -6,7 +6,6 @@ #include "bindings/ruby_bindings.h" #include "surf/surfxml_parse.h" -#include "msg/private.h" /* s_simdata_process_t FIXME: don't mess with MSG internals that way */ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(ruby); @@ -43,56 +42,19 @@ static void rb_process_create_with_args(VALUE fct_name, VALUE arguments, name = RSTRING(fct_name)->ptr; DEBUG1("Create native process %s", name); + char **argv = xbt_new(char *, 2); + argv[0] = bprintf("%s@%s", name, RSTRING(ht_name)->ptr); + argv[1] = NULL; + // Allocate the data for the simulation - process = xbt_new0(s_m_process_t, 1); - process->simdata = xbt_new0(s_simdata_process_t, 1); + process = MSG_process_create_with_arguments(name, + (xbt_main_func_t) ruby_process, + process, + MSG_get_host_by_name(RSTRING(ht_name)->ptr), + 1, argv); + // Bind The Ruby Process instance to The Native Process rb_process_bind(ruby_process, process); - process->name = xbt_strdup(name); - // Host - m_host_t host = MSG_get_host_by_name(RSTRING(ht_name)->ptr); - process->simdata->m_host = host; - - if (!(process->simdata->m_host)) { // Not Binded - free(process->simdata); - free(process->data); - free(process); - rb_raise(rb_eRuntimeError, - "Host not bound while creating native process"); - } - - process->simdata->PID = msg_global->PID++; - - DEBUG7 - ("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)", - process->name, process->simdata->m_host->name, - process->simdata->PID, process, process->simdata, - process->simdata->m_host, process->simdata->m_host->simdata); - - /* FIXME: that's mainly for debugging. We could only allocate this if XBT_LOG_ISENABLED(ruby,debug) is true since I guess this leaks */ - char **argv = xbt_new(char *, 2); - argv[0] = - bprintf("%s@%s", process->name, - process->simdata->m_host->simdata->smx_host->name); - argv[1] = NULL; - process->simdata->s_process = - SIMIX_process_create(process->name, - (xbt_main_func_t) ruby_process, - (void *) process, - process->simdata->m_host->simdata-> - smx_host->name, 1, argv, NULL); - - DEBUG1("context created (s_process=%p)", process->simdata->s_process); - - if (SIMIX_process_self()) { // SomeOne Created Me !! - process->simdata->PPID = - MSG_process_get_PID(SIMIX_process_self()->data); - } else { - process->simdata->PPID = -1; - } - process->simdata->last_errno = MSG_OK; - // let's Add the Process to the list of the Simulation's Processes - xbt_fifo_unshift(msg_global->process_list, process); }