version 1.1.1.1.2.15, 2010/07/07 15:18:22
|
version 1.1.1.1.2.21, 2010/07/08 13:05:50
|
Line 93 rpc_srv_dispatchCall(void *arg)
|
Line 93 rpc_srv_dispatchCall(void *arg)
|
ret = -6; |
ret = -6; |
} else |
} else |
if ((ret = rpc_srv_execCall(f, rpc, v)) == -1) |
if ((ret = rpc_srv_execCall(f, rpc, v)) == -1) |
ret = -6; | ret = -9; |
else |
else |
argc = rpc_srv_getValsCall(f, &vals); |
argc = rpc_srv_getValsCall(f, &vals); |
|
|
Line 179 rpc_srv_dispatchVars(void *arg)
|
Line 179 rpc_srv_dispatchVars(void *arg)
|
rpc_cli_t *c = arg; |
rpc_cli_t *c = arg; |
rpc_srv_t *s; |
rpc_srv_t *s; |
rpc_blob_t *b; |
rpc_blob_t *b; |
int cx, ret; | int ret; |
fd_set fds; |
fd_set fds; |
u_char buf[sizeof(struct tagBLOBHdr)]; |
u_char buf[sizeof(struct tagBLOBHdr)]; |
struct tagBLOBHdr *blob; |
struct tagBLOBHdr *blob; |
Line 190 rpc_srv_dispatchVars(void *arg)
|
Line 190 rpc_srv_dispatchVars(void *arg)
|
} else |
} else |
s = c->cli_parent; |
s = c->cli_parent; |
|
|
cx = -1; |
|
do { |
do { |
// check for disable service at this moment? |
// check for disable service at this moment? |
if (s->srv_blob.state == disable) { |
if (s->srv_blob.state == disable) { |
Line 203 rpc_srv_dispatchVars(void *arg)
|
Line 202 rpc_srv_dispatchVars(void *arg)
|
ret = select(c->cli_sock + 1, &fds, NULL, NULL, NULL); |
ret = select(c->cli_sock + 1, &fds, NULL, NULL, NULL); |
if (ret == -1) { |
if (ret == -1) { |
ret = -2; |
ret = -2; |
} else | } |
cx++; | |
memset(buf, 0, sizeof buf); |
memset(buf, 0, sizeof buf); |
if ((ret = recv(c->cli_sock, buf, sizeof buf, 0)) == -1) { |
if ((ret = recv(c->cli_sock, buf, sizeof buf, 0)) == -1) { |
LOGERR; |
LOGERR; |
Line 222 rpc_srv_dispatchVars(void *arg)
|
Line 221 rpc_srv_dispatchVars(void *arg)
|
} else |
} else |
blob = (struct tagBLOBHdr*) buf; |
blob = (struct tagBLOBHdr*) buf; |
// check BLOB packet session info |
// check BLOB packet session info |
if (memcmp(&blob->hdr_session, &s->srv_session, sizeof blob->hdr_session) || | if (memcmp(&blob->hdr_session, &s->srv_session, sizeof blob->hdr_session)) { |
blob->hdr_seq != cx) { | rpc_SetErr(EINVAL, "Error:: get invalid BLOB session ...\n"); |
rpc_SetErr(EINVAL, "Error:: get invalid BLOB session in seq=%d...\n", blob->hdr_seq); | |
ret = -5; |
ret = -5; |
goto makeReply; |
goto makeReply; |
} |
} |
Line 236 rpc_srv_dispatchVars(void *arg)
|
Line 234 rpc_srv_dispatchVars(void *arg)
|
blob->hdr_var); |
blob->hdr_var); |
ret = -6; |
ret = -6; |
break; |
break; |
} | } else |
printf("++++++ %p\n", b); | blob->hdr_len = b->blob_len; |
|
|
if (rpc_srv_blobMap(s, b) != -1) { |
if (rpc_srv_blobMap(s, b) != -1) { |
ret = rpc_srv_sendBLOB(c, b); |
ret = rpc_srv_sendBLOB(c, b); |
Line 265 rpc_srv_dispatchVars(void *arg)
|
Line 263 rpc_srv_dispatchVars(void *arg)
|
blob->hdr_cmd); |
blob->hdr_cmd); |
ret = -7; |
ret = -7; |
} |
} |
cx++; |
|
|
|
makeReply: |
makeReply: |
// Replay to client! |
// Replay to client! |
blob->hdr_cmd = ret < 0 ? error : ok; |
blob->hdr_cmd = ret < 0 ? error : ok; |
blob->hdr_seq = ret; | blob->hdr_ret = ret; |
if ((ret = send(c->cli_sock, buf, sizeof buf, 0)) == -1) { |
if ((ret = send(c->cli_sock, buf, sizeof buf, 0)) == -1) { |
LOGERR; |
LOGERR; |
ret = -8; |
ret = -8; |
Line 282 makeReply:
|
Line 279 makeReply:
|
ret = -9; |
ret = -9; |
break; |
break; |
} |
} |
cx = -1; |
|
|
|
} while (ret > -1); |
} while (ret > -1); |
|
|
shutdown(c->cli_sock, SHUT_RDWR); |
shutdown(c->cli_sock, SHUT_RDWR); |
Line 416 rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv)
|
Line 411 rpc_srv_endBLOBServer(rpc_srv_t * __restrict srv)
|
} |
} |
pthread_mutex_unlock(&srv->srv_blob.mtx); |
pthread_mutex_unlock(&srv->srv_blob.mtx); |
|
|
|
while (pthread_mutex_trylock(&srv->srv_blob.mtx) == EBUSY); |
pthread_mutex_destroy(&srv->srv_blob.mtx); |
pthread_mutex_destroy(&srv->srv_blob.mtx); |
} |
} |
|
|
Line 584 rpc_srv_initServer(u_int regProgID, u_int regProcID, i
|
Line 580 rpc_srv_initServer(u_int regProgID, u_int regProcID, i
|
} else |
} else |
memset(srv->srv_clients, 0, srv->srv_numcli * sizeof(rpc_cli_t)); |
memset(srv->srv_clients, 0, srv->srv_numcli * sizeof(rpc_cli_t)); |
|
|
|
pthread_mutex_init(&srv->srv_mtx, NULL); |
|
|
rpc_srv_registerCall(srv, NULL, CALL_SRVSHUTDOWN, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVSHUTDOWN, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVCLIENTS, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVCLIENTS, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVCALLS, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVCALLS, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVSESSIONS, 0); |
rpc_srv_registerCall(srv, NULL, CALL_SRVSESSIONS, 0); |
|
|
pthread_mutex_init(&srv->srv_mtx, NULL); |
|
return srv; |
return srv; |
} |
} |
|
|
Line 630 rpc_srv_endServer(rpc_srv_t * __restrict srv)
|
Line 626 rpc_srv_endServer(rpc_srv_t * __restrict srv)
|
} |
} |
pthread_mutex_unlock(&srv->srv_mtx); |
pthread_mutex_unlock(&srv->srv_mtx); |
|
|
|
while (pthread_mutex_trylock(&srv->srv_mtx) == EBUSY); |
pthread_mutex_destroy(&srv->srv_mtx); |
pthread_mutex_destroy(&srv->srv_mtx); |
|
|
free(srv); |
free(srv); |