From 2a1d5de9bec0f061a37c7219b6d522032ad6eb24 Mon Sep 17 00:00:00 2001 From: coldpeace Date: Thu, 25 Mar 2010 13:54:06 +0000 Subject: [PATCH] check result when sending/receiving tasks git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7372 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/bindings/lua/simgrid_lua.c | 45 ++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index f162819757..c340e6b903 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -85,14 +85,13 @@ static m_task_t *pushTask (lua_State *L,m_task_t tk,int flag) { } //*pi=tk; - printf("push lua task with Name : %s \n",MSG_task_get_name(*pi)); + DEBUG1("push lua task with Name : %s \n",MSG_task_get_name(*pi)); luaL_getmetatable(L,TASK_MODULE_NAME); lua_setmetatable(L,-2); return pi; } - /* ********************************************************************************* */ /* wrapper functions */ /* ********************************************************************************* */ @@ -140,17 +139,49 @@ static int Task_destroy(lua_State *L) { static int Task_send(lua_State *L) { 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 + MSG_error_t res = MSG_task_send(tk,mailbox); + 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; + } + } return 0; } static int Task_recv(lua_State *L) { m_task_t tk = NULL; const char *mailbox = luaL_checkstring(L,1); - int res = MSG_task_receive(&tk,mailbox); - if (MSG_task_has_data(tk)) printf("Receive The Task with Name : %s \n",MSG_task_get_name(tk)); + MSG_error_t res = MSG_task_receive(&tk,mailbox); + if (MSG_task_has_data(tk)) DEBUG1("Receive The Task with Name : %s \n",MSG_task_get_name(tk)); MSG_task_ref(tk); //FIXME: kill it once a ctask cannot be in more than one luatask anymore - res++;//FIXME: check it instead of avoiding the warning + if(res != MSG_OK) + { + switch(res){ + case MSG_TIMEOUT : + ERROR0("MSG_task_receive failed : Timeout"); + break; + case MSG_TRANSFER_FAILURE : + ERROR0("MSG_task_receive failed : Transfer Failure"); + break; + case MSG_HOST_FAILURE : + ERROR0("MSG_task_receive failed : Host Failure "); + break; + default : + ERROR0("MSG_task_receive failed : Unexpected error , please report this bug"); + break; + } + } DEBUG1("Task Name : >>>%s",MSG_task_get_name(tk)); //lua_pushlightuserdata(L,MSG_task_get_data(tk)); pushTask(L,tk,1); -- 2.20.1