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

Diff for /src/usr.bin/tmux/server-client.c between version 1.72 and 1.73

version 1.72, 2012/05/06 07:38:17 version 1.73, 2012/05/21 18:27:42
Line 35 
Line 35 
 void    server_client_check_redraw(struct client *);  void    server_client_check_redraw(struct client *);
 void    server_client_set_title(struct client *);  void    server_client_set_title(struct client *);
 void    server_client_reset_state(struct client *);  void    server_client_reset_state(struct client *);
 void    server_client_in_callback(struct bufferevent *, short, void *);  
 void    server_client_out_callback(struct bufferevent *, short, void *);  
 void    server_client_err_callback(struct bufferevent *, short, void *);  
   
 int     server_client_msg_dispatch(struct client *);  int     server_client_msg_dispatch(struct client *);
 void    server_client_msg_command(struct client *, struct msg_command_data *);  void    server_client_msg_command(struct client *, struct msg_command_data *);
Line 67 
Line 64 
                 fatal("gettimeofday failed");                  fatal("gettimeofday failed");
         memcpy(&c->activity_time, &c->creation_time, sizeof c->activity_time);          memcpy(&c->activity_time, &c->creation_time, sizeof c->activity_time);
   
         c->stdin_event = NULL;          c->stdin_data = evbuffer_new ();
         c->stdout_event = NULL;          c->stdout_data = evbuffer_new ();
         c->stderr_event = NULL;          c->stderr_data = evbuffer_new ();
   
         c->tty.fd = -1;          c->tty.fd = -1;
         c->title = NULL;          c->title = NULL;
Line 144 
Line 141 
         if (c->flags & CLIENT_TERMINAL)          if (c->flags & CLIENT_TERMINAL)
                 tty_free(&c->tty);                  tty_free(&c->tty);
   
         if (c->stdin_event != NULL)          evbuffer_free (c->stdin_data);
                 bufferevent_free(c->stdin_event);          evbuffer_free (c->stdout_data);
         if (c->stdin_fd != -1) {          evbuffer_free (c->stderr_data);
                 setblocking(c->stdin_fd, 1);  
                 close(c->stdin_fd);  
         }  
         if (c->stdout_event != NULL)  
                 bufferevent_free(c->stdout_event);  
         if (c->stdout_fd != -1) {  
                 setblocking(c->stdout_fd, 1);  
                 close(c->stdout_fd);  
         }  
         if (c->stderr_event != NULL)  
                 bufferevent_free(c->stderr_event);  
         if (c->stderr_fd != -1) {  
                 setblocking(c->stderr_fd, 1);  
                 close(c->stderr_fd);  
         }  
   
         status_free_jobs(&c->status_new);          status_free_jobs(&c->status_new);
         status_free_jobs(&c->status_old);          status_free_jobs(&c->status_old);
Line 240 
Line 222 
                         goto client_lost;                          goto client_lost;
         }          }
   
           server_push_stdout(c);
           server_push_stderr(c);
   
         server_update_event(c);          server_update_event(c);
         return;          return;
   
Line 603 
Line 588 
         if (!(c->flags & CLIENT_EXIT))          if (!(c->flags & CLIENT_EXIT))
                 return;                  return;
   
         if (c->stdout_fd != -1 && c->stdout_event != NULL &&          if (EVBUFFER_LENGTH(c->stdin_data) != 0)
             EVBUFFER_LENGTH(c->stdout_event->output) != 0)  
                 return;                  return;
         if (c->stderr_fd != -1 && c->stderr_event != NULL &&          if (EVBUFFER_LENGTH(c->stdout_data) != 0)
             EVBUFFER_LENGTH(c->stderr_event->output) != 0)  
                 return;                  return;
           if (EVBUFFER_LENGTH(c->stderr_data) != 0)
                   return;
   
         exitdata.retcode = c->retcode;          exitdata.retcode = c->retcode;
         server_write_client(c, MSG_EXIT, &exitdata, sizeof exitdata);          server_write_client(c, MSG_EXIT, &exitdata, sizeof exitdata);
Line 686 
Line 671 
         xfree(title);          xfree(title);
 }  }
   
 /*  
  * Error callback for client stdin. Caller must increase reference count when  
  * enabling event!  
  */  
 void  
 server_client_in_callback(  
     unused struct bufferevent *bufev, unused short what, void *data)  
 {  
         struct client   *c = data;  
   
         c->references--;  
         if (c->flags & CLIENT_DEAD)  
                 return;  
   
         bufferevent_disable(c->stdin_event, EV_READ|EV_WRITE);  
         setblocking(c->stdin_fd, 1);  
         close(c->stdin_fd);  
         c->stdin_fd = -1;  
   
         if (c->stdin_callback != NULL)  
                 c->stdin_callback(c, c->stdin_data);  
 }  
   
 /* Error callback for client stdout. */  
 void  
 server_client_out_callback(  
     unused struct bufferevent *bufev, unused short what, unused void *data)  
 {  
         struct client   *c = data;  
   
         bufferevent_disable(c->stdout_event, EV_READ|EV_WRITE);  
         setblocking(c->stdout_fd, 1);  
         close(c->stdout_fd);  
         c->stdout_fd = -1;  
 }  
   
 /* Error callback for client stderr. */  
 void  
 server_client_err_callback(  
     unused struct bufferevent *bufev, unused short what, unused void *data)  
 {  
         struct client   *c = data;  
   
         bufferevent_disable(c->stderr_event, EV_READ|EV_WRITE);  
         setblocking(c->stderr_fd, 1);  
         close(c->stderr_fd);  
         c->stderr_fd = -1;  
 }  
   
 /* Dispatch message from client. */  /* Dispatch message from client. */
 int  int
 server_client_msg_dispatch(struct client *c)  server_client_msg_dispatch(struct client *c)
Line 743 
Line 679 
         struct msg_command_data  commanddata;          struct msg_command_data  commanddata;
         struct msg_identify_data identifydata;          struct msg_identify_data identifydata;
         struct msg_environ_data  environdata;          struct msg_environ_data  environdata;
           struct msg_stdin_data    stdindata;
         ssize_t                  n, datalen;          ssize_t                  n, datalen;
   
         if ((n = imsg_read(&c->ibuf)) == -1 || n == 0)          if ((n = imsg_read(&c->ibuf)) == -1 || n == 0)
Line 778 
Line 715 
                                 fatalx("MSG_IDENTIFY missing fd");                                  fatalx("MSG_IDENTIFY missing fd");
                         memcpy(&identifydata, imsg.data, sizeof identifydata);                          memcpy(&identifydata, imsg.data, sizeof identifydata);
   
                         c->stdin_fd = imsg.fd;  
                         c->stdin_event = bufferevent_new(c->stdin_fd,  
                             NULL, NULL, server_client_in_callback, c);  
                         if (c->stdin_event == NULL)  
                                 fatalx("failed to create stdin event");  
                         setblocking(c->stdin_fd, 0);  
   
                         server_client_msg_identify(c, &identifydata, imsg.fd);                          server_client_msg_identify(c, &identifydata, imsg.fd);
                         break;                          break;
                 case MSG_STDOUT:                  case MSG_STDIN:
                         if (datalen != 0)                          if (datalen != sizeof stdindata)
                                 fatalx("bad MSG_STDOUT size");                                  fatalx("bad MSG_STDIN size");
                         if (imsg.fd == -1)                          memcpy(&stdindata, imsg.data, sizeof stdindata);
                                 fatalx("MSG_STDOUT missing fd");  
   
                         c->stdout_fd = imsg.fd;                          if (c->stdin_callback == NULL)
                         c->stdout_event = bufferevent_new(c->stdout_fd,                                  break;
                             NULL, NULL, server_client_out_callback, c);                          if (stdindata.size <= 0)
                         if (c->stdout_event == NULL)                                  c->stdin_closed = 1;
                                 fatalx("failed to create stdout event");                          else {
                         setblocking(c->stdout_fd, 0);                                  evbuffer_add(c->stdin_data, stdindata.data,
                                       stdindata.size);
                           }
                           c->stdin_callback(c, c->stdin_closed,
                               c->stdin_callback_data);
                         break;                          break;
                 case MSG_STDERR:  
                         if (datalen != 0)  
                                 fatalx("bad MSG_STDERR size");  
                         if (imsg.fd == -1)  
                                 fatalx("MSG_STDERR missing fd");  
   
                         c->stderr_fd = imsg.fd;  
                         c->stderr_event = bufferevent_new(c->stderr_fd,  
                             NULL, NULL, server_client_err_callback, c);  
                         if (c->stderr_event == NULL)  
                                 fatalx("failed to create stderr event");  
                         setblocking(c->stderr_fd, 0);  
   
                         break;  
                 case MSG_RESIZE:                  case MSG_RESIZE:
                         if (datalen != 0)                          if (datalen != 0)
                                 fatalx("bad MSG_RESIZE size");                                  fatalx("bad MSG_RESIZE size");
Line 880 
Line 798 
         va_list ap;          va_list ap;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         evbuffer_add_vprintf(ctx->cmdclient->stderr_event->output, fmt, ap);          evbuffer_add_vprintf(ctx->cmdclient->stderr_data, fmt, ap);
         va_end(ap);          va_end(ap);
   
         bufferevent_write(ctx->cmdclient->stderr_event, "\n", 1);          evbuffer_add(ctx->cmdclient->stderr_data, "\n", 1);
           server_push_stderr(ctx->cmdclient);
         ctx->cmdclient->retcode = 1;          ctx->cmdclient->retcode = 1;
 }  }
   
Line 894 
Line 813 
         va_list ap;          va_list ap;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         evbuffer_add_vprintf(ctx->cmdclient->stdout_event->output, fmt, ap);          evbuffer_add_vprintf(ctx->cmdclient->stdout_data, fmt, ap);
         va_end(ap);          va_end(ap);
   
         bufferevent_write(ctx->cmdclient->stdout_event, "\n", 1);          evbuffer_add(ctx->cmdclient->stdout_data, "\n", 1);
           server_push_stdout(ctx->cmdclient);
 }  }
   
 /* Callback to send print message to client, if not quiet. */  /* Callback to send print message to client, if not quiet. */
Line 910 
Line 830 
                 return;                  return;
   
         va_start(ap, fmt);          va_start(ap, fmt);
         evbuffer_add_vprintf(ctx->cmdclient->stdout_event->output, fmt, ap);          evbuffer_add_vprintf(ctx->cmdclient->stdout_data, fmt, ap);
         va_end(ap);          va_end(ap);
   
         bufferevent_write(ctx->cmdclient->stdout_event, "\n", 1);          evbuffer_add(ctx->cmdclient->stdout_data, "\n", 1);
           server_push_stdout(ctx->cmdclient);
 }  }
   
 /* Handle command message. */  /* Handle command message. */
Line 970 
Line 891 
 server_client_msg_identify(  server_client_msg_identify(
     struct client *c, struct msg_identify_data *data, int fd)      struct client *c, struct msg_identify_data *data, int fd)
 {  {
         int     tty_fd;  
   
         c->cwd = NULL;          c->cwd = NULL;
         data->cwd[(sizeof data->cwd) - 1] = '\0';          data->cwd[(sizeof data->cwd) - 1] = '\0';
         if (*data->cwd != '\0')          if (*data->cwd != '\0')
Line 979 
Line 898 
   
         if (!isatty(fd))          if (!isatty(fd))
             return;              return;
         if ((tty_fd = dup(fd)) == -1)  
                 fatal("dup failed");  
         data->term[(sizeof data->term) - 1] = '\0';          data->term[(sizeof data->term) - 1] = '\0';
         tty_init(&c->tty, tty_fd, data->term);          tty_init(&c->tty, fd, data->term);
         if (data->flags & IDENTIFY_UTF8)          if (data->flags & IDENTIFY_UTF8)
                 c->tty.flags |= TTY_UTF8;                  c->tty.flags |= TTY_UTF8;
         if (data->flags & IDENTIFY_256COLOURS)          if (data->flags & IDENTIFY_256COLOURS)

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.73