Diff for /libaitrpc/src/srv.c between versions 1.1.1.1.2.5 and 1.1.1.1.2.8

version 1.1.1.1.2.5, 2010/06/23 15:07:15 version 1.1.1.1.2.8, 2010/06/23 17:29:07
Line 185  rpc_srv_dispatchVars(void *arg) Line 185  rpc_srv_dispatchVars(void *arg)
         rpc_blob_t *b;          rpc_blob_t *b;
         int cx, ret;          int cx, ret;
         fd_set fds;          fd_set fds;
        u_char buf[BLOBSIZ];        u_char buf[sizeof(struct tagBLOBHdr)];
         struct tagBLOBHdr *blob;          struct tagBLOBHdr *blob;
   
         if (!arg) {          if (!arg) {
Line 196  rpc_srv_dispatchVars(void *arg) Line 196  rpc_srv_dispatchVars(void *arg)
   
         cx = -1;          cx = -1;
         do {          do {
                 cx++;  
   
                 FD_ZERO(&fds);                  FD_ZERO(&fds);
                 FD_SET(c->cli_sock, &fds);                  FD_SET(c->cli_sock, &fds);
                 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
                memset(buf, 0, BLOBSIZ);                        cx++;
                if ((ret = recv(c->cli_sock, buf, BLOBSIZ, 0)) == -1) {                memset(buf, 0, sizeof buf);
                 if ((ret = recv(c->cli_sock, buf, sizeof buf, 0)) == -1) {
                         LOGERR;                          LOGERR;
                         ret = -3;                          ret = -3;
                         break;                          break;
Line 227  rpc_srv_dispatchVars(void *arg) Line 226  rpc_srv_dispatchVars(void *arg)
                         ret = -5;                          ret = -5;
                         break;                          break;
                 }                  }
                // Go to decapsulate packet ...                // get requested BLOB object
                if (!(b = rpc_srv_getBLOB(s, blob->hdr_var))) {                if (!(b = rpc_srv_getBLOB(s, blob->hdr_var)))
                        rpc_SetErr(EINVAL, "Error:: var (%x) not found into BLOB server ...\n", blob->hdr_var);                        if (blob->hdr_cmd != set) {
                        ret = -6;                                rpc_SetErr(EINVAL, "Error:: var (%x) not found into BLOB server ...\n", blob->hdr_var);
                        break;                                ret = -6;
                }                                break;
                         }
                 // Go to proceed packet ...
                 switch (blob->hdr_cmd) {                  switch (blob->hdr_cmd) {
                         case get:                          case get:
                                ret = rpc_srv_sendBLOB(c, b);                                if (rpc_srv_blobMap(s, b) != -1) {
                                         ret = rpc_srv_sendBLOB(c, b);
                                         rpc_srv_blobUnmap(b);
                                 } else
                                         ret = -7;
                                 break;                                  break;
                         case set:                          case set:
                                ret = rpc_srv_recvBLOB(c, b);                                if (b) {
                                         rpc_SetErr(EINVAL, "Error:: Cannot set var into BLOB server, already exists ...\n");
                                         ret = -6;
                                         break;
                                 }
 
                                 ret = rpc_srv_recvBLOB(c);
                                 if (ret == -1)
                                         ret = -7;
                                 break;                                  break;
                         case unset:                          case unset:
                                ret = rpc_srv_freeBLOB(b);                                ret = rpc_srv_blobFree(s, b);
                                 if (ret == -1)
                                         ret = -7;
                                 break;                                  break;
                         default:                          default:
                                 rpc_SetErr(EINVAL, "Error:: unsupported BLOB command (%d)...\n",                                   rpc_SetErr(EINVAL, "Error:: unsupported BLOB command (%d)...\n", 
                                                 blob->hdr_cmd);                                                  blob->hdr_cmd);
                                ret -7;                                ret = -7;
                 }
 
                 // Replay to client!
                 blob->hdr_cmd = ret < 0 ? error : ok;
                 blob->hdr_seq = ret;
                 if ((ret = send(c->cli_sock, buf, sizeof buf, 0)) == -1) {
                         LOGERR;
                         ret = -8;
                         break;
                 }
                 if (ret != sizeof buf) {
                         rpc_SetErr(EBADMSG, "Error:: in send BLOB reply, should be send %d bytes, "
                                         "really is %d\n", sizeof buf, ret);
                         ret = -9;
                         break;
                 }                  }
         } while (ret > -1);          } while (ret > -1);
   

Removed from v.1.1.1.1.2.5  
changed lines
  Added in v.1.1.1.1.2.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>