--- libaitrpc/src/srv.c 2012/03/12 14:53:07 1.6.2.1 +++ libaitrpc/src/srv.c 2012/03/12 15:04:38 1.6.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.6.2.1 2012/03/12 14:53:07 misho Exp $ +* $Id: srv.c,v 1.6.2.2 2012/03/12 15:04:38 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -777,6 +777,7 @@ rpc_srv_loopServer(rpc_srv_t * __restrict srv) fd_set fds; int ret; struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; + pthread_attr_t attr; if (!srv) { rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t start RPC server ...\n"); @@ -791,6 +792,9 @@ rpc_srv_loopServer(rpc_srv_t * __restrict srv) return -1; } + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + while (srv->srv_kill != kill) { for (c = srv->srv_clients, i = 0; i < srv->srv_numcli && c; i++, c++) if (!c->cli_sa.sa.sa_family) @@ -822,13 +826,13 @@ rpc_srv_loopServer(rpc_srv_t * __restrict srv) } else c->cli_parent = srv; - if (pthread_create(&c->cli_tid, NULL, rpc_srv_dispatchCall, c)) { + if (pthread_create(&c->cli_tid, &attr, rpc_srv_dispatchCall, c)) { LOGERR; continue; - } else - pthread_detach(c->cli_tid); + } } + pthread_attr_destroy(&attr); return 0; }