--- libaitrpc/src/srv.c 2012/11/19 15:48:45 1.12.2.8 +++ libaitrpc/src/srv.c 2012/11/19 21:28:55 1.12.2.10 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.12.2.8 2012/11/19 15:48:45 misho Exp $ +* $Id: srv.c,v 1.12.2.10 2012/11/19 21:28:55 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -71,12 +71,8 @@ inline void rpc_freeCli(rpc_cli_t * __restrict c) { rpc_srv_t *s = c->cli_parent; - ait_val_t v; - printf("_t_1=%p t_e=%p so=%d c=%p %s:%hu\n", s->srv_root->root_timer.tqh_first, *s->srv_root->root_timer.tqh_last, c->cli_sock, c, io_n2addr(&c->cli_sa, &v), io_n2port(&c->cli_sa)); -AIT_FREE_VAL(&v); schedCancelby(s->srv_root, taskMAX, CRITERIA_ARG, c, NULL); - printf("+t_1=%p t_e=%p so=%d c=%p\n", s->srv_root->root_timer.tqh_first, *s->srv_root->root_timer.tqh_last, c->cli_sock, c); /* free buffer */ AIT_FREE_VAL(&c->cli_buf); @@ -119,6 +115,7 @@ _allocClient(rpc_srv_t * __restrict srv, io_sockaddr_t if (!c) { c = io_malloc(sizeof(rpc_cli_t)); + printf("+++++++++++++++++++++++++++id=%d %p\n", n, c); if (!c) { LOGERR; srv->srv_kill = 1; @@ -525,25 +522,32 @@ end: /* ------------------------------------------------------ */ -static void * -closeBLOBClient(sched_task_t *task) +inline void +rpc_freeBLOBCli(rpc_cli_t * __restrict c) { - rpc_cli_t *c = TASK_ARG(task); rpc_srv_t *s = c->cli_parent; - schedCancelby(TASK_ROOT(task), taskMAX, CRITERIA_ARG, TASK_ARG(task), NULL); + schedCancelby(s->srv_blob.root, taskMAX, CRITERIA_ARG, c, NULL); - /* close client socket */ - if (TASK_VAL(task)) - shutdown(c->cli_sock, SHUT_RDWR); - close(c->cli_sock); - /* free buffer */ AIT_FREE_VAL(&c->cli_buf); io_arrayDel(s->srv_blob.clients, c->cli_id, 0); if (c) io_free(c); +} + + +static void * +closeBLOBClient(sched_task_t *task) +{ + int sock = ((rpc_cli_t*) TASK_ARG(task))->cli_sock; + + rpc_freeBLOBCli(TASK_ARG(task)); + + /* close client socket */ + shutdown(sock, SHUT_RDWR); + close(sock); return NULL; }