--- libaitrpc/src/srv.c 2010/06/18 13:36:01 1.1.1.1.2.1 +++ libaitrpc/src/srv.c 2010/06/18 15:47:34 1.1.1.1.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.1.1.1.2.1 2010/06/18 13:36:01 misho Exp $ +* $Id: srv.c,v 1.1.1.1.2.2 2010/06/18 15:47:34 misho Exp $ * *************************************************************************/ #include "global.h" @@ -243,6 +243,7 @@ rpc_srv_initServer(u_int regProgID, u_int regProcID, i srv->srv_session.sess_program = regProgID; srv->srv_session.sess_process = regProcID; + srv->srv_server.cli_tid = pthread_self(); srv->srv_server.cli_parent = srv; if (family == AF_INET) memcpy(&srv->srv_server.cli_sa, &sin, sizeof srv->srv_server.cli_sa); @@ -334,6 +335,9 @@ rpc_srv_execServer(rpc_srv_t * __restrict srv) socklen_t salen = sizeof(struct sockaddr); register int i; rpc_cli_t *c; + fd_set fds; + int ret; + struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; if (!srv) { rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t start RPC server ...\n"); @@ -353,9 +357,20 @@ rpc_srv_execServer(rpc_srv_t * __restrict srv) usleep(1000000); continue; } + + FD_ZERO(&fds); + FD_SET(srv->srv_server.cli_sock, &fds); + ret = select(srv->srv_server.cli_sock + 1, &fds, NULL, NULL, &tv); + if (ret == -1) { + LOGERR; + ret = 1; + break; + } + if (!ret) + continue; + c->cli_sock = accept(srv->srv_server.cli_sock, &c->cli_sa, &salen); if (c->cli_sock == -1) { - printf("%s(%d): #%d - %s\n", __func__, __LINE__, errno, strerror(errno)); LOGERR; continue; } else @@ -367,7 +382,6 @@ rpc_srv_execServer(rpc_srv_t * __restrict srv) } } - /* not reached !!! */ return 0; }