|
|
| version 1.11.2.3, 2012/09/17 14:16:42 | version 1.11.2.5, 2012/11/13 09:21:27 |
|---|---|
| Line 135 execCall(sched_task_t *task) | Line 135 execCall(sched_task_t *task) |
| if (argc) { | if (argc) { |
| arr = io_buffer2vars(buf + sizeof(struct tagRPCCall), | arr = io_buffer2vars(buf + sizeof(struct tagRPCCall), |
| AIT_LEN(&c->cli_buf) - TASK_VAL(task) - sizeof(struct tagRPCCall), | AIT_LEN(&c->cli_buf) - TASK_VAL(task) - sizeof(struct tagRPCCall), |
| argc, 1); | argc, 42); |
| if (!arr) { | if (!arr) { |
| rpc_SetErr(ERPCMISMATCH, "#%d - %s", io_GetErrno(), io_GetError()); | rpc_SetErr(ERPCMISMATCH, "#%d - %s", io_GetErrno(), io_GetError()); |
| rpc->call_argc ^= rpc->call_argc; | rpc->call_argc ^= rpc->call_argc; |
| Line 185 rxPacket(sched_task_t *task) | Line 185 rxPacket(sched_task_t *task) |
| u_char *buf = AIT_GET_BUF(&c->cli_buf); | u_char *buf = AIT_GET_BUF(&c->cli_buf); |
| struct tagRPCCall *rpc; | struct tagRPCCall *rpc; |
| memset(buf, 0, AIT_LEN(&c->cli_buf)); | if (!off) |
| memset(buf, 0, AIT_LEN(&c->cli_buf)); | |
| else | |
| memmove(buf, buf + off, AIT_LEN(&c->cli_buf) - off); | |
| rlen = recv(TASK_FD(task), buf + off, AIT_LEN(&c->cli_buf) - off, 0); | rlen = recv(TASK_FD(task), buf + off, AIT_LEN(&c->cli_buf) - off, 0); |
| if (rlen < 1) { | if (rlen < 1) { |
| /* close connection */ | /* close connection */ |
| Line 734 rpc_srv_initServer(u_int regProgID, u_char regProcID, | Line 737 rpc_srv_initServer(u_int regProgID, u_char regProcID, |
| srv->srv_server.cli_parent = srv; | srv->srv_server.cli_parent = srv; |
| memcpy(&srv->srv_server.cli_sa, &sa, sizeof srv->srv_server.cli_sa); | memcpy(&srv->srv_server.cli_sa, &sa, sizeof srv->srv_server.cli_sa); |
| /* init functions list */ | /* init functions */ |
| TAILQ_INIT(&srv->srv_funcs); | pthread_mutex_init(&srv->srv_funcs.mtx, NULL); |
| SLIST_INIT(&srv->srv_funcs); | |
| AVL_INIT(&srv->srv_funcs); | |
| /* init scheduler */ | /* init scheduler */ |
| srv->srv_root = schedBegin(); | srv->srv_root = schedBegin(); |
| if (!srv->srv_root) { | if (!srv->srv_root) { |
| rpc_SetErr(sched_GetErrno(), "%s", sched_GetError()); | rpc_SetErr(sched_GetErrno(), "%s", sched_GetError()); |
| pthread_mutex_destroy(&srv->srv_funcs.mtx); | |
| io_free(srv); | io_free(srv); |
| return NULL; | return NULL; |
| } | } |
| Line 750 rpc_srv_initServer(u_int regProgID, u_char regProcID, | Line 756 rpc_srv_initServer(u_int regProgID, u_char regProcID, |
| if (!srv->srv_clients) { | if (!srv->srv_clients) { |
| rpc_SetErr(io_GetErrno(), "%s", io_GetError()); | rpc_SetErr(io_GetErrno(), "%s", io_GetError()); |
| schedEnd(&srv->srv_root); | schedEnd(&srv->srv_root); |
| pthread_mutex_destroy(&srv->srv_funcs.mtx); | |
| io_free(srv); | io_free(srv); |
| return NULL; | return NULL; |
| } | } |
| Line 760 rpc_srv_initServer(u_int regProgID, u_char regProcID, | Line 767 rpc_srv_initServer(u_int regProgID, u_char regProcID, |
| LOGERR; | LOGERR; |
| io_arrayDestroy(&srv->srv_clients); | io_arrayDestroy(&srv->srv_clients); |
| schedEnd(&srv->srv_root); | schedEnd(&srv->srv_root); |
| pthread_mutex_destroy(&srv->srv_funcs.mtx); | |
| io_free(srv); | io_free(srv); |
| return NULL; | return NULL; |
| } | } |
| Line 789 err: /* error condition */ | Line 797 err: /* error condition */ |
| close(srv->srv_server.cli_sock); | close(srv->srv_server.cli_sock); |
| io_arrayDestroy(&srv->srv_clients); | io_arrayDestroy(&srv->srv_clients); |
| schedEnd(&srv->srv_root); | schedEnd(&srv->srv_root); |
| pthread_mutex_destroy(&srv->srv_funcs.mtx); | |
| io_free(srv); | io_free(srv); |
| return NULL; | return NULL; |
| } | } |
| Line 812 rpc_srv_endServer(rpc_srv_t ** __restrict psrv) | Line 821 rpc_srv_endServer(rpc_srv_t ** __restrict psrv) |
| (*psrv)->srv_kill = 1; | (*psrv)->srv_kill = 1; |
| sleep(RPC_SCHED_POLLING); | sleep(RPC_SCHED_POLLING); |
| pthread_mutex_destroy(&(*psrv)->srv_funcs.mtx); | |
| io_free(*psrv); | io_free(*psrv); |
| *psrv = NULL; | *psrv = NULL; |
| } | } |
| Line 827 rpc_srv_loopServer(rpc_srv_t * __restrict srv) | Line 837 rpc_srv_loopServer(rpc_srv_t * __restrict srv) |
| { | { |
| rpc_cli_t *c; | rpc_cli_t *c; |
| register int i; | register int i; |
| rpc_func_t *f, *tmp; | rpc_func_t *f; |
| struct timespec ts = { RPC_SCHED_POLLING, 0 }; | struct timespec ts = { RPC_SCHED_POLLING, 0 }; |
| if (!srv) { | if (!srv) { |
| Line 835 rpc_srv_loopServer(rpc_srv_t * __restrict srv) | Line 845 rpc_srv_loopServer(rpc_srv_t * __restrict srv) |
| return -1; | return -1; |
| } | } |
| fcntl(srv->srv_server.cli_sock, F_SETFL, | |
| fcntl(srv->srv_server.cli_sock, F_GETFL) | O_NONBLOCK); | |
| if (listen(srv->srv_server.cli_sock, io_arraySize(srv->srv_clients)) == -1) { | if (listen(srv->srv_server.cli_sock, io_arraySize(srv->srv_clients)) == -1) { |
| LOGERR; | LOGERR; |
| return -1; | return -1; |
| } | } else |
| fcntl(srv->srv_server.cli_sock, F_SETFL, | |
| fcntl(srv->srv_server.cli_sock, F_GETFL) | O_NONBLOCK); | |
| if (!schedRead(srv->srv_root, acceptClients, srv, srv->srv_server.cli_sock, NULL, 0)) { | if (!schedRead(srv->srv_root, acceptClients, srv, srv->srv_server.cli_sock, NULL, 0)) { |
| rpc_SetErr(sched_GetErrno(), "%s", sched_GetError()); | rpc_SetErr(sched_GetErrno(), "%s", sched_GetError()); |
| Line 870 rpc_srv_loopServer(rpc_srv_t * __restrict srv) | Line 879 rpc_srv_loopServer(rpc_srv_t * __restrict srv) |
| close(srv->srv_server.cli_sock); | close(srv->srv_server.cli_sock); |
| /* detach exported calls */ | /* detach exported calls */ |
| TAILQ_FOREACH_SAFE(f, &srv->srv_funcs, func_node, tmp) { | RPC_FUNCS_LOCK(&srv->srv_funcs); |
| TAILQ_REMOVE(&srv->srv_funcs, f, func_node); | while ((f = SLIST_FIRST(&srv->srv_funcs))) { |
| SLIST_REMOVE_HEAD(&srv->srv_funcs, func_next); | |
| AIT_FREE_VAL(&f->func_name); | AIT_FREE_VAL(&f->func_name); |
| io_free(f); | io_free(f); |
| } | } |
| srv->srv_funcs.avlh_root = NULL; | |
| RPC_FUNCS_UNLOCK(&srv->srv_funcs); | |
| schedEnd(&srv->srv_root); | schedEnd(&srv->srv_root); |
| return 0; | return 0; |