--- libaitrpc/src/cli.c 2012/05/17 21:40:02 1.9.2.14 +++ libaitrpc/src/cli.c 2012/05/17 22:57:42 1.9.2.15 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.9.2.14 2012/05/17 21:40:02 misho Exp $ +* $Id: cli.c,v 1.9.2.15 2012/05/17 22:57:42 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -290,11 +290,19 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short pfd.fd = cli->cli_sock; pfd.events = POLLOUT; - if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) == -1 || - pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { - LOGERR; - return -1; - } + do { + if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || + pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { + if (ret) { + if (errno == EAGAIN) + continue; + else + LOGERR; + } else + rpc_SetErr(ETIMEDOUT, "Timeout, can't send to RPC server"); + return -1; + } + } while (0); if ((ret = send(cli->cli_sock, buf, wlen, MSG_NOSIGNAL)) == -1) { LOGERR; return -1; @@ -308,17 +316,20 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short return 0; /* reply from RPC server */ - pfd.fd = cli->cli_sock; pfd.events = POLLIN | POLLPRI; - if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) == -1 || - pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { - if (ret) - LOGERR; - else - rpc_SetErr(ETIMEDOUT, "Timeout, no answer from RPC server"); - - return -1; - } + do { + if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || + pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { + if (ret) { + if (errno == EAGAIN) + continue; + else + LOGERR; + } else + rpc_SetErr(ETIMEDOUT, "Timeout, no answer from RPC server"); + return -1; + } + } while (0); memset(buf, 0, AIT_LEN(&cli->cli_buf)); if ((ret = recv(cli->cli_sock, buf, AIT_LEN(&cli->cli_buf), 0)) < 1) { if (ret) @@ -382,8 +393,8 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short inline int rpc_cli_ping(rpc_cli_t *cli) { - array_t *arr; int ret = 0; + array_t *arr = NULL; if (!cli) return -1;