Diff for /libaitrpc/src/srv.c between versions 1.1.1.1.2.16 and 1.1.1.1.2.20

version 1.1.1.1.2.16, 2010/07/08 07:16:36 version 1.1.1.1.2.20, 2010/07/08 12:29:38
Line 97  rpc_srv_dispatchCall(void *arg) Line 97  rpc_srv_dispatchCall(void *arg)
                         else                          else
                                 argc = rpc_srv_getValsCall(f, &vals);                                  argc = rpc_srv_getValsCall(f, &vals);
   
                 printf("finish func %d\n", argc);  
 makeReply:  makeReply:
                 memcpy(&rrpc.ret_session, &rpc->call_session, sizeof rrpc.ret_session);                  memcpy(&rrpc.ret_session, &rpc->call_session, sizeof rrpc.ret_session);
                 rrpc.ret_tag = rpc->call_tag;                  rrpc.ret_tag = rpc->call_tag;
Line 180  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 191  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 204  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 223  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 237  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 266  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 283  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 417  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 631  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);

Removed from v.1.1.1.1.2.16  
changed lines
  Added in v.1.1.1.1.2.20


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