]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
libev can be used (but not multithreaded) and del fd unused.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Apr 2008 11:58:53 +0000 (11:58 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Apr 2008 11:58:53 +0000 (11:58 +0000)
git-svn-id: file:///svn/unbound/trunk@1023 be551aaa-1e26-0410-a405-d3ace91eadb9

configure
configure.ac
doc/Changelog
services/outside_network.c
services/outside_network.h
util/netevent.c
util/netevent.h

index 88ebc129981b166bf6513fc8c197e3778c28f03b..7adf3dca2329e9e7181cda2f497e4f8ae545e1b9 100755 (executable)
--- a/configure
+++ b/configure
@@ -21971,7 +21971,7 @@ echo $ECHO_N "checking for libevent... $ECHO_C" >&6; }
             fi
         done
         if test x_$found_libevent != x_yes; then
-               if test -f "$dir/event.h" -a -f "$dir/libevent.la"; then
+               if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
                        # libevent source directory
                        { echo "$as_me:$LINENO: result: found in $thedir" >&5
 echo "${ECHO_T}found in $thedir" >&6; }
@@ -21987,8 +21987,8 @@ echo "${ECHO_T}found in $thedir" >&6; }
                        cp $ev_files_o build/libevent
                        cp $ev_files_lo build/libevent
                        cp $ev_files_libso build/libevent/.libs
-                       LATE_LDFLAGS="build/libevent/*.lo"
-                       LDFLAGS="build/libevent/*.o $LDFLAGS"
+                       LATE_LDFLAGS="build/libevent/*.lo -lm"
+                       LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
                else
                        { { echo "$as_me:$LINENO: error: Cannot find the libevent library in $withval
 You can restart ./configure --with-libevent=no to use a builtin alternative.
index bcd25e59ff335088e4c107d57d0e4013ea7db5fd..1e38ce48ffd1c90b55d3fc60d35859d28c68fcc1 100644 (file)
@@ -520,7 +520,7 @@ if test x_$withval == x_yes -o x_$withval != x_no; then
             fi
         done
         if test x_$found_libevent != x_yes; then
-               if test -f "$dir/event.h" -a -f "$dir/libevent.la"; then
+               if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
                        # libevent source directory
                        AC_MSG_RESULT(found in $thedir)
                        CPPFLAGS="$CPPFLAGS -I$thedir"
@@ -535,8 +535,8 @@ if test x_$withval == x_yes -o x_$withval != x_no; then
                        cp $ev_files_o build/libevent
                        cp $ev_files_lo build/libevent
                        cp $ev_files_libso build/libevent/.libs
-                       LATE_LDFLAGS="build/libevent/*.lo"
-                       LDFLAGS="build/libevent/*.o $LDFLAGS"
+                       LATE_LDFLAGS="build/libevent/*.lo -lm"
+                       LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
                else
                        AC_MSG_ERROR([Cannot find the libevent library in $withval
 You can restart ./configure --with-libevent=no to use a builtin alternative.
index 9a737b17f567b275e6b0148c81e9c5598c3cb00d..d5f7ffbe3c8cb4ce035409afb3964c2ee3234951 100644 (file)
@@ -1,3 +1,9 @@
+9 April 2008: Wouter
+       - configure can detect libev(from its build directory) when passed
+         --with-libevent=/home/wouter/libev-3.2
+         libev-3.2 is a little faster than libevent-1.4.3-stable (about 5%).
+       - unused commpoints not listed in epoll list.
+
 8 April 2008: Wouter
        - unbound tries to set the ulimit fds when started as server.
          if that does not work, it will scale back its requirements.
index f69de0281c5efc66c69e111044ae4671f8877b07..713c2a512d47d4cfd0eb5224c62757a65ac31d3e 100644 (file)
@@ -275,6 +275,9 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error,
        (void)rbtree_delete(outnet->pending, p->node.key);
        fptr_ok(fptr_whitelist_pending_udp(p->cb));
        (void)(*p->cb)(p->c, p->cb_arg, NETEVENT_NOERROR, reply_info);
+       p->c->inuse--;
+       if(p->c->inuse == 0)
+               comm_point_stop_listening(p->c);
        pending_delete(NULL, p);
        return 0;
 }
@@ -367,8 +370,11 @@ make_udp_range(struct comm_point** coms, const char* ifname,
                }
                coms[done] = comm_point_create_udp(outnet->base, fd, 
                        outnet->udp_buff, outnet_udp_cb, outnet);
-               if(coms[done])
+               if(coms[done]) {
+                       log_assert(coms[done]->inuse == 0);
+                       comm_point_stop_listening(coms[done]);
                        done++;
+               }
        }
        return done;
 }
@@ -409,6 +415,9 @@ pending_udp_timer_cb(void *arg)
        verbose(VERB_ALGO, "timeout udp");
        fptr_ok(fptr_whitelist_pending_udp(p->cb));
        (void)(*p->cb)(p->c, p->cb_arg, NETEVENT_TIMEOUT, NULL);
+       p->c->inuse--;
+       if(p->c->inuse == 0)
+               comm_point_stop_listening(p->c);
        pending_delete(p->outnet, p);
 }
 
@@ -528,6 +537,9 @@ pending_node_del(rbnode_t* node, void* arg)
 {
        struct pending* pend = (struct pending*)node;
        struct outside_network* outnet = (struct outside_network*)arg;
+       pend->c->inuse--;
+       if(pend->c->inuse == 0)
+               comm_point_stop_listening(pend->c);
        pending_delete(outnet, pend);
 }
 
@@ -725,6 +737,9 @@ pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
                pending_delete(outnet, pend);
                return NULL;
        }
+       if(pend->c->inuse == 0)
+               comm_point_start_listening(pend->c, -1, -1);
+       pend->c->inuse++;
 
        /* system calls to set timeout after sending UDP to make roundtrip
           smaller. */
@@ -916,6 +931,9 @@ serviced_delete(struct serviced_query* sq)
                if(sq->status == serviced_query_UDP_EDNS ||
                        sq->status == serviced_query_UDP) {
                        struct pending* p = (struct pending*)sq->pending;
+                       p->c->inuse--;
+                       if(p->c->inuse == 0)
+                               comm_point_stop_listening(p->c);
                        pending_delete(sq->outnet, p);
                } else {
                        struct waiting_tcp* p = (struct waiting_tcp*)
index 7286a614c58395a8c8d9070fda3225fcb17123ff..b51fc5720a4aa1e3031cede32ebea2d25da53275 100644 (file)
@@ -79,6 +79,8 @@ struct outside_network {
         * Each is on a different port. This is for ip4 ports.
         */
        struct comm_point** udp4_ports;
+       /** number of queries open on each port */
+       int* udp4_inuse;
        /** number of udp4 ports */
        size_t num_udp4;
 
@@ -86,6 +88,8 @@ struct outside_network {
         * The opened ip6 ports.
         */
        struct comm_point** udp6_ports;
+       /** number of queries open on each port */
+       int* udp6_inuse;
        /** number of udp6 ports */
        size_t num_udp6;
 
index 58faa39b19f4fb079a4520b3a8706faaaeff384e..4e25f8741341997e443a51230c61a251903f0822 100644 (file)
@@ -850,6 +850,7 @@ comm_point_create_udp(struct comm_base *base, int fd, ldns_buffer* buffer,
        c->do_not_close = 0;
        c->tcp_do_toggle_rw = 0;
        c->tcp_check_nb_connect = 0;
+       c->inuse = 0;
        c->callback = callback;
        c->cb_arg = callback_arg;
        evbits = EV_READ | EV_PERSIST;
@@ -893,6 +894,7 @@ comm_point_create_udp_ancil(struct comm_base *base, int fd,
        c->type = comm_udp;
        c->tcp_do_close = 0;
        c->do_not_close = 0;
+       c->inuse = 0;
        c->tcp_do_toggle_rw = 0;
        c->tcp_check_nb_connect = 0;
        c->callback = callback;
index 299044a76c037212afbe429f5f74a7a44eb66e39..2a8644a0d3c3fc2e3f7e05f04e5b8bea668a27eb 100644 (file)
@@ -191,6 +191,10 @@ struct comm_point {
        /** if set, checks for pending error from nonblocking connect() call.*/
        int tcp_check_nb_connect;
 
+       /** number of queries outstanding on this socket, used by
+        * outside network for udp ports */
+       int inuse;
+
        /** callback when done.
            tcp_accept does not get called back, is NULL then.
            If a timeout happens, callback with timeout=1 is called.