]> granicus.if.org Git - libevent/commitdiff
devpoll support
authorNiels Provos <provos@gmail.com>
Fri, 30 Jul 2004 04:57:21 +0000 (04:57 +0000)
committerNiels Provos <provos@gmail.com>
Fri, 30 Jul 2004 04:57:21 +0000 (04:57 +0000)
svn:r113

Makefile.am
configure.in
event.c
test/regress.c
test/test.sh

index 8989b9c00403742e9df689df80d993316d5828bb..2cfb03cec7b0bceca487cd76e6aaca06e1063b6d 100644 (file)
@@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
 SUBDIRS = . sample test
 
 EXTRA_DIST = acconfig.h err.c event.h evsignal.h event.3 kqueue.c \
-       epoll_sub.c epoll.c select.c rtsig.c poll.c signal.c \
+       epoll_sub.c epoll.c select.c rtsig.c poll.c signal.c devpoll.c \
        sample/Makefile.am sample/Makefile.in sample/event-test.c \
        sample/signal-test.c sample/time-test.c \
        test/Makefile.am test/Makefile.in test/bench.c test/regress.c \
index fca0a544a5608a057ca113bdfba0107ae478fabf..697372977cce495ea46a2bc29b3eaf9766ad50ae 100644 (file)
@@ -2,7 +2,7 @@ dnl configure.in for libevent
 dnl Dug Song <dugsong@monkey.org>
 AC_INIT(event.c)
 
-AM_INIT_AUTOMAKE(libevent,0.8)
+AM_INIT_AUTOMAKE(libevent,0.9)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
@@ -33,7 +33,7 @@ AC_CHECK_LIB(socket, socket)
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/ioctl.h)
+AC_CHECK_HEADERS(stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/ioctl.h sys/devpoll.h)
 if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
        AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
        AC_EGREP_CPP(yes,
@@ -143,6 +143,13 @@ if test "x$haveepoll" = "xyes" ; then
        needsignal=yes
 fi
 
+havedevpoll=no
+if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then
+       AC_DEFINE(HAVE_DEVPOLL, 1,
+                   [Define if /dev/poll is available])
+        AC_LIBOBJ(devpoll)
+fi
+
 havekqueue=no
 if test "x$ac_cv_header_sys_event_h" = "xyes"; then
        AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
diff --git a/event.c b/event.c
index 8be1ac743c648f8e3453a995c4a12bb8401d8bbf..66cf8a6a57b0944a342e524019ccc583e347cd6a 100644 (file)
--- a/event.c
+++ b/event.c
@@ -76,6 +76,9 @@ extern const struct eventop epollops;
 #ifdef HAVE_WORKING_KQUEUE
 extern const struct eventop kqops;
 #endif
+#ifdef HAVE_DEVPOLL
+extern const struct eventop devpollops;
+#endif
 #ifdef WIN32
 extern const struct eventop win32ops;
 #endif
@@ -88,6 +91,9 @@ const struct eventop *eventops[] = {
 #ifdef HAVE_EPOLL
        &epollops,
 #endif
+#ifdef HAVE_DEVPOLL
+       &devpollops,
+#endif
 #ifdef HAVE_RTSIG
        &rtsigops,
 #endif
index 19eda980567bbfffc560a1cfa2233dbb265b3ed5..7adffff36abc04e61ee793c28c392cdbe059ef95 100644 (file)
@@ -75,8 +75,10 @@ simple_read_cb(int fd, short event, void *arg)
        len = read(fd, buf, sizeof(buf));
 
        if (len) {
-               if (!called)
-                       event_add(arg, NULL);
+               if (!called) {
+                       if (event_add(arg, NULL) == -1)
+                               exit(1);
+               }
        } else if (called == 1)
                test_ok = 1;
 
@@ -122,8 +124,10 @@ multiple_write_cb(int fd, short event, void *arg)
                return;
        }
 
-       if (!usepersist)
-               event_add(ev, NULL);
+       if (!usepersist) {
+               if (event_add(ev, NULL) == -1)
+                       exit(1);
+       }
 }
 
 void
@@ -142,8 +146,10 @@ multiple_read_cb(int fd, short event, void *arg)
        }
 
        roff += len;
-       if (!usepersist)
-               event_add(ev, NULL);
+       if (!usepersist) {
+               if (event_add(ev, NULL) == -1) 
+                       exit(1);
+       }
 }
 
 void
@@ -194,7 +200,8 @@ combined_read_cb(int fd, short event, void *arg)
                return;
 
        both->nread += len;
-       event_add(&both->ev, NULL);
+       if (event_add(&both->ev, NULL) == -1)
+               exit(1);
 }
 
 void
@@ -217,7 +224,8 @@ combined_write_cb(int fd, short event, void *arg)
        }
 
        both->nread -= len;
-       event_add(&both->ev, NULL);
+       if (event_add(&both->ev, NULL) == -1)
+               exit(1);
 }
 
 /* Test infrastructure */
@@ -278,7 +286,8 @@ test1(void)
        shutdown(pair[0], SHUT_WR);
 
        event_set(&ev, pair[1], EV_READ, simple_read_cb, &ev);
-       event_add(&ev, NULL);
+       if (event_add(&ev, NULL) == -1)
+               exit(1);
        event_dispatch();
 
        cleanup_test();
@@ -293,7 +302,8 @@ test2(void)
        setup_test("Simple write: ");
        
        event_set(&ev, pair[0], EV_WRITE, simple_write_cb, &ev);
-       event_add(&ev, NULL);
+       if (event_add(&ev, NULL) == -1)
+               exit(1);
        event_dispatch();
 
        cleanup_test();
@@ -315,9 +325,11 @@ test3(void)
        usepersist = 0;
 
        event_set(&ev, pair[0], EV_WRITE, multiple_write_cb, &ev);
-       event_add(&ev, NULL);
+       if (event_add(&ev, NULL) == -1)
+               exit(1);
        event_set(&ev2, pair[1], EV_READ, multiple_read_cb, &ev2);
-       event_add(&ev2, NULL);
+       if (event_add(&ev2, NULL) == -1)
+               exit(1);
        event_dispatch();
 
        if (roff == woff)
@@ -342,9 +354,11 @@ test4(void)
        usepersist = 1;
 
        event_set(&ev, pair[0], EV_WRITE|EV_PERSIST, multiple_write_cb, &ev);
-       event_add(&ev, NULL);
+       if (event_add(&ev, NULL) == -1)
+               exit(1);
        event_set(&ev2, pair[1], EV_READ|EV_PERSIST, multiple_read_cb, &ev2);
-       event_add(&ev2, NULL);
+       if (event_add(&ev2, NULL) == -1)
+               exit(1);
        event_dispatch();
 
        if (roff == woff)
@@ -371,10 +385,14 @@ test5(void)
        event_set(&w1.ev, pair[0], EV_WRITE, combined_write_cb, &w1);
        event_set(&r2.ev, pair[1], EV_READ, combined_read_cb, &r2);
        event_set(&w2.ev, pair[1], EV_WRITE, combined_write_cb, &w2);
-       event_add(&r1.ev, NULL);
-       event_add(&w1.ev, NULL);
-       event_add(&r2.ev, NULL);
-       event_add(&w2.ev, NULL);
+       if (event_add(&r1.ev, NULL) == -1)
+               exit(1);
+       if (event_add(&w1.ev, NULL))
+               exit(1);
+       if (event_add(&r2.ev, NULL))
+               exit(1);
+       if (event_add(&w2.ev, NULL))
+               exit(1);
 
        event_dispatch();
 
index f76dc2a7048a4d671474d594ac3da21a632131f6..d23c1fac4c720cacb8db1eba8157fc97290c29bb 100755 (executable)
@@ -2,6 +2,7 @@
 
 setup () {
         export EVENT_NOKQUEUE=yes
+        export EVENT_NODEVPOLL=yes
         export EVENT_NOPOLL=yes
         export EVENT_NOSELECT=yes
         export EVENT_NOEPOLL=yes
@@ -53,6 +54,11 @@ unset EVENT_NOKQUEUE
 echo "KQUEUE"
 test
 
+setup
+unset EVENT_NODEVPOLL
+echo "DEVPOLL"
+test
+
 setup
 unset EVENT_NOPOLL
 echo "POLL"