--- libaitrpc/src/cli.c 2011/10/31 14:58:33 1.5.2.5 +++ libaitrpc/src/cli.c 2011/11/03 13:35:39 1.5.2.6 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.5.2.5 2011/10/31 14:58:33 misho Exp $ +* $Id: cli.c,v 1.5.2.6 2011/11/03 13:35:39 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -65,8 +65,6 @@ rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli, rpc_SetErr(EINVAL, "Error:: Invalid parameters can`t connect to BLOB server ...\n"); return NULL; } - if (!Port) - Port = RPC_DEFPORT + 1; cli = malloc(sizeof(rpc_cli_t)); if (!cli) { @@ -76,12 +74,12 @@ rpc_cli_openBLOBClient(rpc_cli_t * __restrict rpccli, memcpy(cli, rpccli, sizeof(rpc_cli_t)); memcpy(&sa, &rpccli->cli_sa, sizeof sa); - switch (rpccli->cli_sa.sa.sa_family) { + switch (sa.sa.sa_family) { case AF_INET: - sa.sin.sin_port = htons(Port); + sa.sin.sin_port = htons(Port ? Port : ntohs(sa.sin.sin_port) + 1); break; case AF_INET6: - sa.sin6.sin6_port = htons(Port); + sa.sin6.sin6_port = htons(Port ? Port : ntohs(sa.sin6.sin6_port) + 1); break; case AF_LOCAL: strlcat(sa.sun.sun_path, ".blob", sizeof sa.sun.sun_path); @@ -323,12 +321,12 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, /* prepare RPC call */ rpc = (struct tagRPCCall*) buf; rpc_addPktSession(&rpc->call_session, cli->cli_parent); - rpc->call_argc = htons(in_vars ? io_arraySize(in_vars) : 0); + rpc->call_argc = htons(io_arraySize(in_vars)); rpc->call_tag = tag = htons(crcFletcher16((u_short*) str, sizeof str / 2)); rpc->call_hash = hash = htonl(hash_fnv((char*) str, sizeof str)); Limit = sizeof(struct tagRPCCall); - if (in_vars && io_arraySize(in_vars)) { + if (io_arraySize(in_vars)) { /* marshaling variables */ ret = io_vals2buffer(buf + Limit, cli->cli_netbuf - Limit, in_vars); if (ret == -1) { @@ -387,7 +385,6 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, } else Limit = sizeof(struct tagRPCRet); if (rrpc->ret_tag != tag || rrpc->ret_hash != hash) { - printf("tag=%x/%x hash=%x/%x\n", rrpc->ret_tag, tag, rrpc->ret_hash, hash); rpc_SetErr(ERPCMISMATCH, "Error:: get wrong RPC reply ...\n"); free(buf); return -5; @@ -421,12 +418,12 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, } /* - * rpc_cli_freeVals() Free ait_val_t array returned from RPC call + * rpc_cli_freeVars() Free ait_val_t array returned from RPC call * @vars = Variable array * return: none */ inline void -rpc_cli_freeVals(array_t ** __restrict vars) +rpc_cli_freeVars(array_t ** __restrict vars) { register int i; @@ -442,12 +439,12 @@ rpc_cli_freeVals(array_t ** __restrict vars) } /* - * rpc_cli_allocVals() Allocate ait_val_t array for RPC call + * rpc_cli_allocVars() Allocate ait_val_t array for RPC call * @args = Number of arguments * return: =NULL error or !=NULL allocated array */ inline array_t * -rpc_cli_allocVals(u_short args) +rpc_cli_allocVars(u_short args) { array_t *arr; register int i; @@ -463,7 +460,7 @@ rpc_cli_allocVals(u_short args) v = malloc(sizeof(ait_val_t)); if (!v) { LOGERR; - rpc_cli_freeVals(&arr); + rpc_cli_freeVars(&arr); return NULL; } else { memset(v, 0, sizeof(ait_val_t));