src/server/daemon/event_solaris.c

changeset 133
87b405d61f64
parent 79
f48cea237ec3
child 153
85320d8b5d5c
equal deleted inserted replaced
132:e9afb5387007 133:87b405d61f64
98 } 98 }
99 99
100 for(int i=0;i<nev;i++) { 100 for(int i=0;i<nev;i++) {
101 event_t *event = events[i].portev_user; 101 event_t *event = events[i].portev_user;
102 if(event->fn) { 102 if(event->fn) {
103 int saved_ev = event->poll;
103 if(event->fn(ev, event)) { 104 if(event->fn(ev, event)) {
104 /* 105 /*
105 * on solaris we have to reassociate the fd after 106 * on solaris we have to reassociate the fd after
106 * each event 107 * each event
107 * we do this if the event function returns 1 108 * we do this if the event function returns 1
108 */ 109 */
109 if(ev_poll(ev, event)) { 110
110 perror("port_associate"); 111 if(event->poll != saved_ev) {
111 } 112 // event type changed
113 int ne = 0;
114 if((event->poll & EVENT_POLLIN) == EVENT_POLLIN) {
115 ne |= POLLIN;
116 }
117 if((event->poll & EVENT_POLLOUT) == EVENT_POLLOUT) {
118 ne |= POLLOUT;
119 }
120 }
121
122 if(ev_poll(ev, event)) {
123 perror("port_associate");
124 }
112 } else if(event->finish) { 125 } else if(event->finish) {
113 event->finish(ev, event); 126 event->finish(ev, event);
114 } 127 }
115 } 128 }
116 } 129 }
131 } 144 }
132 145
133 int ev_pollin(event_handler_t *h, int fd, event_t *event) { 146 int ev_pollin(event_handler_t *h, int fd, event_t *event) {
134 event->object = (intptr_t)fd; 147 event->object = (intptr_t)fd;
135 event->events = POLLIN; 148 event->events = POLLIN;
149 event->poll = EVENT_POLLIN;
136 return port_associate( 150 return port_associate(
137 ev_get_port(h), 151 ev_get_port(h),
138 PORT_SOURCE_FD, 152 PORT_SOURCE_FD,
139 (uintptr_t)fd, 153 (uintptr_t)fd,
140 POLLIN, 154 POLLIN,
142 } 156 }
143 157
144 int ev_pollout(event_handler_t *h, int fd, event_t *event) { 158 int ev_pollout(event_handler_t *h, int fd, event_t *event) {
145 event->object = (intptr_t)fd; 159 event->object = (intptr_t)fd;
146 event->events = POLLOUT; 160 event->events = POLLOUT;
161 event->poll EVENT_POLLOUT;
147 return port_associate( 162 return port_associate(
148 ev_get_port(h), 163 ev_get_port(h),
149 PORT_SOURCE_FD, 164 PORT_SOURCE_FD,
150 (uintptr_t)fd, 165 (uintptr_t)fd,
151 POLLOUT, 166 POLLOUT,

mercurial