Loading include/norns/norns_error.h +5 −4 Original line number Diff line number Diff line Loading @@ -73,10 +73,11 @@ extern "C" { #define NORNS_ETASKSPENDING -43 /* task status */ #define NORNS_EPENDING -100 #define NORNS_EINPROGRESS -101 #define NORNS_EFINISHED -102 #define NORNS_EFINISHEDWERROR -103 #define NORNS_EUNDEFINED -100 #define NORNS_EPENDING -101 #define NORNS_EINPROGRESS -102 #define NORNS_EFINISHED -103 #define NORNS_EFINISHEDWERROR -104 /* errors resources */ #define NORNS_ERESOURCEEXISTS -110 Loading include/norns/norns_types.h +9 −8 Original line number Diff line number Diff line Loading @@ -123,14 +123,6 @@ typedef enum { NORNS_IOTASK_REMOVE = 0x3 } norns_op_t; /* Descriptor for an I/O task */ typedef struct { norns_tid_t t_id; /* task identifier */ norns_op_t t_op; /* operation to be performed */ norns_resource_t t_src; /* source resource */ norns_resource_t t_dst; /* destination resource */ } norns_iotask_t; /* I/O task status descriptor */ typedef struct { norns_status_t st_status; /* task current status */ Loading @@ -140,7 +132,16 @@ typedef struct { size_t st_total; /* total bytes in task */ } norns_stat_t; /* Descriptor for an I/O task */ typedef struct { norns_tid_t t_id; /* task identifier */ norns_op_t t_op; /* operation to be performed */ norns_resource_t t_src; /* source resource */ norns_resource_t t_dst; /* destination resource */ /* Internal members */ norns_stat_t __t_status; /* cached task status */ } norns_iotask_t; /* Additional administrative types */ typedef enum { Loading lib/libnorns.c +12 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,14 @@ norns_error(norns_iotask_t* task, norns_stat_t* stats) { return NORNS_EBADARGS; } // we might already have the task status cached in the task descriptor if // the user called norns_wait() and the task completed if(task->__t_status.st_status == NORNS_EFINISHED || task->__t_status.st_status == NORNS_EFINISHEDWERROR) { *stats = task->__t_status; return NORNS_SUCCESS; } return send_status_request(task, stats); } Loading Loading @@ -251,6 +259,10 @@ norns_wait(norns_iotask_t* task, if(stats.st_status == NORNS_EFINISHED || stats.st_status == NORNS_EFINISHEDWERROR) { // given that the task finished, we can save its completion status // so that future calls to norns_error() can retrieve it without // having to contact the server task->__t_status = stats; return NORNS_SUCCESS; } Loading lib/libnornsctl.c +12 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,14 @@ nornsctl_error(norns_iotask_t* task, return NORNS_EBADARGS; } // we might already have the task status cached in the task descriptor if // the user called norns_wait() and the task completed if(task->__t_status.st_status == NORNS_EFINISHED || task->__t_status.st_status == NORNS_EFINISHEDWERROR) { *stats = task->__t_status; return NORNS_SUCCESS; } return send_status_request(task, stats); } Loading Loading @@ -437,6 +445,10 @@ nornsctl_wait(norns_iotask_t* task, if(stats.st_status == NORNS_EFINISHED || stats.st_status == NORNS_EFINISHEDWERROR) { // given that the task finished, we can save its completion status // so that future calls to nornsctl_error() can retrieve it without // having to contact the server task->__t_status = stats; return NORNS_SUCCESS; } Loading src/api/response.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ norns::rpc::Response_Type encode(norns::api::response_type type) { using norns::io::task_status; switch(status) { case task_status::undefined: return NORNS_EUNDEFINED; case task_status::pending: return NORNS_EPENDING; case task_status::running: Loading Loading
include/norns/norns_error.h +5 −4 Original line number Diff line number Diff line Loading @@ -73,10 +73,11 @@ extern "C" { #define NORNS_ETASKSPENDING -43 /* task status */ #define NORNS_EPENDING -100 #define NORNS_EINPROGRESS -101 #define NORNS_EFINISHED -102 #define NORNS_EFINISHEDWERROR -103 #define NORNS_EUNDEFINED -100 #define NORNS_EPENDING -101 #define NORNS_EINPROGRESS -102 #define NORNS_EFINISHED -103 #define NORNS_EFINISHEDWERROR -104 /* errors resources */ #define NORNS_ERESOURCEEXISTS -110 Loading
include/norns/norns_types.h +9 −8 Original line number Diff line number Diff line Loading @@ -123,14 +123,6 @@ typedef enum { NORNS_IOTASK_REMOVE = 0x3 } norns_op_t; /* Descriptor for an I/O task */ typedef struct { norns_tid_t t_id; /* task identifier */ norns_op_t t_op; /* operation to be performed */ norns_resource_t t_src; /* source resource */ norns_resource_t t_dst; /* destination resource */ } norns_iotask_t; /* I/O task status descriptor */ typedef struct { norns_status_t st_status; /* task current status */ Loading @@ -140,7 +132,16 @@ typedef struct { size_t st_total; /* total bytes in task */ } norns_stat_t; /* Descriptor for an I/O task */ typedef struct { norns_tid_t t_id; /* task identifier */ norns_op_t t_op; /* operation to be performed */ norns_resource_t t_src; /* source resource */ norns_resource_t t_dst; /* destination resource */ /* Internal members */ norns_stat_t __t_status; /* cached task status */ } norns_iotask_t; /* Additional administrative types */ typedef enum { Loading
lib/libnorns.c +12 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,14 @@ norns_error(norns_iotask_t* task, norns_stat_t* stats) { return NORNS_EBADARGS; } // we might already have the task status cached in the task descriptor if // the user called norns_wait() and the task completed if(task->__t_status.st_status == NORNS_EFINISHED || task->__t_status.st_status == NORNS_EFINISHEDWERROR) { *stats = task->__t_status; return NORNS_SUCCESS; } return send_status_request(task, stats); } Loading Loading @@ -251,6 +259,10 @@ norns_wait(norns_iotask_t* task, if(stats.st_status == NORNS_EFINISHED || stats.st_status == NORNS_EFINISHEDWERROR) { // given that the task finished, we can save its completion status // so that future calls to norns_error() can retrieve it without // having to contact the server task->__t_status = stats; return NORNS_SUCCESS; } Loading
lib/libnornsctl.c +12 −0 Original line number Diff line number Diff line Loading @@ -402,6 +402,14 @@ nornsctl_error(norns_iotask_t* task, return NORNS_EBADARGS; } // we might already have the task status cached in the task descriptor if // the user called norns_wait() and the task completed if(task->__t_status.st_status == NORNS_EFINISHED || task->__t_status.st_status == NORNS_EFINISHEDWERROR) { *stats = task->__t_status; return NORNS_SUCCESS; } return send_status_request(task, stats); } Loading Loading @@ -437,6 +445,10 @@ nornsctl_wait(norns_iotask_t* task, if(stats.st_status == NORNS_EFINISHED || stats.st_status == NORNS_EFINISHEDWERROR) { // given that the task finished, we can save its completion status // so that future calls to nornsctl_error() can retrieve it without // having to contact the server task->__t_status = stats; return NORNS_SUCCESS; } Loading
src/api/response.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ norns::rpc::Response_Type encode(norns::api::response_type type) { using norns::io::task_status; switch(status) { case task_status::undefined: return NORNS_EUNDEFINED; case task_status::pending: return NORNS_EPENDING; case task_status::running: Loading