--- libaitrpc/src/cli.c 2012/11/19 12:43:21 1.12.2.1 +++ libaitrpc/src/cli.c 2012/11/19 14:51:52 1.12.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.12.2.1 2012/11/19 12:43:21 misho Exp $ +* $Id: cli.c,v 1.12.2.2 2012/11/19 14:51:52 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -270,6 +270,8 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short if (out_vars) *out_vars = NULL; + memset(&sa, 0, sizeof sa); + /* prepare RPC call */ rpc = (struct tagRPCCall*) buf; rpc_addPktSession(&rpc->call_session, cli->cli_parent); @@ -334,18 +336,18 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short do { if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { - if (ret) + if (ret) { LOGERR; - else { + } else { if (wlen++ < 7) continue; else rpc_SetErr(ETIMEDOUT, "Timeout, no answer from RPC server"); } + return -1; } - } while (0); - do { + memset(buf, 0, AIT_LEN(&cli->cli_buf)); if (cli->cli_id == SOCK_STREAM) ret = recv(cli->cli_sock, buf, AIT_LEN(&cli->cli_buf), 0); @@ -361,10 +363,13 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short } return -1; } - /* check for response from known address */ - if (io_addrcmp(&cli->cli_sa, &sa, 42)) { - rpc_SetErr(ERPCMISMATCH, "Received RPC response from unknown address"); - continue; + + if (cli->cli_id == SOCK_DGRAM) { + /* check for response from known address */ + if (io_addrcmp(&cli->cli_sa, &sa, 42)) { + rpc_SetErr(ERPCMISMATCH, "Received RPC response from unknown address"); + continue; + } } } while (0); if (ret < sizeof(struct tagRPCCall)) {