[BACK]Return to client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/client.c between version 1.8 and 1.9

version 1.8, 2009/07/30 16:16:19 version 1.9, 2009/07/30 16:32:12
Line 137 
Line 137 
 client_main(struct client_ctx *cctx)  client_main(struct client_ctx *cctx)
 {  {
         struct pollfd    pfd;          struct pollfd    pfd;
         int              xtimeout; /* Yay for ncurses namespace! */  
   
         siginit();          siginit();
   
Line 158 
Line 157 
                         sigcont = 0;                          sigcont = 0;
                 }                  }
   
                 switch (client_msg_dispatch(cctx)) {  
                 case -1:  
                         goto out;  
                 case 0:  
                         /* May be more in buffer, don't let poll block. */  
                         xtimeout = 0;  
                         break;  
                 default:  
                         /* Out of data, poll may block. */  
                         xtimeout = INFTIM;  
                         break;  
                 }  
   
                 pfd.fd = cctx->srv_fd;                  pfd.fd = cctx->srv_fd;
                 pfd.events = POLLIN;                  pfd.events = POLLIN;
                 if (BUFFER_USED(cctx->srv_out) > 0)                  if (BUFFER_USED(cctx->srv_out) > 0)
                         pfd.events |= POLLOUT;                          pfd.events |= POLLOUT;
   
                 if (poll(&pfd, 1, xtimeout) == -1) {                  if (poll(&pfd, 1, INFTIM) == -1) {
                         if (errno == EAGAIN || errno == EINTR)                          if (errno == EAGAIN || errno == EINTR)
                                 continue;                                  continue;
                         fatal("poll failed");                          fatal("poll failed");
Line 186 
Line 172 
                         cctx->exittype = CCTX_DIED;                          cctx->exittype = CCTX_DIED;
                         break;                          break;
                 }                  }
   
                   if (client_msg_dispatch(cctx) != 0)
                           break;
         }          }
   
 out:  
         if (sigterm) {          if (sigterm) {
                 printf("[terminated]\n");                  printf("[terminated]\n");
                 return (1);                  return (1);
Line 226 
Line 214 
         client_write_server(cctx, MSG_RESIZE, &data, sizeof data);          client_write_server(cctx, MSG_RESIZE, &data, sizeof data);
   
         sigwinch = 0;          sigwinch = 0;
   }
   
   int
   client_msg_dispatch(struct client_ctx *cctx)
   {
           struct hdr               hdr;
           struct msg_print_data    printdata;
   
           for (;;) {
                   if (BUFFER_USED(cctx->srv_in) < sizeof hdr)
                           return (0);
                   memcpy(&hdr, BUFFER_OUT(cctx->srv_in), sizeof hdr);
                   if (BUFFER_USED(cctx->srv_in) < (sizeof hdr) + hdr.size)
                           return (0);
                   buffer_remove(cctx->srv_in, sizeof hdr);
   
                   switch (hdr.type) {
                   case MSG_DETACH:
                           if (hdr.size != 0)
                                   fatalx("bad MSG_DETACH size");
   
                           client_write_server(cctx, MSG_EXITING, NULL, 0);
                           cctx->exittype = CCTX_DETACH;
                           break;
                   case MSG_ERROR:
                           if (hdr.size != sizeof printdata)
                                   fatalx("bad MSG_PRINT size");
                           buffer_read(cctx->srv_in, &printdata, sizeof printdata);
                           printdata.msg[(sizeof printdata.msg) - 1] = '\0';
   
                           cctx->errstr = xstrdup(printdata.msg);
                           return (-1);
                   case MSG_EXIT:
                           if (hdr.size != 0)
                                   fatalx("bad MSG_EXIT size");
   
                           client_write_server(cctx, MSG_EXITING, NULL, 0);
                           cctx->exittype = CCTX_EXIT;
                           break;
                   case MSG_EXITED:
                           if (hdr.size != 0)
                                   fatalx("bad MSG_EXITED size");
   
                           return (-1);
                   case MSG_SHUTDOWN:
                           if (hdr.size != 0)
                                   fatalx("bad MSG_SHUTDOWN size");
   
                           client_write_server(cctx, MSG_EXITING, NULL, 0);
                           cctx->exittype = CCTX_SHUTDOWN;
                           break;
                   case MSG_SUSPEND:
                           if (hdr.size != 0)
                                   fatalx("bad MSG_SUSPEND size");
   
                           client_suspend();
                           break;
                   default:
                           fatalx("unexpected message");
                   }
           }
 }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9