--- libaitrpc/src/builtin.c 2013/03/07 23:10:50 1.12 +++ libaitrpc/src/builtin.c 2015/07/19 23:54:48 1.22.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: builtin.c,v 1.12 2013/03/07 23:10:50 misho Exp $ +* $Id: builtin.c,v 1.22.2.1 2015/07/19 23:54:48 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 +Copyright 2004 - 2015 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ SUCH DAMAGE. /* builtin RPC server functions */ static int -rpcServerClients(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcServerClients(RPC_CALL_STDARGS) { rpc_srv_t *srv; rpc_cli_t *c; @@ -90,7 +90,7 @@ rpcServerClients(rpc_cli_t *cli, struct tagRPCCall *rp } static int -rpcServerCalls(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcServerCalls(RPC_CALL_STDARGS) { rpc_srv_t *srv; rpc_func_t *f; @@ -126,47 +126,50 @@ rpcServerCalls(rpc_cli_t *cli, struct tagRPCCall *rpc, } static int -rpcServerSessions(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcServerSessions(RPC_CALL_STDARGS) { rpc_srv_t *srv; RPC_CALLBACK_CHECK_INPUT(cli); srv = RPC_SRV_SERVER(cli); - AIT_SET_I32(ait_getVars(&RPC_RETVARS(cli), 3), array_Size(srv->srv_clients)); + AIT_SET_I32(ait_getVars(&RPC_RETVARS(cli), 2), array_Size(srv->srv_clients)); AIT_SET_U8(ait_getVars(&RPC_RETVARS(cli), 0), srv->srv_session.sess_version); - AIT_SET_U32(ait_getVars(&RPC_RETVARS(cli), 1), srv->srv_session.sess_program); - AIT_SET_U8(ait_getVars(&RPC_RETVARS(cli), 2), srv->srv_session.sess_process); + AIT_SET_U8(ait_getVars(&RPC_RETVARS(cli), 1), srv->srv_session.sess_instance); return 0; } static int -rpcServerShutdown(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcServerShutdown(RPC_CALL_STDARGS) { rpc_srv_t *srv; RPC_CALLBACK_CHECK_INPUT(cli); srv = RPC_SRV_SERVER(cli); - rpc_freeCli(cli); - + if (srv->srv_blob.tid) + pthread_kill(srv->srv_blob.tid, SIGFBLOB); + while (srv->srv_blob.root) { + srv->srv_blob.kill = 1; + usleep(1000); + } srv->srv_kill = 1; return 0; } static int -rpcServerPing(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcServerPing(RPC_CALL_STDARGS) { - if (rpc->call_req.flags == RPC_REPLY) - AIT_SET_U16(ait_getVars(&RPC_RETVARS(cli), 0), ntohs(rpc->call_seq)); + if (ntohl((u_long) rpc->call_req.flags) == RPC_REPLY) + AIT_SET_U16(ait_getVars(&RPC_RETVARS(cli), 0), random() % USHRT_MAX); return 0; } /* ---------------------------------------------------- */ static int -rpcBLOBServerShutdown(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcBLOBServerShutdown(RPC_CALL_STDARGS) { rpc_srv_t *srv; @@ -180,7 +183,7 @@ rpcBLOBServerShutdown(rpc_cli_t *cli, struct tagRPCCal } static int -rpcBLOBServerVars(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcBLOBServerVars(RPC_CALL_STDARGS) { rpc_srv_t *srv; rpc_blob_t *b; @@ -223,7 +226,7 @@ rpcBLOBServerVars(rpc_cli_t *cli, struct tagRPCCall *r } static int -rpcBLOBServerClients(rpc_cli_t *cli, struct tagRPCCall *rpc, array_t *iv) +rpcBLOBServerClients(RPC_CALL_STDARGS) { rpc_srv_t *srv; rpc_cli_t *c; @@ -275,7 +278,7 @@ rpcBLOBServerClients(rpc_cli_t *cli, struct tagRPCCall * @srv = RPC server instance * return: -1 error or 0 ok */ -inline int +int rpc_register_srvPing(rpc_srv_t * __restrict srv) { if (!srv)