From dd36982ad51632bc47ce7b73cad0696e85d593c3 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Sun, 8 Nov 2009 22:40:36 +0000 Subject: Sync OpenBSD patchset 491: Initial changes to move tmux to libevent. This moves the client-side loops are pretty much fully over to event-based only (tmux.c and client.c) but server-side (server.c and friends) treats libevent as a sort of clever poll, waking up after every event to run various things. Moving the server stuff over to bufferevents and timers and so on will come later. --- server-window.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'server-window.c') diff --git a/server-window.c b/server-window.c index 9a411cd3..80a20330 100644 --- a/server-window.c +++ b/server-window.c @@ -1,4 +1,4 @@ -/* $Id: server-window.c,v 1.4 2009-11-04 22:47:29 tcunha Exp $ */ +/* $Id: server-window.c,v 1.5 2009-11-08 22:40:36 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -47,19 +48,23 @@ server_window_prepare(void) continue; events = 0; if (!server_window_backoff(wp)) - events |= POLLIN; + events = EV_READ; if (BUFFER_USED(wp->out) > 0) - events |= POLLOUT; - server_poll_add( + events |= EV_WRITE; + event_del(&wp->event); + event_set(&wp->event, wp->fd, events, server_window_callback, wp); + event_add(&wp->event, NULL); if (wp->pipe_fd == -1) continue; events = 0; if (BUFFER_USED(wp->pipe_buf) > 0) - events |= POLLOUT; - server_poll_add( + events |= EV_WRITE; + event_del(&wp->pipe_event); + event_set(&wp->pipe_event, wp->pipe_fd, events, server_window_callback, wp); + event_add(&wp->pipe_event, NULL); } } } @@ -90,7 +95,7 @@ server_window_backoff(struct window_pane *wp) /* Process a single window pane event. */ void -server_window_callback(int fd, int events, void *data) +server_window_callback(int fd, short events, void *data) { struct window_pane *wp = data; -- cgit