[BACK]Return to rumpclient.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / librumpclient

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/librumpclient/rumpclient.c between version 1.38 and 1.39

version 1.38, 2011/02/27 12:58:29 version 1.39, 2011/03/08 15:34:37
Line 66  int (*host_connect)(int, const struct so
Line 66  int (*host_connect)(int, const struct so
 int     (*host_fcntl)(int, int, ...);  int     (*host_fcntl)(int, int, ...);
 int     (*host_poll)(struct pollfd *, nfds_t, int);  int     (*host_poll)(struct pollfd *, nfds_t, int);
 ssize_t (*host_read)(int, void *, size_t);  ssize_t (*host_read)(int, void *, size_t);
 ssize_t (*host_sendto)(int, const void *, size_t, int,  ssize_t (*host_sendmsg)(int, const struct msghdr *, int);
                        const struct sockaddr *, socklen_t);  
 int     (*host_setsockopt)(int, int, int, const void *, socklen_t);  int     (*host_setsockopt)(int, int, int, const void *, socklen_t);
 int     (*host_dup)(int);  int     (*host_dup)(int);
   
Line 96  static int handshake_req(struct spclient
Line 95  static int handshake_req(struct spclient
 static time_t retrytimo = 0;  static time_t retrytimo = 0;
   
 static int  static int
 send_with_recon(struct spclient *spc, const void *data, size_t dlen)  send_with_recon(struct spclient *spc, struct iovec *iov, size_t iovlen)
 {  {
         struct timeval starttime, curtime;          struct timeval starttime, curtime;
         time_t prevreconmsg;          time_t prevreconmsg;
Line 104  send_with_recon(struct spclient *spc, co
Line 103  send_with_recon(struct spclient *spc, co
         int rv;          int rv;
   
         for (prevreconmsg = 0, reconretries = 0;;) {          for (prevreconmsg = 0, reconretries = 0;;) {
                 rv = dosend(spc, data, dlen);                  rv = dosend(spc, iov, iovlen);
                 if (__predict_false(rv == ENOTCONN || rv == EBADF)) {                  if (__predict_false(rv == ENOTCONN || rv == EBADF)) {
                         /* no persistent connections */                          /* no persistent connections */
                         if (retrytimo == 0) {                          if (retrytimo == 0) {
Line 287  syscall_req(struct spclient *spc, sigset
Line 286  syscall_req(struct spclient *spc, sigset
 {  {
         struct rsp_hdr rhdr;          struct rsp_hdr rhdr;
         struct respwait rw;          struct respwait rw;
           struct iovec iov[2];
         int rv;          int rv;
   
         rhdr.rsp_len = sizeof(rhdr) + dlen;          rhdr.rsp_len = sizeof(rhdr) + dlen;
Line 294  syscall_req(struct spclient *spc, sigset
Line 294  syscall_req(struct spclient *spc, sigset
         rhdr.rsp_type = RUMPSP_SYSCALL;          rhdr.rsp_type = RUMPSP_SYSCALL;
         rhdr.rsp_sysnum = sysnum;          rhdr.rsp_sysnum = sysnum;
   
           IOVPUT(iov[0], rhdr);
           IOVPUT_WITHSIZE(iov[1], __UNCONST(data), dlen);
   
         do {          do {
                 putwait(spc, &rw, &rhdr);                  putwait(spc, &rw, &rhdr);
                 if ((rv = send_with_recon(spc, &rhdr, sizeof(rhdr))) != 0) {                  if ((rv = send_with_recon(spc, iov, __arraycount(iov))) != 0) {
                         unputwait(spc, &rw);  
                         continue;  
                 }  
                 if ((rv = send_with_recon(spc, data, dlen)) != 0) {  
                         unputwait(spc, &rw);                          unputwait(spc, &rw);
                         continue;                          continue;
                 }                  }
Line 319  handshake_req(struct spclient *spc, int 
Line 318  handshake_req(struct spclient *spc, int 
         int cancel, bool haslock)          int cancel, bool haslock)
 {  {
         struct handshake_fork rf;          struct handshake_fork rf;
           const char *myprogname;
         struct rsp_hdr rhdr;          struct rsp_hdr rhdr;
         struct respwait rw;          struct respwait rw;
         sigset_t omask;          sigset_t omask;
         size_t bonus;          size_t bonus;
           struct iovec iov[2];
         int rv;          int rv;
   
         if (type == HANDSHAKE_FORK) {          if (type == HANDSHAKE_FORK) {
                 bonus = sizeof(rf);                  bonus = sizeof(rf);
         } else {          } else {
                 bonus = strlen(getprogname())+1;                  myprogname = getprogname();
                   bonus = strlen(myprogname)+1;
         }          }
   
         /* performs server handshake */          /* performs server handshake */
Line 337  handshake_req(struct spclient *spc, int 
Line 339  handshake_req(struct spclient *spc, int 
         rhdr.rsp_type = RUMPSP_HANDSHAKE;          rhdr.rsp_type = RUMPSP_HANDSHAKE;
         rhdr.rsp_handshake = type;          rhdr.rsp_handshake = type;
   
           IOVPUT(iov[0], rhdr);
   
         pthread_sigmask(SIG_SETMASK, &fullset, &omask);          pthread_sigmask(SIG_SETMASK, &fullset, &omask);
         if (haslock)          if (haslock)
                 putwait_locked(spc, &rw, &rhdr);                  putwait_locked(spc, &rw, &rhdr);
         else          else
                 putwait(spc, &rw, &rhdr);                  putwait(spc, &rw, &rhdr);
         rv = dosend(spc, &rhdr, sizeof(rhdr));  
         if (type == HANDSHAKE_FORK) {          if (type == HANDSHAKE_FORK) {
                 memcpy(rf.rf_auth, data, sizeof(rf.rf_auth)); /* uh, why? */                  memcpy(rf.rf_auth, data, sizeof(rf.rf_auth)); /* uh, why? */
                 rf.rf_cancel = cancel;                  rf.rf_cancel = cancel;
                 rv = send_with_recon(spc, &rf, sizeof(rf));                  IOVPUT(iov[1], rf);
         } else {          } else {
                 rv = dosend(spc, getprogname(), strlen(getprogname())+1);                  IOVPUT_WITHSIZE(iov[1], __UNCONST(getprogname()), bonus);
         }          }
           rv = send_with_recon(spc, iov, __arraycount(iov));
         if (rv || cancel) {          if (rv || cancel) {
                 if (haslock)                  if (haslock)
                         unputwait_locked(spc, &rw);                          unputwait_locked(spc, &rw);
Line 377  prefork_req(struct spclient *spc, sigset
Line 381  prefork_req(struct spclient *spc, sigset
 {  {
         struct rsp_hdr rhdr;          struct rsp_hdr rhdr;
         struct respwait rw;          struct respwait rw;
           struct iovec iov[1];
         int rv;          int rv;
   
         rhdr.rsp_len = sizeof(rhdr);          rhdr.rsp_len = sizeof(rhdr);
Line 384  prefork_req(struct spclient *spc, sigset
Line 389  prefork_req(struct spclient *spc, sigset
         rhdr.rsp_type = RUMPSP_PREFORK;          rhdr.rsp_type = RUMPSP_PREFORK;
         rhdr.rsp_error = 0;          rhdr.rsp_error = 0;
   
           IOVPUT(iov[0], rhdr);
   
         do {          do {
                 putwait(spc, &rw, &rhdr);                  putwait(spc, &rw, &rhdr);
                 rv = send_with_recon(spc, &rhdr, sizeof(rhdr));                  rv = send_with_recon(spc, iov, __arraycount(iov));
                 if (rv != 0) {                  if (rv != 0) {
                         unputwait(spc, &rw);                          unputwait(spc, &rw);
                         continue;                          continue;
Line 430  send_copyin_resp(struct spclient *spc, u
Line 437  send_copyin_resp(struct spclient *spc, u
         int wantstr)          int wantstr)
 {  {
         struct rsp_hdr rhdr;          struct rsp_hdr rhdr;
           struct iovec iov[2];
   
         if (wantstr)          if (wantstr)
                 dlen = MIN(dlen, strlen(data)+1);                  dlen = MIN(dlen, strlen(data)+1);
Line 440  send_copyin_resp(struct spclient *spc, u
Line 448  send_copyin_resp(struct spclient *spc, u
         rhdr.rsp_type = RUMPSP_COPYIN;          rhdr.rsp_type = RUMPSP_COPYIN;
         rhdr.rsp_sysnum = 0;          rhdr.rsp_sysnum = 0;
   
           IOVPUT(iov[0], rhdr);
           IOVPUT_WITHSIZE(iov[1], data, dlen);
   
         if (resp_sendlock(spc) != 0)          if (resp_sendlock(spc) != 0)
                 return;                  return;
         (void)dosend(spc, &rhdr, sizeof(rhdr));          (void)SENDIOV(spc, iov);
         (void)dosend(spc, data, dlen);  
         sendunlock(spc);          sendunlock(spc);
 }  }
   
Line 451  static void
Line 461  static void
 send_anonmmap_resp(struct spclient *spc, uint64_t reqno, void *addr)  send_anonmmap_resp(struct spclient *spc, uint64_t reqno, void *addr)
 {  {
         struct rsp_hdr rhdr;          struct rsp_hdr rhdr;
           struct iovec iov[2];
   
         rhdr.rsp_len = sizeof(rhdr) + sizeof(addr);          rhdr.rsp_len = sizeof(rhdr) + sizeof(addr);
         rhdr.rsp_reqno = reqno;          rhdr.rsp_reqno = reqno;
Line 458  send_anonmmap_resp(struct spclient *spc,
Line 469  send_anonmmap_resp(struct spclient *spc,
         rhdr.rsp_type = RUMPSP_ANONMMAP;          rhdr.rsp_type = RUMPSP_ANONMMAP;
         rhdr.rsp_sysnum = 0;          rhdr.rsp_sysnum = 0;
   
           IOVPUT(iov[0], rhdr);
           IOVPUT(iov[1], addr);
   
         if (resp_sendlock(spc) != 0)          if (resp_sendlock(spc) != 0)
                 return;                  return;
         (void)dosend(spc, &rhdr, sizeof(rhdr));          (void)SENDIOV(spc, iov);
         (void)dosend(spc, &addr, sizeof(addr));  
         sendunlock(spc);          sendunlock(spc);
 }  }
   
Line 775  rumpclient_init()
Line 788  rumpclient_init()
         FINDSYM(fcntl)          FINDSYM(fcntl)
         FINDSYM(poll)          FINDSYM(poll)
         FINDSYM(read)          FINDSYM(read)
         FINDSYM(sendto)          FINDSYM(sendmsg)
         FINDSYM(setsockopt)          FINDSYM(setsockopt)
         FINDSYM(dup)          FINDSYM(dup)
         FINDSYM(kqueue)          FINDSYM(kqueue)

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

CVSweb <webmaster@jp.NetBSD.org>