--- libaitrpc/src/cli.c 2016/08/02 12:00:39 1.26.4.3 +++ libaitrpc/src/cli.c 2019/08/15 14:59:18 1.27.2.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.26.4.3 2016/08/02 12:00:39 misho Exp $ +* $Id: cli.c,v 1.27.2.1 2019/08/15 14:59:18 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2016 +Copyright 2004 - 2019 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -71,7 +71,7 @@ rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli, } else memcpy(cli, rpccli, sizeof(rpc_cli_t)); - memcpy(&cli->cli_sa, &rpccli->cli_sa, sizeof(sockaddr_t)); + memcpy(&cli->cli_sa, &rpccli->cli_sa, sizeof cli->cli_sa); switch (cli->cli_sa.sa.sa_family) { case AF_INET: cli->cli_sa.sin.sin_port = @@ -111,7 +111,7 @@ rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli, e_free(cli); return NULL; } - if (connect(cli->cli_sock, &cli->cli_sa.sa, sizeof cli->cli_sa.sa) == -1) { + if (connect(cli->cli_sock, &cli->cli_sa.sa, e_addrlen(&cli->cli_sa)) == -1) { LOGERR; close(cli->cli_sock); e_free(cli); @@ -405,7 +405,7 @@ rpc_pkt_Receive(int sock, int type, sockaddr_t * __res if (seq != ntohl(rpc->call_seq)) continue; } - } while (ret < 1); + } while (ret < 0); return ret; } @@ -605,14 +605,16 @@ rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short if ((wlen = rpc_pkt_Receive(cli->cli_sock, cli->cli_id, &cli->cli_sa, &cli->cli_buf, seq)) == -1) return -1; - if (!wlen) /* closed rpc connection */ - return 1; + if (!wlen) { /* closed rpc connection */ + rpc_SetErr(ECONNRESET, "Closed connection"); + return -1; + } if ((wlen = rpc_pkt_Replay(&cli->cli_buf, cli->cli_parent, tag, out_vars, type)) == -1) return -1; - return 0; + return wlen; } /*