--- libaitrpc/src/srv.c 2012/03/15 01:55:33 1.7 +++ libaitrpc/src/srv.c 2012/03/28 13:37:13 1.7.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.7 2012/03/15 01:55:33 misho Exp $ +* $Id: srv.c,v 1.7.2.2 2012/03/28 13:37:13 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -114,7 +114,7 @@ execCall(sched_task_t *task) ioTRACE(RPC_TRACE_LEVEL); /* Go decapsulate variables ... */ - if (!(rpc->call_req.flags & RPC_NOREPLY) && argc) { + if (argc) { arr = io_buffer2vars(buf + sizeof(struct tagRPCCall), TASK_DATLEN(task) - sizeof(struct tagRPCCall), argc, 1); if (!arr) { @@ -135,13 +135,20 @@ execCall(sched_task_t *task) ioDEBUG(RPC_DEBUG_LEVEL, "RPC function %s from module %s", AIT_GET_STR(&f->func_name), AIT_GET_LIKE(&f->func_file, char*)); + /* if client doesn't want reply */ + argc = rpc->call_req.flags & RPC_NOREPLY; rpc->call_rep.ret = RPC_ERROR(rpc_srv_execCall(f, rpc, arr)); if (rpc->call_rep.ret == htonl(-1)) { rpc->call_rep.eno = RPC_ERROR(errno); rpc->call_argc ^= rpc->call_argc; } else { rpc->call_rep.eno ^= rpc->call_rep.eno; - rpc->call_argc = htons(rpc_srv_getVars(f, NULL)); + if (argc) { + /* without reply */ + io_clrVars(f->func_vars); + rpc->call_argc ^= rpc->call_argc; + } else + rpc->call_argc = htons(rpc_srv_getVars(f, NULL)); } } @@ -312,7 +319,7 @@ rxBLOB(sched_task_t *task) ioTRACE(RPC_TRACE_LEVEL); /* check for disable service at this moment? */ - if (s->srv_blob.state == disable) { + if (!s || s->srv_blob.state == disable) { usleep(100000); #ifdef HAVE_PTHREAD_YIELD pthread_yield(); @@ -586,10 +593,9 @@ rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) ioTRACE(RPC_TRACE_LEVEL); - if (!srv) { - rpc_SetErr(EINVAL, "Can`t destroy server because parameter is null!"); + if (!srv || srv->srv_blob.state == disable) return; - } else + else srv->srv_blob.state = kill; rpc_srv_unregisterCall(srv, NULL, CALL_BLOBSHUTDOWN); @@ -621,6 +627,9 @@ rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) while (pthread_mutex_trylock(&srv->srv_blob.mtx) == EBUSY); pthread_mutex_destroy(&srv->srv_blob.mtx); + + /* at final, save disable BLOB service state */ + srv->srv_blob.state = disable; } /* @@ -838,6 +847,7 @@ rpc_srv_initServer(u_int regProgID, u_int regProcID, i rpc_srv_registerCall(srv, NULL, CALL_SRVCLIENTS, 1); rpc_srv_registerCall(srv, NULL, CALL_SRVSESSIONS, 4); rpc_srv_registerCall(srv, NULL, CALL_SRVCALLS, 1); + return srv; }