fixed solaris build

Tue, 01 Jan 2013 14:02:25 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 01 Jan 2013 14:02:25 +0100
changeset 43
8ac56edb4e94
parent 42
cb9c63c1edee
child 44
3da1f7b6847f

fixed solaris build

make/linux.mk file | annotate | diff | comparison | revisions
make/solaris.mk file | annotate | diff | comparison | revisions
make/suncc.mk file | annotate | diff | comparison | revisions
src/server/Makefile file | annotate | diff | comparison | revisions
src/server/daemon/event.h file | annotate | diff | comparison | revisions
src/server/daemon/event_linux.c file | annotate | diff | comparison | revisions
src/server/daemon/event_solaris.c file | annotate | diff | comparison | revisions
src/server/daemon/event_solaris.h file | annotate | diff | comparison | revisions
src/server/util/atomic.h file | annotate | diff | comparison | revisions
--- a/make/linux.mk	Tue Jan 01 13:42:58 2013 +0100
+++ b/make/linux.mk	Tue Jan 01 14:02:25 2013 +0100
@@ -29,7 +29,7 @@
 
 # compiler and linker flags
 
-
+LDFLAGS = 
 
 
 # platform dependend source files
--- a/make/solaris.mk	Tue Jan 01 13:42:58 2013 +0100
+++ b/make/solaris.mk	Tue Jan 01 14:02:25 2013 +0100
@@ -29,7 +29,7 @@
 
 # compiler and linker flags
 
-
+LDFLAGS = -lsocket -lsendfile
 
 
 # platform dependend source files
--- a/make/suncc.mk	Tue Jan 01 13:42:58 2013 +0100
+++ b/make/suncc.mk	Tue Jan 01 14:02:25 2013 +0100
@@ -28,4 +28,7 @@
 
 CFLAGS = -xc99
 
+CC  = cc
+CXX = CC
+LD = cc
 
--- a/src/server/Makefile	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/Makefile	Tue Jan 01 14:02:25 2013 +0100
@@ -29,7 +29,7 @@
 BUILD_ROOT = ../..
 include $(BUILD_ROOT)/config.mk
 
-LDFLAGS = -pg -lpthread -ldl -lnsl -lm -lxerces-c -lldap
+LDFLAGS += -pg -lpthread -ldl -lnsl -lm -lxerces-c -lldap
 
 OBJ_DIR = $(BUILD_ROOT)/build/
 
--- a/src/server/daemon/event.h	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/daemon/event.h	Tue Jan 01 14:02:25 2013 +0100
@@ -47,6 +47,7 @@
     Request      *rq;
     event_func   fn;
     intptr_t     object;
+    int          events;
     void         *cookie;
 };
 
--- a/src/server/daemon/event_linux.c	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/daemon/event_linux.c	Tue Jan 01 14:02:25 2013 +0100
@@ -113,7 +113,7 @@
             if(event->fn) {
                 if(!event->fn(ev, event)) {
                     // event fn returned 0 -> remove event from epoll
-                    if(epoll_ctl(ep, EPOLL_CTL_DEL, event->object, NULL) != 0){
+                    if(epoll_ctl(ep, EPOLL_CTL_DEL, event->object, NULL)) {
                         perror("epoll_ctl");
                     }
                 }
--- 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);
--- a/src/server/daemon/event_solaris.h	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/daemon/event_solaris.h	Tue Jan 01 14:02:25 2013 +0100
@@ -54,6 +54,7 @@
 
 int ev_get_port(event_handler_t *h);
 
+int ev_poll(event_handler_t *h, event_t *event);
 
 #ifdef	__cplusplus
 }
--- a/src/server/util/atomic.h	Tue Jan 01 13:42:58 2013 +0100
+++ b/src/server/util/atomic.h	Tue Jan 01 14:02:25 2013 +0100
@@ -44,8 +44,8 @@
 // use atomic.h
 #include <atomic.h>
 
-#define ws_atomic_inc32(intptr) ucx_atomic_dec_32_nv(intptr)
-#define ws_atomic_dec32(intptr) ucx_atomic_dec_32_nv(intptr)
+#define ws_atomic_inc32(intptr) atomic_dec_32_nv(intptr)
+#define ws_atomic_dec32(intptr) atomic_dec_32_nv(intptr)
 // TODO
 
 #endif

mercurial