version 1.30.2.7, 2024/02/26 16:56:22
|
version 1.30.2.12, 2024/03/20 17:06:11
|
Line 87 rpc_freeCli(rpc_cli_t * __restrict c)
|
Line 87 rpc_freeCli(rpc_cli_t * __restrict c)
|
{ |
{ |
rpc_srv_t *s = c->cli_parent; |
rpc_srv_t *s = c->cli_parent; |
|
|
schedCancelby(s->srv_root, taskMAX, CRITERIA_ARG, c, NULL); | if (s->srv_proto == SOCK_STREAM) |
| schedCancelby(s->srv_root, taskMAX, CRITERIA_ARG, c, NULL); |
|
|
/* free buffer */ |
/* free buffer */ |
AIT_FREE_VAL(&c->cli_buf); |
AIT_FREE_VAL(&c->cli_buf); |
Line 146 _allocClient(rpc_srv_t * __restrict srv, sockaddr_t *
|
Line 147 _allocClient(rpc_srv_t * __restrict srv, sockaddr_t *
|
|
|
/* alloc empty buffer */ |
/* alloc empty buffer */ |
AIT_SET_BUFSIZ(&c->cli_buf, 0, srv->srv_netbuf); |
AIT_SET_BUFSIZ(&c->cli_buf, 0, srv->srv_netbuf); |
|
if (!AIT_GET_BUF(&c->cli_buf)) { |
|
array_Del(srv->srv_clients, n, 0); |
|
e_free(c); |
|
c = NULL; |
|
} |
} |
} |
|
|
return c; |
return c; |
Line 302 execCall(sched_task_t *task)
|
Line 308 execCall(sched_task_t *task)
|
taskExit(task, NULL); |
taskExit(task, NULL); |
} |
} |
|
|
int |
|
rpc_srv_Return(sched_root_task_t *root, rpc_cli_t *c) |
|
{ |
|
rpc_srv_t *s = c->cli_parent; |
|
u_char *buf = AIT_GET_BUF(&c->cli_buf); |
|
struct tagRPCCall *rpc = (struct tagRPCCall*) buf; |
|
|
|
if (!RPC_CHK_NOREPLY(rpc)) { |
|
rpc->call_argc = (u_char) array_Size(RPC_RETVARS(c)); |
|
schedWrite(root, cbProto[s->srv_proto][CB_TXPACKET], c, c->cli_sock, NULL, 0); |
|
} |
|
|
|
return rpc->call_argc; |
|
} |
|
|
|
static void * |
static void * |
rxPacket(sched_task_t *task) |
rxPacket(sched_task_t *task) |
{ |
{ |
rpc_cli_t *c = TASK_ARG(task); |
rpc_cli_t *c = TASK_ARG(task); |
rpc_srv_t *s = c->cli_parent; |
rpc_srv_t *s = c->cli_parent; |
int len, noreply = 0, rlen = AIT_LEN(&c->cli_buf); | int len, noreply = 0, rlen; |
#if 0 |
#if 0 |
u_short crc; |
u_short crc; |
#endif |
#endif |
Line 575 rxUDPPacket(sched_task_t *task)
|
Line 566 rxUDPPacket(sched_task_t *task)
|
|
|
c = _allocClient(srv, &sa); |
c = _allocClient(srv, &sa); |
if (!c) { |
if (!c) { |
EVERBOSE(1, "RPC client quota exceeded! Connection will be shutdown!\n"); | EVERBOSE(1, "RPC client quota exceeded!"); |
usleep(2000); /* blocked client delay */ |
usleep(2000); /* blocked client delay */ |
goto end; |
goto end; |
} else { |
} else { |
Line 1012 rxEXTPacket(sched_task_t *task)
|
Line 1003 rxEXTPacket(sched_task_t *task)
|
{ |
{ |
rpc_srv_t *srv = TASK_ARG(task); |
rpc_srv_t *srv = TASK_ARG(task); |
rpc_cli_t *c = NULL; |
rpc_cli_t *c = NULL; |
int len, noreply = 0, rlen = AIT_LEN(&c->cli_buf); | int len, noreply = 0, rlen; |
struct tagRPCCall *rpc; |
struct tagRPCCall *rpc; |
struct timespec ts = { DEF_RPC_TIMEOUT, 0 }; |
struct timespec ts = { DEF_RPC_TIMEOUT, 0 }; |
sockaddr_t sa; |
sockaddr_t sa; |
Line 1580 rpc_srv_initServer(u_char InstID, int concurentClients
|
Line 1571 rpc_srv_initServer(u_char InstID, int concurentClients
|
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
e_free(srv); |
e_free(srv); |
return NULL; |
return NULL; |
} else | } |
schedSignalDispatch(srv->srv_root, 42); | |
|
|
/* init pool for clients */ |
/* init pool for clients */ |
srv->srv_clients = array_Init(concurentClients); |
srv->srv_clients = array_Init(concurentClients); |
Line 1703 rpc_srv_loopServer(rpc_srv_t * __restrict srv)
|
Line 1693 rpc_srv_loopServer(rpc_srv_t * __restrict srv)
|
schedPolling(srv->srv_root, &ts, NULL); |
schedPolling(srv->srv_root, &ts, NULL); |
/* main rpc loop */ |
/* main rpc loop */ |
schedRun(srv->srv_root, &srv->srv_kill); |
schedRun(srv->srv_root, &srv->srv_kill); |
schedSignalDispatch(srv->srv_root, 0); |
|
|
|
/* close all clients connections & server socket */ |
/* close all clients connections & server socket */ |
for (i = 0; i < array_Size(srv->srv_clients); i++) { |
for (i = 0; i < array_Size(srv->srv_clients); i++) { |
Line 1842 rpc_srv_initServer2(u_char InstID, int concurentClient
|
Line 1831 rpc_srv_initServer2(u_char InstID, int concurentClient
|
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
e_free(srv); |
e_free(srv); |
return NULL; |
return NULL; |
} else | } |
schedSignalDispatch(srv->srv_root, 42); | |
|
|
/* init pool for clients */ |
/* init pool for clients */ |
srv->srv_clients = array_Init(concurentClients); |
srv->srv_clients = array_Init(concurentClients); |
Line 1961 rpc_srv_initServerExt(u_char InstID, int netBuf, int f
|
Line 1949 rpc_srv_initServerExt(u_char InstID, int netBuf, int f
|
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
pthread_mutex_destroy(&srv->srv_funcs.mtx); |
e_free(srv); |
e_free(srv); |
return NULL; |
return NULL; |
} else | } |
schedSignalDispatch(srv->srv_root, 42); | |
|
|
/* init pool for clients */ |
/* init pool for clients */ |
srv->srv_clients = array_Init(1); |
srv->srv_clients = array_Init(1); |
Line 1980 rpc_srv_initServerExt(u_char InstID, int netBuf, int f
|
Line 1967 rpc_srv_initServerExt(u_char InstID, int netBuf, int f
|
rpc_register_srvPing(srv); |
rpc_register_srvPing(srv); |
|
|
return srv; |
return srv; |
|
} |
|
|
|
/* |
|
* rpc_srv_Return() - Prepare IPC return answer to RPC client |
|
* |
|
* @c = RPC client |
|
* return: number of arguments in response |
|
*/ |
|
int |
|
rpc_srv_Return(rpc_cli_t *c) |
|
{ |
|
rpc_srv_t *s = c->cli_parent; |
|
u_char *buf = AIT_GET_BUF(&c->cli_buf); |
|
struct tagRPCCall *rpc = (struct tagRPCCall*) buf; |
|
|
|
if (!RPC_CHK_NOREPLY(rpc)) { |
|
rpc->call_argc = (u_char) array_Size(RPC_RETVARS(c)); |
|
schedWrite(s->srv_root, cbProto[s->srv_proto][CB_TXPACKET], c, c->cli_sock, rpc, 0); |
|
} else |
|
rpc->call_argc ^= rpc->call_argc; |
|
|
|
return rpc->call_argc; |
} |
} |