Diff for /embedaddon/lighttpd/src/fdevent.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2014/06/15 20:20:06 version 1.1.1.3, 2016/11/02 10:35:00
Line 1 Line 1
   #include "first.h"
   
 #include "base.h"  #include "base.h"
 #include "log.h"  #include "log.h"
   
Line 16  fdevents *fdevent_init(server *srv, size_t maxfds, fde Line 18  fdevents *fdevent_init(server *srv, size_t maxfds, fde
         fdevents *ev;          fdevents *ev;
   
         ev = calloc(1, sizeof(*ev));          ev = calloc(1, sizeof(*ev));
           force_assert(NULL != ev);
         ev->srv = srv;          ev->srv = srv;
         ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray));          ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray));
           force_assert(NULL != ev->fdarray);
         ev->maxfds = maxfds;          ev->maxfds = maxfds;
   
         switch(type) {          switch(type) {
Line 107  static fdnode *fdnode_init(void) { Line 111  static fdnode *fdnode_init(void) {
         fdnode *fdn;          fdnode *fdn;
   
         fdn = calloc(1, sizeof(*fdn));          fdn = calloc(1, sizeof(*fdn));
           force_assert(NULL != fdn);
         fdn->fd = -1;          fdn->fd = -1;
         return fdn;          return fdn;
 }  }
Line 136  int fdevent_unregister(fdevents *ev, int fd) { Line 141  int fdevent_unregister(fdevents *ev, int fd) {
         if (!ev) return 0;          if (!ev) return 0;
         fdn = ev->fdarray[fd];          fdn = ev->fdarray[fd];
   
         force_assert(fdn->events == 0);  
   
         fdnode_free(fdn);          fdnode_free(fdn);
   
         ev->fdarray[fd] = NULL;          ev->fdarray[fd] = NULL;
Line 145  int fdevent_unregister(fdevents *ev, int fd) { Line 148  int fdevent_unregister(fdevents *ev, int fd) {
         return 0;          return 0;
 }  }
   
int fdevent_event_del(fdevents *ev, int *fde_ndx, int fd) {void fdevent_event_del(fdevents *ev, int *fde_ndx, int fd) {
        int fde = fde_ndx ? *fde_ndx : -1;        if (-1 == fd) return;
         if (NULL == ev->fdarray[fd]) return;
   
        if (NULL == ev->fdarray[fd]) return 0;        if (ev->event_del) *fde_ndx = ev->event_del(ev, *fde_ndx, fd);
 
        if (ev->event_del) fde = ev->event_del(ev, fde, fd); 
         ev->fdarray[fd]->events = 0;          ev->fdarray[fd]->events = 0;
   }
   
        if (fde_ndx) *fde_ndx = fde;void fdevent_event_set(fdevents *ev, int *fde_ndx, int fd, int events) {
         if (-1 == fd) return;
   
        return 0;        /*(Note: skips registering with kernel if initial events is 0,
          * so caller should pass non-zero events for initial registration.
          * If never registered due to never being called with non-zero events,
          * then FDEVENT_HUP or FDEVENT_ERR will never be returned.) */
         if (ev->fdarray[fd]->events == events) return;/*(no change; nothing to do)*/
 
         if (ev->event_set) *fde_ndx = ev->event_set(ev, *fde_ndx, fd, events);
         ev->fdarray[fd]->events = events;
 }  }
   
int fdevent_event_set(fdevents *ev, int *fde_ndx, int fd, int events) {void fdevent_event_add(fdevents *ev, int *fde_ndx, int fd, int event) {
        int fde = fde_ndx ? *fde_ndx : -1;        int events;
         if (-1 == fd) return;
   
        if (ev->event_set) fde = ev->event_set(ev, fde, fd, events);        events = ev->fdarray[fd]->events;
         if ((events & event) || 0 == event) return; /*(no change; nothing to do)*/
 
         events |= event;
         if (ev->event_set) *fde_ndx = ev->event_set(ev, *fde_ndx, fd, events);
         ev->fdarray[fd]->events = events;          ev->fdarray[fd]->events = events;
   }
   
        if (fde_ndx) *fde_ndx = fde;void fdevent_event_clr(fdevents *ev, int *fde_ndx, int fd, int event) {
         int events;
         if (-1 == fd) return;
   
        return 0;        events = ev->fdarray[fd]->events;
         if (!(events & event)) return; /*(no change; nothing to do)*/
 
         events &= ~event;
         if (ev->event_set) *fde_ndx = ev->event_set(ev, *fde_ndx, fd, events);
         ev->fdarray[fd]->events = events;
 }  }
   
 int fdevent_poll(fdevents *ev, int timeout_ms) {  int fdevent_poll(fdevents *ev, int timeout_ms) {

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>