- m_task_t tk = checkTask(L,1);
- const char *mailbox = luaL_checkstring(L,2);
- int res = MSG_task_send(tk,mailbox);
- res++;//FIXME: check it instead of avoiding the warning
+ stackDump("send ",L);
+ m_task_t tk = checkTask(L,-2);
+ const char *mailbox = luaL_checkstring(L,-1);
+ lua_pop(L,1); // remove the string so that the task is on top of it
+ MSG_task_set_data(tk,L); // Copy my stack into the task, so that the receiver can copy the lua task directly
+ MSG_error_t res = MSG_task_send(tk,mailbox);
+ while (MSG_task_has_data(tk)) // Don't mess up with my stack: the receiver didn't copy the data yet
+ MSG_process_sleep(0); // yield
+
+ if (res != MSG_OK) switch(res) {
+ case MSG_TIMEOUT :
+ ERROR0("MSG_task_send failed : Timeout");
+ break;
+ case MSG_TRANSFER_FAILURE :
+ ERROR0("MSG_task_send failed : Transfer Failure");
+ break;
+ case MSG_HOST_FAILURE :
+ ERROR0("MSG_task_send failed : Host Failure ");
+ break;
+ default :
+ ERROR0("MSG_task_send failed : Unexpected error , please report this bug");
+ break;
+ }