--- libaitrpc/src/srv.c 2013/07/16 13:04:20 1.17 +++ libaitrpc/src/srv.c 2013/08/20 23:49:54 1.17.4.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.17 2013/07/16 13:04:20 misho Exp $ +* $Id: srv.c,v 1.17.4.2 2013/08/20 23:49:54 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -74,8 +74,8 @@ rpc_freeCli(rpc_cli_t * __restrict c) schedCancelby(s->srv_root, taskMAX, CRITERIA_ARG, c, NULL); - /* free buffer */ - AIT_FREE_VAL(&c->cli_buf); + /* free buffer(s) */ + ait_freeVars(&c->cli_buf); array_Del(s->srv_clients, c->cli_id, 0); if (c) @@ -126,8 +126,14 @@ _allocClient(rpc_srv_t * __restrict srv, sockaddr_t * c->cli_parent = srv; } - /* alloc empty buffer */ - AIT_SET_BUFSIZ(&c->cli_buf, 0, srv->srv_netbuf); + /* init buffer(s) */ + c->cli_buf = ait_allocVars(1); + if (!c->cli_buf) { + rpc_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); + array_Del(srv->srv_clients, n, 42); + return NULL; + } else + AIT_SET_BUFSIZ(array(c->cli_buf, 0, ait_val_t*), 0, srv->srv_netbuf); } return c; @@ -367,7 +373,7 @@ acceptClients(sched_task_t *task) c->cli_sock = accept(TASK_FD(task), &c->cli_sa.sa, &salen); if (c->cli_sock == -1) { LOGERR; - AIT_FREE_VAL(&c->cli_buf); + ait_freeVars(&c->cli_buf); array_Del(srv->srv_clients, c->cli_id, 42); goto end; } else @@ -536,8 +542,8 @@ rpc_freeBLOBCli(rpc_cli_t * __restrict c) schedCancelby(s->srv_blob.root, taskMAX, CRITERIA_ARG, c, NULL); - /* free buffer */ - AIT_FREE_VAL(&c->cli_buf); + /* free buffer(s) */ + ait_freeVars(&c->cli_buf); array_Del(s->srv_blob.clients, c->cli_id, 0); if (c) @@ -705,14 +711,20 @@ acceptBLOBClients(sched_task_t *task) c->cli_parent = srv; } - /* alloc empty buffer */ - AIT_SET_BUFSIZ(&c->cli_buf, 0, srv->srv_netbuf); + /* init buffer(s) */ + c->cli_buf = ait_allocVars(1); + if (!c->cli_buf) { + rpc_SetErr(elwix_GetErrno(), "%s", elwix_GetError()); + array_Del(srv->srv_blob.clients, i, 42); + goto end; + } else + AIT_SET_BUFSIZ(array(c->cli_buf, 0, ait_val_t*), 0, srv->srv_netbuf); /* accept client */ c->cli_sock = accept(TASK_FD(task), &c->cli_sa.sa, &salen); if (c->cli_sock == -1) { LOGERR; - AIT_FREE_VAL(&c->cli_buf); + ait_freeVars(&c->cli_buf); array_Del(srv->srv_blob.clients, i, 42); goto end; } else { @@ -906,7 +918,7 @@ rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv) close(c->cli_sock); schedCancelby(srv->srv_blob.root, taskMAX, CRITERIA_ARG, c, NULL); - AIT_FREE_VAL(&c->cli_buf); + ait_freeVars(&c->cli_buf); } array_Del(srv->srv_blob.clients, i, 42); } @@ -1112,7 +1124,7 @@ rpc_srv_loopServer(rpc_srv_t * __restrict srv) schedCancelby(srv->srv_root, taskMAX, CRITERIA_ARG, c, NULL); ait_freeVars(&RPC_RETVARS(c)); - AIT_FREE_VAL(&c->cli_buf); + ait_freeVars(&c->cli_buf); } array_Del(srv->srv_clients, i, 42); }