--- libaitrpc/src/srv.c 2011/08/19 14:24:54 1.3.2.10 +++ libaitrpc/src/srv.c 2011/08/19 14:39:23 1.3.2.11 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: srv.c,v 1.3.2.10 2011/08/19 14:24:54 misho Exp $ +* $Id: srv.c,v 1.3.2.11 2011/08/19 14:39:23 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -87,7 +87,7 @@ rpc_srv_dispatchCall(void *arg) ret = -3; break; } - if (!ret) { // receive EOF + if (!ret) { /* receive EOF */ ret = 0; break; } @@ -97,30 +97,30 @@ rpc_srv_dispatchCall(void *arg) break; } else rpc = (struct tagRPCCall*) buf; - // check RPC packet session info + /* check RPC packet session info */ if (memcmp(&rpc->call_session, &s->srv_session, sizeof rpc->call_session)) { rpc_SetErr(EINVAL, "Error:: get invalid RPC session ...\n"); ret = -5; goto makeReply; } else Limit = sizeof(struct tagRPCCall); - // RPC is OK! Go decapsulate variables ... + /* RPC is OK! Go decapsulate variables ... */ if (rpc->call_argc) { v = (rpc_val_t*) (buf + Limit); - // check RPC packet length + /* check RPC packet length */ if (rpc->call_argc * sizeof(rpc_val_t) > sizeof buf - Limit) { - rpc_SetErr(EMSGSIZE, "Error:: Too big RPC packet ...\n"); + rpc_SetErr(EMSGSIZE, "Error:: too long RPC packet ...\n"); ret = -5; goto makeReply; } else Limit += rpc->call_argc * sizeof(rpc_val_t); - // RPC received variables types OK! + /* RPC received variables types OK! */ data = (u_char*) v + rpc->call_argc * sizeof(rpc_val_t); for (i = 0; i < rpc->call_argc; i++) { switch (v[i].val_type) { case buffer: if (v[i].val_len > sizeof buf - Limit) { - rpc_SetErr(EMSGSIZE, "Error:: Too big RPC packet ...\n"); + rpc_SetErr(EMSGSIZE, "Error:: too long RPC packet ...\n"); ret = -5; goto makeReply; } else @@ -131,7 +131,7 @@ rpc_srv_dispatchCall(void *arg) break; case string: if (v[i].val_len > sizeof buf - Limit) { - rpc_SetErr(EMSGSIZE, "Error:: Too big RPC packet ...\n"); + rpc_SetErr(EMSGSIZE, "Error:: too long RPC packet ...\n"); ret = -5; goto makeReply; } else @@ -147,7 +147,7 @@ rpc_srv_dispatchCall(void *arg) goto makeReply; } if (s->srv_blob.state == kill) { - rpc_SetErr(ENOTSUP, "Error:: BLOB server is killed\n"); + rpc_SetErr(ENOTSUP, "Error:: BLOB server is gone.\n"); ret = -5; goto makeReply; } @@ -157,6 +157,7 @@ rpc_srv_dispatchCall(void *arg) } } + /* execute call */ argc = 0; vals = NULL; memcpy(&ses, &rpc->call_session, sizeof ses); @@ -169,6 +170,7 @@ rpc_srv_dispatchCall(void *arg) else argc = rpc_srv_getVars(f, &vals); makeReply: + /* made reply */ memset(buf, 0, sizeof buf); rrpc = (struct tagRPCRet*) buf; Limit = sizeof(struct tagRPCRet); @@ -229,7 +231,7 @@ makeReply: break; } if (s->srv_blob.state == kill) { - rpc_SetErr(ENOTSUP, "Error:: BLOB server is killed\n"); + rpc_SetErr(ENOTSUP, "Error:: BLOB server is gone.\n"); rrpc->ret_retcode = ret = -5; rrpc->ret_argc = 0; break; @@ -284,7 +286,7 @@ rpc_srv_dispatchVars(void *arg) s = c->cli_parent; do { - // check for disable service at this moment? + /* check for disable service at this moment? */ if (s->srv_blob.state == disable && s->srv_kill != kill) { usleep(100000); pthread_yield(); @@ -321,13 +323,13 @@ rpc_srv_dispatchVars(void *arg) break; } else 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)) { rpc_SetErr(EINVAL, "Error:: get invalid BLOB session ...\n"); ret = -5; goto makeReply; } - // Go to proceed packet ... + /* Go to proceed packet ... */ switch (blob->hdr_cmd) { case get: if (!(b = rpc_srv_getBLOB(s, blob->hdr_var))) { @@ -346,7 +348,7 @@ rpc_srv_dispatchVars(void *arg) break; case set: if ((b = rpc_srv_registerBLOB(s, blob->hdr_len))) { - // set new BLOB variable for reply :) + /* set new BLOB variable for reply :) */ blob->hdr_var = b->blob_var; ret = rpc_srv_recvBLOB(c, b); @@ -366,7 +368,7 @@ rpc_srv_dispatchVars(void *arg) } makeReply: - // Replay to client! + /* Replay to client! */ blob->hdr_cmd = ret < 0 ? error : ok; blob->hdr_ret = ret; ret = send(c->cli_sock, buf, sizeof buf, 0);