[Spice-commits] 7 commits - configure.ac server/main_channel.c server/Makefile.am server/red_channel.c server/red_channel.h server/reds.c server/red_worker.c server/snd_worker.c

Alon Levy alon at kemper.freedesktop.org
Tue Feb 21 00:41:25 PST 2012


 configure.ac          |   10 +++
 server/Makefile.am    |   12 ++--
 server/main_channel.c |    2 
 server/red_channel.c  |   16 +----
 server/red_channel.h  |   12 +++-
 server/red_worker.c   |  143 ++++++++++++++++++++++++++------------------------
 server/reds.c         |   28 +++++++++
 server/snd_worker.c   |    9 ++-
 8 files changed, 140 insertions(+), 92 deletions(-)

New commits:
commit 016bc7513f0e758162d136476b8faa7e7832a60b
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:13 2012 -0600

    Use standard IOV_MAX definition where applicable
    
    This is provided by <limits.h> on all platforms as long as _XOPEN_SOURCE
    is defined. On Linux, this is 1024, on Solaris, this is 16, and on any
    other platform, we now respect the value supported by the OS.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/main_channel.c b/server/main_channel.c
index f7e1ab0..4d1f8ea 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -47,8 +47,6 @@
 
 #define ZERO_BUF_SIZE 4096
 
-#define REDS_MAX_SEND_IOVEC 100
-
 #define NET_TEST_WARMUP_BYTES 0
 #define NET_TEST_BYTES (1024 * 250)
 
diff --git a/server/red_channel.c b/server/red_channel.c
index 5b8027c..2cd98da 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -329,7 +329,7 @@ static void red_channel_client_peer_prepare_out_msg(
     RedChannelClient *rcc = (RedChannelClient *)opaque;
 
     *vec_size = spice_marshaller_fill_iovec(rcc->send_data.marshaller,
-                                            vec, MAX_SEND_VEC, pos);
+                                            vec, IOV_MAX, pos);
 }
 
 static void red_channel_client_peer_on_out_block(void *opaque)
diff --git a/server/red_channel.h b/server/red_channel.h
index a360a30..ce534ca 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -22,17 +22,22 @@
 #ifndef _H_RED_CHANNEL
 #define _H_RED_CHANNEL
 
-#include "red_common.h"
 #include <pthread.h>
+#include <limits.h>
+
+#include "red_common.h"
 #include "spice.h"
 #include "ring.h"
 #include "common/marshaller.h"
 #include "server/demarshallers.h"
 
 #define MAX_SEND_BUFS 1000
-#define MAX_SEND_VEC 100
 #define CLIENT_ACK_WINDOW 20
 
+#ifndef IOV_MAX
+#define IOV_MAX 1024
+#endif
+
 #define MAX_HEADER_SIZE sizeof(SpiceDataHeader)
 
 /* Basic interface for channels, without using the RedChannel interface.
@@ -109,7 +114,7 @@ typedef struct OutgoingHandlerInterface {
 typedef struct OutgoingHandler {
     OutgoingHandlerInterface *cb;
     void *opaque;
-    struct iovec vec_buf[MAX_SEND_VEC];
+    struct iovec vec_buf[IOV_MAX];
     int vec_size;
     struct iovec *vec;
     int pos;
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 0e93a6f..aa1ceb7 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -21,6 +21,7 @@
 
 #include <fcntl.h>
 #include <errno.h>
+#include <limits.h>
 #include <sys/socket.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
@@ -36,7 +37,9 @@
 #include "generated_marshallers.h"
 #include "demarshallers.h"
 
-#define MAX_SEND_VEC 100
+#ifndef IOV_MAX
+#define IOV_MAX 1024
+#endif
 
 #define RECIVE_BUF_SIZE (16 * 1024 * 2)
 
@@ -262,7 +265,7 @@ static int snd_send_data(SndChannel *channel)
     }
 
     for (;;) {
-        struct iovec vec[MAX_SEND_VEC];
+        struct iovec vec[IOV_MAX];
         int vec_size;
 
         if (!n) {
@@ -276,7 +279,7 @@ static int snd_send_data(SndChannel *channel)
         }
 
         vec_size = spice_marshaller_fill_iovec(channel->send_data.marshaller,
-                                               vec, MAX_SEND_VEC, channel->send_data.pos);
+                                               vec, IOV_MAX, channel->send_data.pos);
         n = reds_stream_writev(channel->stream, vec, vec_size);
         if (n == -1) {
             switch (errno) {
commit bdfd6c234bca76232f4bac308fc21321ebba7f1a
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:12 2012 -0600

    Respect IOV_MAX if defined
    
    Solaris has a pitiful maximum writev vector size of only 16, so the ping
    request at initial startup destroyed this call and broke things
    immediately. Reimplement stream_writev_cb() to respect IOV_MAX and break
    the writev() calls into chunks as necessary. Care was taken to return
    the correct values as necessary so the EAGAIN handling logic can
    determine where to resume the writev call the next time around.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/reds.c b/server/reds.c
index 250e0ca..797d9d5 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/socket.h>
+#include <sys/uio.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
@@ -340,7 +341,31 @@ static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size)
 
 static ssize_t stream_writev_cb(RedsStream *s, const struct iovec *iov, int iovcnt)
 {
-    return writev(s->socket, iov, iovcnt);
+    ssize_t ret = 0;
+    do {
+        int tosend;
+        ssize_t n, expected = 0;
+        int i;
+#ifdef IOV_MAX
+        tosend = MIN(iovcnt, IOV_MAX);
+#else
+        tosend = iovcnt;
+#endif
+        for (i = 0; i < tosend; i++) {
+            expected += iov[i].iov_len;
+        }
+        n = writev(s->socket, iov, tosend);
+        if (n <= expected) {
+            if (n > 0)
+                ret += n;
+            return ret == 0 ? n : ret;
+        }
+        ret += n;
+        iov += tosend;
+        iovcnt -= tosend;
+    } while(iovcnt > 0);
+
+    return ret;
 }
 
 static ssize_t stream_read_cb(RedsStream *s, void *buf, size_t size)
commit 143a1df24e83e9c1e173c16aeb76d61ffdce9598
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:11 2012 -0600

    red_worker: reimplement event loop using poll()
    
    This removes the epoll dependency we had in red_worker, which was the
    last Linux-specific call we were using in the entire Spice server. Given
    we never have more than 10 file descriptors involved, there is little
    performance gain had here by using epoll() over poll().
    
    The biggest change is introduction of a new pre_disconnect callback;
    this is because poll, unlike epoll, cannot automatically remove file
    descriptors as they are closed from the pollfd set. This cannot be done
    in the existing on_disconnect callback; that is too late as the stream
    has already been closed and the file descriptor lost. The on_disconnect
    callback can not be moved before the close and other operations easily
    because of some behavior that relies on client_num being set to a
    certain value.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index 59e6af6..5b8027c 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -1191,6 +1191,9 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
         return;
     }
     red_channel_client_pipe_clear(rcc);
+    if (rcc->channel->channel_cbs.pre_disconnect) {
+        rcc->channel->channel_cbs.pre_disconnect(rcc);
+    }
     reds_stream_free(rcc->stream);
     rcc->stream = NULL;
     red_channel_remove_client(rcc);
diff --git a/server/red_channel.h b/server/red_channel.h
index 543aec1..a360a30 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -182,6 +182,7 @@ typedef void (*channel_client_migrate_proc)(RedChannelClient *base);
  */
 typedef struct {
     channel_configure_socket_proc config_socket;
+    channel_disconnect_proc pre_disconnect;
     channel_disconnect_proc on_disconnect;
     channel_send_pipe_item_proc send_item;
     channel_hold_pipe_item_proc hold_item;
diff --git a/server/red_worker.c b/server/red_worker.c
index 3973f3e..e88dbc0 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -31,7 +31,6 @@
 
 #include <stdio.h>
 #include <stdarg.h>
-#include <sys/epoll.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -39,6 +38,7 @@
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
+#include <poll.h>
 #include <pthread.h>
 #include <netinet/tcp.h>
 #include <setjmp.h>
@@ -231,12 +231,12 @@ double inline stat_byte_to_mega(uint64_t size)
 #define stat_compress_add(a, b, c, d)
 #endif
 
-#define MAX_EPOLL_SOURCES 10
+#define MAX_EVENT_SOURCES 20
 #define INF_EVENT_WAIT ~0
 
 
 typedef struct EventListener EventListener;
-typedef void (*event_listener_action_proc)(EventListener *ctx, uint32_t events);
+typedef void (*event_listener_action_proc)(EventListener *ctx, struct pollfd *pfd);
 typedef void (*event_listener_free_proc)(EventListener *ctx);
 struct EventListener {
     uint32_t refs;
@@ -877,7 +877,8 @@ typedef struct RedWorker {
     int id;
     int running;
     uint32_t *pending;
-    int epoll;
+    struct pollfd poll_fds[MAX_EVENT_SOURCES];
+    EventListener *listeners[MAX_EVENT_SOURCES];
     unsigned int event_timeout;
     uint32_t repoll_cmd_ring;
     uint32_t repoll_cursor_ring;
@@ -8721,6 +8722,21 @@ void red_show_tree(RedWorker *worker)
     }
 }
 
+static void poll_channel_client_pre_disconnect(RedChannelClient *rcc)
+{
+    CommonChannel *common;
+    int i;
+
+    common = SPICE_CONTAINEROF(rcc->channel, CommonChannel, base);
+    for (i = 0; i < MAX_EVENT_SOURCES; i++) {
+        struct pollfd *pfd = common->worker->poll_fds + i;
+        if (pfd->fd == rcc->stream->socket) {
+            pfd->fd = -1;
+            break;
+        }
+    }
+}
+
 static void display_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     DisplayChannel *display_channel;
@@ -9612,7 +9628,7 @@ CursorChannelClient *cursor_channel_create_rcc(CommonChannel *common,
 static int listen_to_new_client_channel(CommonChannel *common,
     CommonChannelClient *common_cc, RedsStream *stream)
 {
-    struct epoll_event event;
+    int i;
 
     common_cc->listener.refs = 1;
     common_cc->listener.action = common->listener_action;
@@ -9620,17 +9636,23 @@ static int listen_to_new_client_channel(CommonChannel *common,
     ASSERT(common->base.clients_num);
     common_cc->id = common->worker->id;
     red_printf("NEW ID = %d", common_cc->id);
-    event.events = EPOLLIN | EPOLLOUT | EPOLLET;
-    event.data.ptr = &common_cc->listener;
-    if (epoll_ctl(common->worker->epoll, EPOLL_CTL_ADD, stream->socket, &event) == -1) {
-        red_printf("epoll_ctl failed, %s", strerror(errno));
-        return FALSE;
+
+    for (i = 0; i < MAX_EVENT_SOURCES; i++) {
+        struct pollfd *pfd = common->worker->poll_fds + i;
+        if (pfd->fd < 0) {
+            red_printf("new poll event %d (fd %d)", i, stream->socket);
+            pfd->fd = stream->socket;
+            pfd->events = POLLIN | POLLOUT;
+            common->worker->listeners[i] = &common_cc->listener;
+            return TRUE;
+        }
     }
-    return TRUE;
+    return FALSE;
 }
 
 static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type, int migrate,
                                  event_listener_action_proc handler,
+                                 channel_disconnect_proc pre_disconnect,
                                  channel_disconnect_proc on_disconnect,
                                  channel_send_pipe_item_proc send_item,
                                  channel_hold_pipe_item_proc hold_item,
@@ -9645,6 +9667,7 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_t
     ChannelCbs channel_cbs;
 
     channel_cbs.config_socket = common_channel_config_socket;
+    channel_cbs.pre_disconnect = pre_disconnect;
     channel_cbs.on_disconnect = on_disconnect;
     channel_cbs.send_item = send_item;
     channel_cbs.hold_item = hold_item;
@@ -9675,12 +9698,12 @@ error:
     return NULL;
 }
 
-static void handle_channel_events(EventListener *in_listener, uint32_t events)
+static void handle_channel_events(EventListener *in_listener, struct pollfd *pfd)
 {
     CommonChannelClient *common_cc = SPICE_CONTAINEROF(in_listener, CommonChannelClient, listener);
     RedChannelClient *rcc = &common_cc->base;
 
-    if ((events & EPOLLIN) && red_channel_client_is_connected(rcc)) {
+    if ((pfd->events & POLLIN) && red_channel_client_is_connected(rcc)) {
         red_channel_client_receive(rcc);
     }
 
@@ -9835,6 +9858,7 @@ static void display_channel_create(RedWorker *worker, int migrate)
             worker, sizeof(*display_channel),
             SPICE_CHANNEL_DISPLAY, migrate,
             handle_channel_events,
+            poll_channel_client_pre_disconnect,
             display_channel_client_on_disconnect,
             display_channel_send_item,
             display_channel_hold_pipe_item,
@@ -10049,6 +10073,7 @@ static void cursor_channel_create(RedWorker *worker, int migrate)
         worker, sizeof(*worker->cursor_channel),
         SPICE_CHANNEL_CURSOR, migrate,
         handle_channel_events,
+        poll_channel_client_pre_disconnect,
         cursor_channel_client_on_disconnect,
         cursor_channel_send_item,
         cursor_channel_hold_pipe_item,
@@ -11027,7 +11052,7 @@ static void register_callbacks(Dispatcher *dispatcher)
 
 
 
-static void handle_dev_input(EventListener *listener, uint32_t events)
+static void handle_dev_input(EventListener *listener, struct pollfd *pfd)
 {
     RedWorker *worker = SPICE_CONTAINEROF(listener, RedWorker, dev_listener);
 
@@ -11041,10 +11066,9 @@ static void handle_dev_free(EventListener *ctx)
 
 static void red_init(RedWorker *worker, WorkerInitData *init_data)
 {
-    struct epoll_event event;
     RedWorkerMessage message;
-    int epoll;
     Dispatcher *dispatcher;
+    int i;
 
     ASSERT(sizeof(CursorItem) <= QXL_CURSUR_DEVICE_DATA_SIZE);
 
@@ -11086,17 +11110,13 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
     worker->wakeup_counter = stat_add_counter(worker->stat, "wakeups", TRUE);
     worker->command_counter = stat_add_counter(worker->stat, "commands", TRUE);
 #endif
-    if ((epoll = epoll_create(MAX_EPOLL_SOURCES)) == -1) {
-        red_error("epoll_create failed, %s", strerror(errno));
+    for (i = 0; i < MAX_EVENT_SOURCES; i++) {
+        worker->poll_fds[i].fd = -1;
     }
-    worker->epoll = epoll;
 
-    event.events = EPOLLIN;
-    event.data.ptr = &worker->dev_listener;
-
-    if (epoll_ctl(epoll, EPOLL_CTL_ADD, worker->channel, &event) == -1) {
-        red_error("add channel failed, %s", strerror(errno));
-    }
+    worker->poll_fds[0].fd = worker->channel;
+    worker->poll_fds[0].events = POLLIN;
+    worker->listeners[0] = &worker->dev_listener;
 
     red_memslot_info_init(&worker->mem_slots,
                           init_data->num_memslots_groups,
@@ -11140,13 +11160,10 @@ void *red_worker_main(void *arg)
     red_init_zlib(&worker);
     worker.event_timeout = INF_EVENT_WAIT;
     for (;;) {
-        struct epoll_event events[MAX_EPOLL_SOURCES];
-        int num_events;
-        struct epoll_event *event;
-        struct epoll_event *end;
+        int i, num_events;
 
         worker.event_timeout = MIN(red_get_streams_timout(&worker), worker.event_timeout);
-        num_events = epoll_wait(worker.epoll, events, MAX_EPOLL_SOURCES, worker.event_timeout);
+        num_events = poll(worker.poll_fds, MAX_EVENT_SOURCES, worker.event_timeout);
         red_handle_streams_timout(&worker);
 
         if (worker.display_channel) {
@@ -11160,27 +11177,32 @@ void *red_worker_main(void *arg)
         worker.event_timeout = INF_EVENT_WAIT;
         if (num_events == -1) {
             if (errno != EINTR) {
-                red_error("poll_wait failed, %s", strerror(errno));
+                red_error("poll failed, %s", strerror(errno));
             }
             num_events = 0;
         }
 
-        for (event = events, end = event + num_events;  event < end; event++) {
-            EventListener *evt_listener = (EventListener *)event->data.ptr;
-            evt_listener->refs++;
+        for (i = 0; i < MAX_EVENT_SOURCES; i++) {
+            struct pollfd *pfd = worker.poll_fds + i;
+            if (pfd->revents) {
+                worker.listeners[i]->refs++;
+            }
         }
 
-        for (event = events, end = event + num_events; event < end; event++) {
-            EventListener *evt_listener = (EventListener *)event->data.ptr;
+        for (i = 0; i < MAX_EVENT_SOURCES; i++) {
+            struct pollfd *pfd = worker.poll_fds + i;
+            if (pfd->revents) {
+                EventListener *evt_listener = worker.listeners[i];
 
-            if (evt_listener->refs > 1) {
-                evt_listener->action(evt_listener, event->events);
-                if (--evt_listener->refs) {
-                    continue;
+                if (evt_listener->refs > 1) {
+                    evt_listener->action(evt_listener, pfd);
+                    if (--evt_listener->refs) {
+                        continue;
+                    }
                 }
+                red_printf("freeing event listener");
+                evt_listener->free(evt_listener);
             }
-            red_printf("freeing event listener");
-            evt_listener->free(evt_listener);
         }
 
         if (worker.running) {
diff --git a/server/reds.c b/server/reds.c
index daadb56..250e0ca 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -4204,6 +4204,7 @@ void reds_stream_free(RedsStream *s)
     }
 
     reds_stream_remove_watch(s);
+    red_printf("close socket fd %d", s->socket);
     close(s->socket);
 
     free(s);
commit dfbac622bf9cbff7b4bdcabe78299621821ca61e
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:10 2012 -0600

    Use memcpy call in red_channel_create
    
    Rather than assign the callbacks one-by-one, we can just memcpy the
    struct into the one we have allocated in our RedChannel object, which is
    much more efficient, not to mention future-proof when more callbacks are
    added.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index 0916118..59e6af6 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -610,14 +610,7 @@ RedChannel *red_channel_create(int size,
     channel->type = type;
     channel->id = id;
     channel->handle_acks = handle_acks;
-    channel->channel_cbs.on_disconnect = channel_cbs->on_disconnect;
-    channel->channel_cbs.send_item = channel_cbs->send_item;
-    channel->channel_cbs.release_item = channel_cbs->release_item;
-    channel->channel_cbs.hold_item = channel_cbs->hold_item;
-    channel->channel_cbs.handle_migrate_flush_mark = channel_cbs->handle_migrate_flush_mark;
-    channel->channel_cbs.handle_migrate_data = channel_cbs->handle_migrate_data;
-    channel->channel_cbs.handle_migrate_data_get_serial = channel_cbs->handle_migrate_data_get_serial;
-    channel->channel_cbs.config_socket = channel_cbs->config_socket;
+    memcpy(&channel->channel_cbs, channel_cbs, sizeof(ChannelCbs));
 
     channel->core = core;
     channel->migrate = migrate;
commit 10d79a35c1f571fe91615dd0ffa0f67a903b69c2
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:09 2012 -0600

    Cleanup definitions of disconnect methods
    
    We had multiple stub methods that simply called other disconnect
    methods, making my head hurt with the indirection. Call the right
    methods at the right time and rip out the stub methods; if they are
    truely needed later they can be added again.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/red_channel.c b/server/red_channel.c
index 6296dc9..0916118 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -1201,8 +1201,6 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
     reds_stream_free(rcc->stream);
     rcc->stream = NULL;
     red_channel_remove_client(rcc);
-    // TODO: not do it till destroyed?
-//    red_channel_client_remove(rcc);
     rcc->channel->channel_cbs.on_disconnect(rcc);
 }
 
diff --git a/server/red_worker.c b/server/red_worker.c
index 7703363..3973f3e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -8721,17 +8721,6 @@ void red_show_tree(RedWorker *worker)
     }
 }
 
-// TODO: move to red_channel
-static void red_disconnect_channel(RedChannel *channel)
-{
-    red_channel_disconnect(channel);
-}
-
-static void display_channel_client_disconnect(RedChannelClient *rcc)
-{
-    red_channel_client_disconnect(rcc);
-}
-
 static void display_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     DisplayChannel *display_channel;
@@ -8775,7 +8764,7 @@ void red_disconnect_all_display_TODO_remove_me(RedChannel *channel)
     if (!channel) {
         return;
     }
-    red_channel_apply_clients(channel, display_channel_client_disconnect);
+    red_channel_apply_clients(channel, red_channel_client_disconnect);
 }
 
 static void red_migrate_display(RedWorker *worker, RedChannelClient *rcc)
@@ -9132,7 +9121,7 @@ static int display_channel_client_wait_for_init(DisplayChannelClient *dcc)
         }
         if (red_now() > end_time) {
             red_printf("timeout");
-            display_channel_client_disconnect(&dcc->common.base);
+            red_channel_client_disconnect(&dcc->common.base);
             break;
         }
         usleep(DISPLAY_CLIENT_RETRY_INTERVAL);
@@ -9944,11 +9933,6 @@ error:
     red_channel_client_destroy(&dcc->common.base);
 }
 
-static void cursor_channel_client_disconnect(RedChannelClient *rcc)
-{
-    red_channel_client_disconnect(rcc);
-}
-
 static void cursor_channel_client_on_disconnect(RedChannelClient *rcc)
 {
     if (!rcc) {
@@ -9968,7 +9952,7 @@ static void red_disconnect_cursor(RedChannel *channel)
     ASSERT(channel == (RedChannel *)common->worker->cursor_channel);
     common->worker->cursor_channel = NULL;
     red_channel_apply_clients(channel, red_reset_cursor_cache);
-    red_disconnect_channel(channel);
+    red_channel_disconnect(channel);
 }
 
 static void red_migrate_cursor(RedWorker *worker, RedChannelClient *rcc)
@@ -10676,7 +10660,7 @@ void handle_dev_display_disconnect(void *opaque, void *payload)
 
     red_printf("disconnect display client");
     ASSERT(rcc);
-    display_channel_client_disconnect(rcc);
+    red_channel_client_disconnect(rcc);
 }
 
 void handle_dev_display_migrate(void *opaque, void *payload)
@@ -10725,7 +10709,7 @@ void handle_dev_cursor_disconnect(void *opaque, void *payload)
 
     red_printf("disconnect cursor client");
     ASSERT(rcc);
-    cursor_channel_client_disconnect(rcc);
+    red_channel_client_disconnect(rcc);
 }
 
 void handle_dev_cursor_migrate(void *opaque, void *payload)
commit a67268cbe1038126f00cec5a5330786b4b24a6cc
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:08 2012 -0600

    red_worker: rename epoll_timeout to event_timeout
    
    With future patches in mind that will allow for some other
    non-Linux-specific event polling sytem to be used, rename this to a more
    generic name. All of the select/poll/epoll/kqueue family of calls are
    related to evented I/O, so 'event_' makes sense in this case.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/server/red_worker.c b/server/red_worker.c
index 4c73952..7703363 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -232,7 +232,7 @@ double inline stat_byte_to_mega(uint64_t size)
 #endif
 
 #define MAX_EPOLL_SOURCES 10
-#define INF_EPOLL_WAIT ~0
+#define INF_EVENT_WAIT ~0
 
 
 typedef struct EventListener EventListener;
@@ -878,7 +878,7 @@ typedef struct RedWorker {
     int running;
     uint32_t *pending;
     int epoll;
-    unsigned int epoll_timeout;
+    unsigned int event_timeout;
     uint32_t repoll_cmd_ring;
     uint32_t repoll_cursor_ring;
     uint32_t num_renderers;
@@ -4658,7 +4658,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
             *ring_is_empty = TRUE;
             if (worker->repoll_cursor_ring < CMD_RING_POLL_RETRIES) {
                 worker->repoll_cursor_ring++;
-                worker->epoll_timeout = MIN(worker->epoll_timeout, CMD_RING_POLL_TIMEOUT);
+                worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
                 break;
             }
             if (worker->repoll_cursor_ring > CMD_RING_POLL_RETRIES ||
@@ -4713,7 +4713,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
             *ring_is_empty = TRUE;;
             if (worker->repoll_cmd_ring < CMD_RING_POLL_RETRIES) {
                 worker->repoll_cmd_ring++;
-                worker->epoll_timeout = MIN(worker->epoll_timeout, CMD_RING_POLL_TIMEOUT);
+                worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
                 break;
             }
             if (worker->repoll_cmd_ring > CMD_RING_POLL_RETRIES ||
@@ -4782,7 +4782,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
         if ((worker->display_channel &&
              red_channel_all_blocked(&worker->display_channel->common.base))
             || red_now() - start > 10 * 1000 * 1000) {
-            worker->epoll_timeout = 0;
+            worker->event_timeout = 0;
             return n;
         }
     }
@@ -7878,7 +7878,8 @@ static inline void display_channel_send_free_list(RedChannelClient *rcc)
         /* When using the urgent marshaller, the serial number of the message that is
          * going to be sent right after the SPICE_MSG_LIST, is increased by one.
          * But all this message pixmaps cache references used its old serial.
-         * we use pixmap_cache_items to collect these pixmaps, and we update their serial by calling pixmap_cache_hit.*/
+         * we use pixmap_cache_items to collect these pixmaps, and we update their serial
+         * by calling pixmap_cache_hit. */
         pixmap_cache_hit(dcc->pixmap_cache, dcc->send_data.pixmap_cache_items[i],
                          &dummy, dcc);
     }
@@ -11153,15 +11154,15 @@ void *red_worker_main(void *arg)
     red_init_lz(&worker);
     red_init_jpeg(&worker);
     red_init_zlib(&worker);
-    worker.epoll_timeout = INF_EPOLL_WAIT;
+    worker.event_timeout = INF_EVENT_WAIT;
     for (;;) {
         struct epoll_event events[MAX_EPOLL_SOURCES];
         int num_events;
         struct epoll_event *event;
         struct epoll_event *end;
 
-        worker.epoll_timeout = MIN(red_get_streams_timout(&worker), worker.epoll_timeout);
-        num_events = epoll_wait(worker.epoll, events, MAX_EPOLL_SOURCES, worker.epoll_timeout);
+        worker.event_timeout = MIN(red_get_streams_timout(&worker), worker.event_timeout);
+        num_events = epoll_wait(worker.epoll, events, MAX_EPOLL_SOURCES, worker.event_timeout);
         red_handle_streams_timout(&worker);
 
         if (worker.display_channel) {
@@ -11172,7 +11173,7 @@ void *red_worker_main(void *arg)
                 red_display_cc_free_glz_drawables);
         }
 
-        worker.epoll_timeout = INF_EPOLL_WAIT;
+        worker.event_timeout = INF_EVENT_WAIT;
         if (num_events == -1) {
             if (errno != EINTR) {
                 red_error("poll_wait failed, %s", strerror(errno));
commit 0e3ff74b849431fd0921138205f4205faecc682e
Author: Dan McGee <dpmcgee at gmail.com>
Date:   Thu Feb 16 23:30:07 2012 -0600

    Add configure-time check for -Wl, --version-script option
    
    This is supported by the GNU linker, but not the Solaris linker, which
    is used as the default on that platform even when compiling with GCC.
    Omit passing the option to the linker on platforms that do not support
    it.
    
    Signed-off-by: Dan McGee <dpmcgee at gmail.com>

diff --git a/configure.ac b/configure.ac
index 1c15e74..b8acfa9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,6 +518,16 @@ fi
 AC_MSG_RESULT($have_gcc4)
 AC_SUBST(VISIBILITY_HIDDEN_CFLAGS)
 
+dnl ensure linker supports ---version-script option before using it
+AC_CACHE_CHECK([if -Wl,--version-script works], [spice_cv_ld_version_script],
+    [save_LDFLAGS="$LDFLAGS"
+     LDFLAGS="$LDFLAGS -Wl,--version-script=$srcdir/server/spice-server.syms"
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+        [spice_cv_ld_version_script=yes], [spice_cv_ld_version_script=no])
+     LDFLAGS="$save_LDFLAGS"])
+AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
+    [test x"$spice_cv_ld_version_script" = xyes])
+
 AC_SUBST(SPICE_REQUIRES)
 AC_SUBST(SPICE_NONPKGCONFIG_CFLAGS)
 AC_SUBST(SPICE_NONPKGCONFIG_LIBS)
diff --git a/server/Makefile.am b/server/Makefile.am
index 1284704..a88e464 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -31,12 +31,16 @@ generated_marshallers.h: $(top_srcdir)/spice.proto
 
 lib_LTLIBRARIES = libspice-server.la
 
-libspice_server_la_LDFLAGS =						\
-	-version-number $(SPICE_LT_VERSION)				\
-	-Wl,--version-script=$(top_srcdir)/server/spice-server.syms	\
-	-no-undefined							\
+libspice_server_la_LDFLAGS =			\
+	-version-number $(SPICE_LT_VERSION)	\
+	-no-undefined				\
 	$(NULL)
 
+if HAVE_LD_VERSION_SCRIPT
+libspice_server_la_LDFLAGS += \
+	-Wl,--version-script=$(top_srcdir)/server/spice-server.syms
+endif
+
 libspice_server_la_LIBADD =				\
 	$(top_builddir)/common/libspice-common.la	\
 	$(CELT051_LIBS)					\


More information about the Spice-commits mailing list