]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
manpage , fd-setsize for minievent.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Feb 2007 09:52:46 +0000 (09:52 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 21 Feb 2007 09:52:46 +0000 (09:52 +0000)
git-svn-id: file:///svn/unbound/trunk@134 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/unbound.8
util/mini_event.c
util/mini_event.h

index cc3c26d6a43e960c4137863f08e3cc06599e5b70..96f53ccb49e0406658e8512e763e332089f24454 100644 (file)
@@ -1,3 +1,7 @@
+21 February 2007: Wouter
+       - put -c option in man page.
+       - minievent fd array capped by FD_SETSIZE.
+
 20 February 2007: Wouter
        - Added locks code and pthread spinlock detection.
        - can use no locks, or solaris native thread library.
index d347f429dfee2b69c06644972ea2ce53dc4b11e8..af4cecff4a0916ced56bcd4f0b7a24e629fea58b 100644 (file)
@@ -41,6 +41,7 @@ unbound
 .Sh SYNOPSIS
 .Nm unbound
 .Op Fl h
+.Op Fl c Ar cfgfile
 .Op Fl p Ar port
 .Op Fl f Ar ip
 .Op Fl z Ar port
@@ -57,6 +58,11 @@ The available options are:
 .It Fl h
 Show the version and commandline option help.
 
+.It Fl c Ar cfgfile
+Set the config file to read with settings for unbound. The syntax is
+described in 
+.Xr unbound.conf 5 .
+
 .It Fl p Ar port
 Start listening on the given port. Default is port 53(DNS).
 
@@ -71,7 +77,8 @@ Increase verbosity. If given multiple times, more information is logged.
 
 .El
 .Sh SEE ALSO
-.Xr resolv.conf 5
+.Xr resolv.conf 5 ,
+.Xr unbound.conf 5 .
 
 .Sh AUTHORS
 .Ic Unbound
index b1578a93570fef394a71cbf642ced539d51e9867..0335433af53c63e49d731e92715096790199979b 100644 (file)
@@ -79,7 +79,12 @@ void *event_init(void)
                event_base_free(base);
                return NULL;
        }
-       base->fds = (struct event**)calloc(MAX_FDS, sizeof(struct event*));
+       base->capfd = MAX_FDS;
+#ifdef FD_SETSIZE
+       if((int)FD_SETSIZE < base->capfd)
+               base->capfd = (int)FD_SETSIZE;
+#endif
+       base->fds = (struct event**)calloc(base->capfd, sizeof(struct event*));
        if(!base->fds) {
                event_base_free(base);
                return NULL;
@@ -239,7 +244,7 @@ int event_add(struct event* ev, struct timeval* tv)
 {
        if(ev->added)
                event_del(ev);
-       if(ev->ev_fd != -1 && ev->ev_fd >= MAX_FDS)
+       if(ev->ev_fd != -1 && ev->ev_fd >= ev->ev_base->capfd)
                return -1;
        if( (ev->ev_events&(EV_READ|EV_WRITE)) && ev->ev_fd != -1) {
                ev->ev_base->fds[ev->ev_fd] = ev;
@@ -264,7 +269,7 @@ int event_add(struct event* ev, struct timeval* tv)
 /** remove event, you may change it again */
 int event_del(struct event* ev)
 {
-       if(ev->ev_fd != -1 && ev->ev_fd >= MAX_FDS)
+       if(ev->ev_fd != -1 && ev->ev_fd >= ev->ev_base->capfd)
                return -1;
        if(ev->ev_events&EV_TIMEOUT)
                (void)rbtree_delete(ev->ev_base->times, &ev->node);
index a02c0d361e8b078de090732e7141dd5ace6452f0..0cfd5377833f2503cf5e973ca0e959768e8b9c67 100644 (file)
  * \file
  * This file implements part of the event(3) libevent api.
  * The back end is only select. Max number of fds is limited.
+ * Max number of signals is limited, one handler per signal only.
+ * And one handler per fd.
+ *
+ * Although limited to select() and a max (1024) open fds, it
+ * is efficient:
+ * o dispatch call caches fd_sets to use. 
+ * o handler calling takes time ~ to the number of fds.
+ * o timeouts are stored in a redblack tree, sorted, so take log(n).
+ * Timeouts are only accurate to the second (no subsecond accuracy).
+ * To avoid cpu hogging, fractional timeouts are rounded up to a whole second.
  */
 
 #ifndef MINI_EVENT_H
@@ -76,6 +86,8 @@ struct event_base
        struct event** fds;
        /** max fd in use */
        int maxfd;
+       /** capacity - size of the fds array */
+       int capfd;
        /** fdset for read write */
        fd_set reads, writes;
        /** array of 0 - maxsig of ptr to event for it */
@@ -95,9 +107,9 @@ struct event {
 
        /** event base it belongs to */
        struct event_base *ev_base;
-       /** fd to poll or -1 for timeouts */
+       /** fd to poll or -1 for timeouts. signal number for sigs. */
        int ev_fd;
-       /** events this event is interested in */
+       /** what events this event is interested in, see EV_.. above. */
        short ev_events;
        /** timeout value */
        struct timeval ev_timeout;
@@ -123,7 +135,7 @@ int event_base_loopexit(struct event_base *, struct timeval *);
 void event_base_free(struct event_base *);
 /** set content of event */
 void event_set(struct event *, int, short, void (*)(int, short, void *), void *);
-/** add event to a base */
+/** add event to a base. You *must* call this for every event. */
 int event_base_set(struct event_base *, struct event *);
 /** add event to make it active. You may not change it with event_set anymore */
 int event_add(struct event *, struct timeval *);
@@ -133,7 +145,8 @@ int event_del(struct event *);
 #define evtimer_add(ev, tv)             event_add(ev, tv)
 #define evtimer_del(ev)                 event_del(ev)
 
-/* uses different implementation. Cannot mix fd/timeouts and signals. */
+/* uses different implementation. Cannot mix fd/timeouts and signals inside
+ * the same struct event. create several event structs for that.  */
 /** install signal handler */
 int signal_add(struct event *, struct timeval *);
 /** set signal event contents */