version 1.25, 2015/05/18 15:09:59
|
version 1.25.2.4, 2015/06/29 22:29:25
|
Line 158 rpc_cli_closeBLOBClient(rpc_cli_t ** __restrict cli)
|
Line 158 rpc_cli_closeBLOBClient(rpc_cli_t ** __restrict cli)
|
rpc_cli_t * |
rpc_cli_t * |
rpc_cli_openClient(u_char InstID, int netBuf, const char *csHost, u_short Port, int proto) |
rpc_cli_openClient(u_char InstID, int netBuf, const char *csHost, u_short Port, int proto) |
{ |
{ |
|
int n = 1; |
rpc_cli_t *cli = NULL; |
rpc_cli_t *cli = NULL; |
sockaddr_t sa = E_SOCKADDR_INIT; |
sockaddr_t sa = E_SOCKADDR_INIT; |
|
|
Line 218 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
Line 219 rpc_cli_openClient(u_char InstID, int netBuf, const ch
|
LOGERR; |
LOGERR; |
goto err; |
goto err; |
} |
} |
if (cli->cli_id == SOCK_STREAM) | if (cli->cli_id == SOCK_STREAM) { |
| setsockopt(cli->cli_sock, IPPROTO_TCP, TCP_NODELAY, &n, sizeof n); |
if (connect(cli->cli_sock, &cli->cli_sa.sa, cli->cli_sa.sa.sa_len) == -1) { |
if (connect(cli->cli_sock, &cli->cli_sa.sa, cli->cli_sa.sa.sa_len) == -1) { |
LOGERR; |
LOGERR; |
goto err; |
goto err; |
} |
} |
|
} |
|
if (cli->cli_id == SOCK_DGRAM) { |
|
sockaddr_t sa2; |
|
|
|
if (!e_gethostbyname(csHost, 0, &sa2)) |
|
goto err; |
|
if (bind(cli->cli_sock, &sa2.sa, sa2.sa.sa_len) == -1) { |
|
LOGERR; |
|
goto err; |
|
} |
|
} |
|
|
fcntl(cli->cli_sock, F_SETFL, fcntl(cli->cli_sock, F_GETFL) | O_NONBLOCK); |
fcntl(cli->cli_sock, F_SETFL, fcntl(cli->cli_sock, F_GETFL) | O_NONBLOCK); |
return cli; |
return cli; |
err: |
err: |
Line 251 rpc_cli_reconnectClient(rpc_cli_t * __restrict cli)
|
Line 264 rpc_cli_reconnectClient(rpc_cli_t * __restrict cli)
|
else |
else |
netBuf = AIT_LEN(&cli->cli_buf); |
netBuf = AIT_LEN(&cli->cli_buf); |
|
|
|
if (cli->cli_id == SOCK_STREAM) |
|
shutdown(cli->cli_sock, SHUT_RDWR); |
|
if (cli->cli_id == SOCK_DGRAM && cli->cli_sa.sa.sa_family == AF_LOCAL) { |
|
sockaddr_t sa2 = E_SOCKADDR_INIT; |
|
socklen_t salen; |
|
|
|
sa2.sa.sa_len = salen = sizeof sa2; |
|
if (!getsockname(cli->cli_sock, &sa2.sa, &salen)) |
|
unlink(sa2.sun.sun_path); |
|
} |
close(cli->cli_sock); |
close(cli->cli_sock); |
|
|
srandom(time(NULL) ^ getpid()); |
srandom(time(NULL) ^ getpid()); |
Line 297 rpc_cli_closeClient(rpc_cli_t ** __restrict cli)
|
Line 320 rpc_cli_closeClient(rpc_cli_t ** __restrict cli)
|
|
|
if ((*cli)->cli_id == SOCK_STREAM) |
if ((*cli)->cli_id == SOCK_STREAM) |
shutdown((*cli)->cli_sock, SHUT_RDWR); |
shutdown((*cli)->cli_sock, SHUT_RDWR); |
|
if ((*cli)->cli_id == SOCK_DGRAM && (*cli)->cli_sa.sa.sa_family == AF_LOCAL) { |
|
sockaddr_t sa2 = E_SOCKADDR_INIT; |
|
socklen_t salen; |
|
|
|
sa2.sa.sa_len = salen = sizeof sa2; |
|
if (!getsockname((*cli)->cli_sock, &sa2.sa, &salen)) |
|
unlink(sa2.sun.sun_path); |
|
} |
close((*cli)->cli_sock); |
close((*cli)->cli_sock); |
|
|
AIT_FREE_VAL(&(*cli)->cli_buf); |
AIT_FREE_VAL(&(*cli)->cli_buf); |
Line 359 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
Line 390 rpc_pkt_Receive(int sock, int type, sockaddr_t * __res
|
|
|
if (ret > 0) { |
if (ret > 0) { |
rpc = (struct tagRPCCall*) AIT_GET_BUF(pkt); |
rpc = (struct tagRPCCall*) AIT_GET_BUF(pkt); |
|
if (ret < ntohl(rpc->call_len)) |
|
continue; |
|
|
/* check for loop request */ |
/* check for loop request */ |
if (!(rpc->call_io & RPC_ACK)) |
if (!(rpc->call_io & RPC_ACK)) |
Line 399 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
Line 432 rpc_pkt_Request(ait_val_t * __restrict pkt, rpc_sess_t
|
|
|
/* calc estimated length */ |
/* calc estimated length */ |
estlen = ait_resideVars(vars) + len; |
estlen = ait_resideVars(vars) + len; |
if (estlen > AIT_LEN(pkt)) | if (estlen > AIT_LEN(pkt)) { |
AIT_RE_BUF(pkt, estlen); | rpc_SetErr(EMSGSIZE, "Message too long"); |
| return -1; |
| } |
buf = AIT_GET_BUF(pkt); |
buf = AIT_GET_BUF(pkt); |
|
|
/* prepare RPC call */ |
/* prepare RPC call */ |
Line 551 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
Line 586 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
if (out_vars) |
if (out_vars) |
*out_vars = NULL; |
*out_vars = NULL; |
|
|
if ((wlen = rpc_pkt_Request(&cli->cli_buf, cli->cli_parent, tag, in_vars, noreply, type, seq)) == -1) | if ((wlen = rpc_pkt_Request(&cli->cli_buf, cli->cli_parent, tag, |
| in_vars, noreply, type, seq)) == -1) |
return -1; |
return -1; |
|
|
if ((wlen = rpc_pkt_Send(cli->cli_sock, cli->cli_id, &cli->cli_sa, &cli->cli_buf, wlen)) == -1) | if ((wlen = rpc_pkt_Send(cli->cli_sock, cli->cli_id, &cli->cli_sa, |
| &cli->cli_buf, wlen)) == -1) |
return -1; |
return -1; |
if (!wlen) /* closed rpc connection */ |
if (!wlen) /* closed rpc connection */ |
return 1; |
return 1; |
Line 562 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
Line 599 rpc_cli_execCall(rpc_cli_t *cli, int noreply, u_short
|
if (noreply) /* we not want reply */ |
if (noreply) /* we not want reply */ |
return 0; |
return 0; |
|
|
if ((wlen = rpc_pkt_Receive(cli->cli_sock, cli->cli_id, &cli->cli_sa, &cli->cli_buf, seq)) == -1) | if ((wlen = rpc_pkt_Receive(cli->cli_sock, cli->cli_id, &cli->cli_sa, |
| &cli->cli_buf, seq)) == -1) |
return -1; |
return -1; |
if (!wlen) /* closed rpc connection */ |
if (!wlen) /* closed rpc connection */ |
return 1; |
return 1; |
|
|
if ((wlen = rpc_pkt_Replay(&cli->cli_buf, cli->cli_parent, tag, out_vars, type)) == -1) | if ((wlen = rpc_pkt_Replay(&cli->cli_buf, cli->cli_parent, tag, |
| out_vars, type)) == -1) |
return -1; |
return -1; |
|
|
return 0; |
return 0; |