~ubuntu-branches/ubuntu/hardy/lighttpd/hardy-updates

« back to all changes in this revision

Viewing changes to src/fdevent_select.c

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2006-12-08 14:40:42 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061208144042-3z5kr9pe0kya5lgu
Tags: 1.4.13-6ubuntu1
* Merge from debian unstable, remaining changes:
  - Replace Depends: on perl with Depends: on libterm-readline-perl-perl

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
                FD_SET(fd, &(ev->select_set_write));
50
50
        }
51
51
        FD_SET(fd, &(ev->select_set_error));
52
 
        
 
52
 
53
53
        if (fd > ev->select_max_fd) ev->select_max_fd = fd;
54
 
        
 
54
 
55
55
        return fd;
56
56
}
57
57
 
58
58
static int fdevent_select_poll(fdevents *ev, int timeout_ms) {
59
59
        struct timeval tv;
60
 
        
 
60
 
61
61
        tv.tv_sec =  timeout_ms / 1000;
62
62
        tv.tv_usec = (timeout_ms % 1000) * 1000;
63
 
        
 
63
 
64
64
        ev->select_read = ev->select_set_read;
65
65
        ev->select_write = ev->select_set_write;
66
66
        ev->select_error = ev->select_set_error;
67
 
        
 
67
 
68
68
        return select(ev->select_max_fd + 1, &(ev->select_read), &(ev->select_write), &(ev->select_error), &tv);
69
69
}
70
70
 
71
71
static int fdevent_select_event_get_revent(fdevents *ev, size_t ndx) {
72
72
        int revents = 0;
73
 
        
 
73
 
74
74
        if (FD_ISSET(ndx, &(ev->select_read))) {
75
75
                revents |= FDEVENT_IN;
76
76
        }
80
80
        if (FD_ISSET(ndx, &(ev->select_error))) {
81
81
                revents |= FDEVENT_ERR;
82
82
        }
83
 
        
 
83
 
84
84
        return revents;
85
85
}
86
86
 
92
92
 
93
93
static int fdevent_select_event_next_fdndx(fdevents *ev, int ndx) {
94
94
        int i;
95
 
        
 
95
 
96
96
        i = (ndx < 0) ? 0 : ndx + 1;
97
 
        
 
97
 
98
98
        for (; i < ev->select_max_fd + 1; i++) {
99
99
                if (FD_ISSET(i, &(ev->select_read))) break;
100
100
                if (FD_ISSET(i, &(ev->select_write))) break;
101
101
                if (FD_ISSET(i, &(ev->select_error))) break;
102
102
        }
103
 
        
 
103
 
104
104
        return i;
105
105
}
106
106
 
108
108
        ev->type = FDEVENT_HANDLER_SELECT;
109
109
#define SET(x) \
110
110
        ev->x = fdevent_select_##x;
111
 
        
 
111
 
112
112
        SET(reset);
113
113
        SET(poll);
114
 
        
 
114
 
115
115
        SET(event_del);
116
116
        SET(event_add);
117
 
        
 
117
 
118
118
        SET(event_next_fdndx);
119
119
        SET(event_get_fd);
120
120
        SET(event_get_revent);
121
 
        
 
121
 
122
122
        return 0;
123
123
}
124
124