--- libaitrpc/src/blob.c 2011/05/02 23:07:55 1.1.2.16 +++ libaitrpc/src/blob.c 2011/08/19 13:03:06 1.2.4.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: blob.c,v 1.1.2.16 2011/05/02 23:07:55 misho Exp $ +* $Id: blob.c,v 1.2.4.3 2011/08/19 13:03:06 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -60,7 +60,13 @@ rpc_srv_blobCreate(rpc_srv_t * __restrict srv, int len int f; u_int rnd; +#ifdef HAVE_SRANDOMDEV srandomdev(); +#else + time_t tim; + + srandom((time(&tim) ^ getpid())); +#endif again: rnd = random() % UINT_MAX; @@ -182,7 +188,7 @@ rpc_srv_blobFree(rpc_srv_t * __restrict srv, rpc_blob_ memset(szFName, 0, MAXPATHLEN); snprintf(szFName, MAXPATHLEN, BLOB_FILE, srv->srv_blob.dir, blob->blob_var); - if (remove(szFName) == -1) { + if (unlink(szFName) == -1) { LOGERR; return -1; } @@ -209,11 +215,13 @@ rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_ return -1; } - for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) - if ((len = send(cli->cli_sock, pos, ret > BLOBSIZ ? BLOBSIZ : ret, 0)) == -1) { + for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) { + len = send(cli->cli_sock, pos, ret > BLOBSIZ ? BLOBSIZ : ret, 0); + if (len == -1) { LOGERR; return -1; } + } return ret; } @@ -246,7 +254,8 @@ rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_ return -1; } - if ((len = recv(cli->cli_sock, pos, BLOBSIZ, 0)) == -1) { + len = recv(cli->cli_sock, pos, BLOBSIZ, 0); + if (len == -1) { LOGERR; return -1; }