--- libaitrpc/src/blob.c 2013/05/26 20:24:52 1.12.2.1 +++ libaitrpc/src/blob.c 2013/07/15 14:27:28 1.13.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: blob.c,v 1.12.2.1 2013/05/26 20:24:52 misho Exp $ +* $Id: blob.c,v 1.13.2.3 2013/07/15 14:27:28 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -272,10 +272,12 @@ rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_ * @cli = Client instance * @var = BLOB variable * @data = BLOB data + * @tout = BLOB live on server timeout in seconds, if =0 default timeout * return: -1 error, 0 ok, 1 remote error */ int -rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t * __restrict var, void * __restrict data) +rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t * __restrict var, + void * __restrict data, int tout) { int ret, len; uint8_t *pos; @@ -291,7 +293,7 @@ rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t rpc_addPktSession(&hdr.hdr_session, cli->cli_parent); hdr.hdr_cmd = set; hdr.hdr_var = 0; - hdr.hdr_ret = 0; + hdr.hdr_ret = tout; hdr.hdr_len = htonl(AIT_LEN(var)); /* send SET request */ @@ -330,12 +332,15 @@ rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t } if (hdr.hdr_cmd != error) { + AIT_SET_BLOB(var, ntohl(hdr.hdr_var), ntohl(hdr.hdr_len)); + if (ntohl(hdr.hdr_len) != AIT_LEN(var)) { + rpc_cli_delBLOB(cli, var); + AIT_NEW_BLOB(var, ntohl(hdr.hdr_len)); + rpc_SetErr(ECANCELED, "Bad return length packet"); return 1; } - - AIT_SET_BLOB(var, ntohl(hdr.hdr_var), ntohl(hdr.hdr_len)); } return hdr.hdr_cmd == error;