--- libaitrpc/src/srv.c 2013/04/02 15:32:03 1.14.2.2 +++ libaitrpc/src/srv.c 2013/07/15 14:22:00 1.16.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.14.2.2 2013/04/02 15:32:03 misho Exp $ +* $Id: srv.c,v 1.16.2.2 2013/07/15 14:22:00 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -67,7 +67,7 @@ static sched_task_func_t cbProto[SOCK_RAW + 1][4] = { }; -inline void +void rpc_freeCli(rpc_cli_t * __restrict c) { rpc_srv_t *s = c->cli_parent; @@ -529,7 +529,7 @@ end: /* ------------------------------------------------------ */ -inline void +void rpc_freeBLOBCli(rpc_cli_t * __restrict c) { rpc_srv_t *s = c->cli_parent; @@ -559,6 +559,16 @@ closeBLOBClient(sched_task_t *task) } static void * +toutBLOB(sched_task_t *task) +{ + rpc_cli_t *c = TASK_ARG(task); + + rpc_srv_unregisterBLOB((rpc_srv_t*) c->cli_parent, (uint32_t) TASK_DATA(task)); + + return NULL; +} + +static void * txBLOB(sched_task_t *task) { rpc_cli_t *c = TASK_ARG(task); @@ -583,6 +593,7 @@ rxBLOB(sched_task_t *task) rpc_blob_t *b; struct tagBLOBHdr blob; int rlen; + struct timespec ts = { RPC_BLOB_TIMEOUT, 0 }; memset(&blob, 0, sizeof blob); rlen = recv(TASK_FD(task), &blob, sizeof blob, 0); @@ -632,9 +643,15 @@ rxBLOB(sched_task_t *task) /* set new BLOB variable for reply :) */ blob.hdr_var = htonl(b->blob_var); + /* set live BLOB timeout */ + ts.tv_sec = blob.hdr_ret ? blob.hdr_ret : RPC_BLOB_TIMEOUT; + /* receive BLOB from client */ blob.hdr_ret = htonl(rpc_srv_recvBLOB(c, b)); rpc_srv_blobUnmap(b); + + schedTimer(TASK_ROOT(task), toutBLOB, TASK_ARG(task), ts, + (void*) (intptr_t) ntohl(blob.hdr_var), ntohl(blob.hdr_len)); } else { blob.hdr_cmd = error; blob.hdr_ret = RPC_ERROR(-1); @@ -645,6 +662,9 @@ rxBLOB(sched_task_t *task) blob.hdr_cmd = error; blob.hdr_ret = RPC_ERROR(-1); } + + schedCancelby(TASK_ROOT(task), taskTIMER, CRITERIA_DATA, + (void*) (intptr_t) ntohl(blob.hdr_var), NULL); break; default: rpc_SetErr(EPROCUNAVAIL, "Unsupported BLOB command %d", blob.hdr_cmd); @@ -826,7 +846,7 @@ rpc_srv_initBLOBServer(rpc_srv_t * __restrict srv, u_s * @srv = RPC Server instance * return: none */ -inline void +void rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) { if (!srv) @@ -1029,7 +1049,7 @@ err: /* error condition */ * @psrv = RPC Server instance * return: none */ -inline void +void rpc_srv_endServer(rpc_srv_t ** __restrict psrv) { if (!psrv || !*psrv)