src/server/daemon/event_solaris.c

changeset 43
8ac56edb4e94
parent 35
4417619a9bbd
child 44
3da1f7b6847f
--- a/src/server/daemon/event_solaris.c	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/daemon/event_solaris.c	Tue Jan 01 14:02:25 2013 +0100
@@ -103,7 +103,16 @@
         for(int i=0;i<nev;i++) {
             event_t *event = events[i].portev_user;
             if(event->fn) {
-                event->fn(ev, event);
+                if(event->fn(ev, event)) {
+                    /*
+                     * on solaris we have to reassociate the fd after
+                     * each event
+                     * we do this if the event function returns 1
+                     */
+                     if(ev_poll(ev, event)) {
+                         perror("port_associate");
+                     }                 
+                }
             }
         }
     }
@@ -124,6 +133,7 @@
 
 int ev_pollin(event_handler_t *h, int fd, event_t *event) {
     event->object = (intptr_t)fd;
+    event->events = POLLIN;
     return port_associate(
             ev_get_port(h),
             PORT_SOURCE_FD,
@@ -134,6 +144,7 @@
 
 int ev_pollout(event_handler_t *h, int fd, event_t *event) {
     event->object = (intptr_t)fd;
+    event->events = POLLOUT;
     return port_associate(
             ev_get_port(h),
             PORT_SOURCE_FD,
@@ -142,6 +153,15 @@
             event);
 }
 
+int ev_poll(event_handler_t *h, event_t *event) {
+    return port_associate(
+            ev_get_port(h),
+            PORT_SOURCE_FD,
+            event->object,
+            event->events,
+            event);
+}
+
 int evt_send(event_handler_t *h, event_t *event) {
     event->object = 0;
     return port_send(ev_get_port(h), 0, event);

mercurial