--- libaitrpc/src/cli.c 2013/05/30 09:22:01 1.16 +++ libaitrpc/src/cli.c 2013/08/22 08:56:15 1.16.8.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.16 2013/05/30 09:22:01 misho Exp $ +* $Id: cli.c,v 1.16.8.2 2013/08/22 08:56:15 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -172,14 +172,6 @@ rpc_cli_openClient(u_char InstID, int netBuf, const ch else netBuf = E_ALIGN(netBuf, 2); /* align netBuf length */ -#ifdef HAVE_SRANDOMDEV - srandomdev(); -#else - time_t tim; - - srandom((time(&tim) ^ getpid())); -#endif - cli = e_malloc(sizeof(rpc_cli_t)); if (!cli) { LOGERR; @@ -410,20 +402,24 @@ rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t array_t * __restrict vars, int noreply, int nocrc) { struct tagRPCCall *rpc; - int ret = 0, len = sizeof(struct tagRPCCall); + int ret = 0, estlen, len = sizeof(struct tagRPCCall); u_char *buf; if (!pkt || !sess) { rpc_SetErr(EINVAL, "Invalid argument(s)!"); return -1; - } else - buf = AIT_GET_BUF(pkt); + } + /* calc estimated length */ + estlen = ait_resideVars(vars) + len; + if (estlen > AIT_LEN(pkt)) + AIT_RE_BUF(pkt, estlen); + buf = AIT_GET_BUF(pkt); + /* prepare RPC call */ rpc = (struct tagRPCCall*) buf; rpc_addPktSession(&rpc->call_session, sess); rpc->call_tag = htons(tag); - rpc->call_seq = htons(random() % USHRT_MAX); if (!vars) rpc->call_argc = 0; else