--- libaitrpc/inc/aitrpc.h 2014/11/26 00:49:46 1.24.2.4 +++ libaitrpc/inc/aitrpc.h 2014/12/16 23:52:07 1.24.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitrpc.h,v 1.24.2.4 2014/11/26 00:49:46 misho Exp $ +* $Id: aitrpc.h,v 1.24.2.5 2014/12/16 23:52:07 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -360,16 +360,18 @@ void rpc_srv_endServer(rpc_srv_t ** __restrict psrv); * return: -1 error or 0 ok, infinite loop ... */ int rpc_srv_loopServer(rpc_srv_t * __restrict srv); -#define rpc_srv_execServer(_srv, _sync) do { assert((_srv)); \ - if (!(_srv)->srv_kill) { \ - pthread_create(&(_srv)->srv_tid, NULL, (void*(*)(void*)) \ - rpc_srv_loopServer, (_srv)); \ - if ((_sync)) \ - pthread_join((_srv)->srv_tid, (void**) (_sync)); \ - else \ - pthread_detach((_srv)->srv_tid); \ - } } while (0) -#define rpc_srv_killServer(_srv) (assert((_srv)), (_srv)->srv_blob.kill = 1, (_srv)->srv_kill = 1) +#define rpc_srv_execServer(_srv, _sync) \ + do { assert((_srv)); \ + if (!(_srv)->srv_kill) { \ + pthread_create(&(_srv)->srv_tid, NULL, (void*(*)(void*)) \ + rpc_srv_loopServer, (_srv)); \ + if ((_sync)) \ + pthread_join((_srv)->srv_tid, (void**) (_sync)); \ + else \ + pthread_detach((_srv)->srv_tid); \ + } } while (0) +#define rpc_srv_killServer(_srv) \ + (assert((_srv)), (_srv)->srv_blob.kill = 1, (_srv)->srv_kill = 1) /* * rpc_srv_initBLOBServer() - Init & create BLOB Server @@ -394,14 +396,14 @@ void rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv) * return: -1 error or 0 ok, infinite loop ... */ int rpc_srv_loopBLOBServer(rpc_srv_t * __restrict srv); -#define rpc_srv_execBLOBServer(_srv) do { assert((_srv)); \ - if (!(_srv)->srv_kill && !(_srv)->srv_blob.kill) { \ - pthread_create(&(_srv)->srv_blob.tid, NULL, \ - (void*(*)(void*)) \ - rpc_srv_loopBLOBServer, (_srv)); \ - pthread_detach((_srv)->srv_blob.tid); \ - } \ - } while (0) +#define rpc_srv_execBLOBServer(_srv) \ + do { assert((_srv)); \ + if (!(_srv)->srv_kill && !(_srv)->srv_blob.kill) { \ + pthread_create(&(_srv)->srv_blob.tid, NULL, \ + (void*(*)(void*)) rpc_srv_loopBLOBServer, (_srv)); \ + pthread_detach((_srv)->srv_blob.tid); \ + } \ + } while (0) /* * rpc_srv_initServer2() - Init & create layer2 RPC Server @@ -422,6 +424,17 @@ rpc_srv_t *rpc_srv_initServer2(u_char InstID, int conc * return: -1 error or 0 ok, infinite loop ... */ int rpc_srv_loopServer2(rpc_srv_t * __restrict srv); +#define rpc_srv_execServer2(_srv, _sync) \ + do { assert((_srv)); \ + if (!(_srv)->srv_kill) { \ + pthread_create(&(_srv)->srv_tid, NULL, (void*(*)(void*)) \ + rpc_srv_loopServer2, (_srv)); \ + if ((_sync)) \ + pthread_join((_srv)->srv_tid, (void**) (_sync)); \ + else \ + pthread_detach((_srv)->srv_tid); \ + } } while (0) +#define rpc_srv_killServer2(x) rpc_srv_killServer((x)) /* * rpc_srv_registerCall() - Register call to RPC server