version 1.7.2.1, 2012/05/16 08:10:39
|
version 1.7.2.5, 2012/05/16 13:32:47
|
Line 61 rpc_srv_blobCreate(rpc_srv_t * __restrict srv, int len
|
Line 61 rpc_srv_blobCreate(rpc_srv_t * __restrict srv, int len
|
int f; |
int f; |
u_int rnd; |
u_int rnd; |
|
|
#ifdef HAVE_SRANDOMDEV |
|
srandomdev(); |
|
#else |
|
time_t tim; |
|
|
|
srandom((time(&tim) ^ getpid())); |
|
#endif |
|
again: |
again: |
rnd = random() % UINT_MAX; |
rnd = random() % UINT_MAX; |
|
|
Line 165 rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t
|
Line 158 rpc_srv_blobMap(rpc_srv_t * __restrict srv, rpc_blob_t
|
inline void |
inline void |
rpc_srv_blobUnmap(rpc_blob_t * __restrict blob) |
rpc_srv_blobUnmap(rpc_blob_t * __restrict blob) |
{ |
{ |
if (blob && blob->blob_data) | if (blob && blob->blob_data) { |
munmap(blob->blob_data, blob->blob_len); |
munmap(blob->blob_data, blob->blob_len); |
blob->blob_data = NULL; |
blob->blob_data = NULL; |
} |
} |
Line 220 rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
Line 213 rpc_srv_sendBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
} |
} |
|
|
for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) { |
for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) { |
len = send(cli->cli_sock, pos, ret, 0); | len = send(cli->cli_sock, pos, ret, MSG_NOSIGNAL); |
if (len == -1) { |
if (len == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
Line 252 rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
Line 245 rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
pfd.fd = cli->cli_sock; |
pfd.fd = cli->cli_sock; |
pfd.events = POLLIN | POLLPRI; |
pfd.events = POLLIN | POLLPRI; |
for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) { |
for (ret = blob->blob_len, pos = blob->blob_data; ret > 0; ret -= len, pos += len) { |
if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || | if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
Line 268 rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
Line 261 rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
return ret; |
return ret; |
} |
} |
|
|
// ------------------------------------------------------------ | /* ------------------------------------------------------------ */ |
|
|
/* |
/* |
* rpc_cli_sendBLOB() - Send BLOB to server |
* rpc_cli_sendBLOB() - Send BLOB to server |
Line 301 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 294 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2)); |
hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2)); |
|
|
/* send SET request */ |
/* send SET request */ |
if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { | if (send(cli->cli_sock, &hdr, sizeof hdr, MSG_NOSIGNAL) == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} |
} |
|
|
/* send BLOB to server */ |
/* send BLOB to server */ |
for (ret = AIT_LEN(var), pos = data; ret > 0; ret -= len, pos += len) |
for (ret = AIT_LEN(var), pos = data; ret > 0; ret -= len, pos += len) |
if ((len = send(cli->cli_sock, pos, ret, 0)) == -1) { | if ((len = send(cli->cli_sock, pos, ret, MSG_NOSIGNAL)) == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} |
} |
Line 316 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 309 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
/* wait for reply */ |
/* wait for reply */ |
pfd.fd = cli->cli_sock; |
pfd.fd = cli->cli_sock; |
pfd.events = POLLIN | POLLPRI; |
pfd.events = POLLIN | POLLPRI; |
if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || | if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
if (ret) |
if (ret) |
LOGERR; |
LOGERR; |
Line 342 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 335 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
return 1; |
return 1; |
} |
} |
|
|
var->val.blob = ntohl(hdr.hdr_var); | AIT_SET_BLOB(var, ntohl(hdr.hdr_var), ntohl(hdr.hdr_len)); |
} |
} |
|
|
return hdr.hdr_cmd == error; |
return hdr.hdr_cmd == error; |
Line 397 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 390 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
pfd.fd = cli->cli_sock; |
pfd.fd = cli->cli_sock; |
pfd.events = POLLIN | POLLPRI; |
pfd.events = POLLIN | POLLPRI; |
for (ret = AIT_LEN(var), pos = *data; ret > 0; ret -= len, pos += len) { |
for (ret = AIT_LEN(var), pos = *data; ret > 0; ret -= len, pos += len) { |
if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || | if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
LOGERR; |
LOGERR; |
free(*data); |
free(*data); |
Line 414 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 407 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
} |
} |
|
|
/* wait for reply */ |
/* wait for reply */ |
if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || | if ((len = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
if (len) |
if (len) |
LOGERR; |
LOGERR; |
Line 480 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 473 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2)); |
hdr.hdr_crc = htons(crcFletcher16((u_short*) &hdr, sizeof hdr / 2)); |
|
|
/* send UNSET request */ |
/* send UNSET request */ |
if (send(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { | if (send(cli->cli_sock, &hdr, sizeof hdr, MSG_NOSIGNAL) == -1) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
} |
} |
Line 488 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 481 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
/* wait for reply */ |
/* wait for reply */ |
pfd.fd = cli->cli_sock; |
pfd.fd = cli->cli_sock; |
pfd.events = POLLIN | POLLPRI; |
pfd.events = POLLIN | POLLPRI; |
if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || | if ((ret = poll(&pfd, 1, DEF_RPC_TIMEOUT * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
if (ret) |
if (ret) |
LOGERR; |
LOGERR; |