version 1.6.2.1, 2012/05/11 09:18:13
|
version 1.6.2.2, 2012/05/11 12:53:35
|
Line 257 rpc_srv_recvBLOB(rpc_cli_t * __restrict cli, rpc_blob_
|
Line 257 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, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
LOGERR; |
LOGERR; |
return -1; |
return -1; |
Line 289 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 289 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
int ret, len; |
int ret, len; |
uint8_t *pos; |
uint8_t *pos; |
struct tagBLOBHdr hdr; |
struct tagBLOBHdr hdr; |
fd_set fds; | struct pollfd pfd; |
struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; | |
|
|
if (!cli || !var || !data) { |
if (!cli || !var || !data) { |
rpc_SetErr(EINVAL, "Invalid arguments"); |
rpc_SetErr(EINVAL, "Invalid arguments"); |
return -1; |
return -1; |
} else | } |
tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout; | |
|
|
rpc_addPktSession(&hdr.hdr_session, cli->cli_parent); |
rpc_addPktSession(&hdr.hdr_session, cli->cli_parent); |
hdr.hdr_cmd = set; |
hdr.hdr_cmd = set; |
Line 321 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 319 rpc_cli_sendBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
} |
} |
|
|
/* wait for reply */ |
/* wait for reply */ |
FD_ZERO(&fds); | pfd.fd = cli->cli_sock; |
FD_SET(cli->cli_sock, &fds); | pfd.events = POLLIN | POLLPRI; |
switch (select(cli->cli_sock + 1, &fds, NULL, NULL, &tv)) { | if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || |
case -1: | pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
| if (ret) |
LOGERR; |
LOGERR; |
return 1; | else |
case 0: | |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
return 1; | return -1; |
} |
} |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
LOGERR; |
LOGERR; |
Line 368 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 366 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
{ |
{ |
int ret, len; |
int ret, len; |
uint8_t *pos; |
uint8_t *pos; |
fd_set fds; | struct pollfd pfd; |
struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; | |
struct tagBLOBHdr hdr; |
struct tagBLOBHdr hdr; |
|
|
if (!cli || !var || !data) { |
if (!cli || !var || !data) { |
rpc_SetErr(EINVAL, "Invalid arguments"); |
rpc_SetErr(EINVAL, "Invalid arguments"); |
return -1; |
return -1; |
} else | } |
tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout; | |
|
|
*data = malloc(AIT_LEN(var)); |
*data = malloc(AIT_LEN(var)); |
if (!*data) { |
if (!*data) { |
Line 403 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 399 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
} |
} |
|
|
/* receive BLOB from server */ |
/* receive BLOB from server */ |
|
pfd.fd = cli->cli_sock; |
|
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) { |
FD_ZERO(&fds); | if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || |
FD_SET(cli->cli_sock, &fds); | pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
len = select(cli->cli_sock + 1, &fds, NULL, NULL, &tv); | |
if (len < 1) { | |
LOGERR; |
LOGERR; |
free(*data); |
free(*data); |
*data = NULL; |
*data = NULL; |
Line 423 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 419 rpc_cli_recvBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
} |
} |
|
|
/* wait for reply */ |
/* wait for reply */ |
FD_ZERO(&fds); | if ((len = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || |
FD_SET(cli->cli_sock, &fds); | pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
switch (select(cli->cli_sock + 1, &fds, NULL, NULL, &tv)) { | if (len) |
case -1: | |
LOGERR; |
LOGERR; |
free(*data); | else |
*data = NULL; | |
return 1; | |
case 0: | |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
free(*data); | free(*data); |
*data = NULL; | *data = NULL; |
return 1; | return 1; |
} |
} |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
LOGERR; |
LOGERR; |
Line 475 int
|
Line 467 int
|
rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t * __restrict var) |
rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t * __restrict var) |
{ |
{ |
struct tagBLOBHdr hdr; |
struct tagBLOBHdr hdr; |
fd_set fds; | struct pollfd pfd; |
struct timeval tv = { DEF_RPC_TIMEOUT, 0 }; | |
int ret; |
int ret; |
|
|
if (!cli || !var) { |
if (!cli || !var) { |
rpc_SetErr(EINVAL, "Invalid arguments"); |
rpc_SetErr(EINVAL, "Invalid arguments"); |
return -1; |
return -1; |
} else | } |
tv.tv_sec = ((rpc_sess_t*) cli->cli_parent)->sess_timeout; | |
|
|
rpc_addPktSession(&hdr.hdr_session, cli->cli_parent); |
rpc_addPktSession(&hdr.hdr_session, cli->cli_parent); |
hdr.hdr_cmd = unset; |
hdr.hdr_cmd = unset; |
Line 501 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
Line 491 rpc_cli_delBLOB(rpc_cli_t * __restrict cli, ait_val_t
|
} |
} |
|
|
/* wait for reply */ |
/* wait for reply */ |
FD_ZERO(&fds); | pfd.fd = cli->cli_sock; |
FD_SET(cli->cli_sock, &fds); | pfd.events = POLLIN | POLLPRI; |
switch (select(cli->cli_sock + 1, &fds, NULL, NULL, &tv)) { | if ((ret = poll(&pfd, 1, ((rpc_sess_t*) cli->cli_parent)->sess_timeout * 1000)) < 1 || |
case -1: | pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) { |
| if (ret) |
LOGERR; |
LOGERR; |
return 1; | else |
case 0: | |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
rpc_SetErr(ETIMEDOUT, "Timeout reached! Server not responde"); |
return 1; | return 1; |
} |
} |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
if (recv(cli->cli_sock, &hdr, sizeof hdr, 0) == -1) { |
LOGERR; |
LOGERR; |