src/server/daemon/event_linux.c

Fri, 01 Nov 2024 12:25:52 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 01 Nov 2024 12:25:52 +0100
changeset 562
69fc4ecc5f60
parent 552
4ed0e46aa9dc
permissions
-rw-r--r--

fix pgext uses a wrong field number, if the column has the same name as a resource or property column

41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
44
3da1f7b6847f added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 43
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <errno.h>
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <sys/epoll.h>
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
33 #include <sys/eventfd.h>
552
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
34 #include <signal.h>
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
36 #include <cx/array_list.h>
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
37 #include <cx/linked_list.h>
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
38
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "../util/systhr.h"
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "../util/atomic.h"
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
42 #include "../util/io.h"
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #include "event.h"
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 #include "event_linux.h"
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
531
9b15b1f72bef change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 529
diff changeset
47 #include "httprequest.h"
9b15b1f72bef change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 529
diff changeset
48
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
50 EVHandler* evhandler_create(EventHandlerConfig *cfg) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
51 EVHandler *ev = malloc(sizeof(EVHandler));
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
52 ev->current = 0;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
53 ev->instances = calloc(cfg->nthreads, sizeof(void*));
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
54 ev->numins = cfg->nthreads;
443
ef3c8a0e1fee improve daemon startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
55
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
56 for(int i=0;i<cfg->nthreads;i++) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
57 EventHandlerLinux *handler = malloc(sizeof(EventHandlerLinux));
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
58 memset(handler, 0, sizeof(EventHandlerLinux));
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
59 ev->instances[i] = (EventHandler*)handler;
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
60
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
61 handler->ep = epoll_create(64);
443
ef3c8a0e1fee improve daemon startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
62 if(handler->ep < 0) {
ef3c8a0e1fee improve daemon startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
63 log_ereport(LOG_FAILURE, "evhandler_create: epoll_create: %s", strerror(errno));
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
64 return NULL;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
65 }
192
6a145e13d933 replaces eventfd with pipe and closes aio branch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
66
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
67 handler->event_fd = eventfd(0, EFD_NONBLOCK);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
68 if(handler->event_fd < 0) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
69 log_ereport(LOG_FAILURE, "evhandler_create: eventfd: %s", strerror(errno));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
70 return NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
71 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
72
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
73 EventQueue *queue = malloc(sizeof(EventQueue));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
74 if(!queue) {
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
75 return NULL;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
76 }
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
77 queue->numevents = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
78 queue->next = NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
79 handler->queue_begin = queue;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
80 handler->queue_end = queue;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
81 handler->num_reserve = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
82
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
83 if(pthread_mutex_init(&handler->queue_lock, NULL)) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
84 log_ereport(LOG_FAILURE, "evhandler_create: cannot initialize mutex");
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
85 return NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
86 }
192
6a145e13d933 replaces eventfd with pipe and closes aio branch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
87
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
88 struct epoll_event epev;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
89 epev.events = EPOLLIN | EPOLLET; // input event, edge triggered
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
90 epev.data.ptr = NULL;
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
91 if(epoll_ctl(handler->ep, EPOLL_CTL_ADD, handler->event_fd, &epev)) {
474
eb7640c59e9b fix broken log_ereport call
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 443
diff changeset
92 log_ereport(LOG_FAILURE, "evhandler_create: epoll_ctl: %s", strerror(errno));
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 return NULL;
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95
552
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
96 handler->thr = systhread_start(
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
97 0,
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
98 0,
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
99 (thrstartfunc)ev_handle_events,
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
100 handler);
443
ef3c8a0e1fee improve daemon startup
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 193
diff changeset
101 }
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 return ev;
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105
552
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
106 void ev_instance_wait(EventHandler *h) {
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
107 EventHandlerLinux *ev = (EventHandlerLinux*)h;
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
108 void *ret;
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
109 pthread_join(ev->thr, &ret);
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
110 }
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
111
547
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
112 static volatile int ev_close = 0;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
113
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
114 void ev_instance_close(EventHandler *h) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
115 EventHandlerLinux *ev = (EventHandlerLinux*)h;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
116 ev_close = 1;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
117 close(ev->ep);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
118 }
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
119
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
120 // unique event addr that indicates shutdown
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
121 static Event shutdown_event;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
122 void ev_instance_shutdown(EventHandler *h) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
123 event_send(h, &shutdown_event);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
124 }
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
125
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
126 void ev_handle_events(EventHandlerLinux *ev) {
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
127 EventHandler *h = (EventHandler*)ev;
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
128 int ep = ev->ep;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
130 struct epoll_event events[EV_MAX_EVENTS];
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
131 Event* finished[EV_MAX_EVENTS];
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
133 size_t queue_len = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
134
543
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
135 int loop_ctn = 0;
547
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
136 int ev_shutdown = 0;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
137 while(!ev_shutdown) {
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
138 // if ev->event_queue contains events, we process them first
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
139 // otherwise we get events from epoll
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
140 int ret = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
141 if(queue_len > 0) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
142 pthread_mutex_lock(&ev->queue_lock);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
143
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
144 EventQueue *queue = ev->queue_begin;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
145 queue_len = queue->numevents;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
146
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
147 // queue_len cannot be bigger than EV_MAX_EVENTS
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
148 // get events from the queue
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
149 for(int i=0;i<queue_len;i++) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
150 events[i].events = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
151 events[i].data.ptr = queue->events[i];
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
152 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
153
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
154 queue->numevents = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
155 if(queue->next) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
156 ev->queue_begin = ev->queue_begin->next;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
157
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
158 // more than 1 queue block available, remove first block
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
159 if(ev->num_reserve < EV_QUEUE_RESERVE) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
160 ev->reserve_block[ev->num_reserve++] = queue;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
161 queue->next = NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
162 } else {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
163 free(queue);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
164 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
165 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
166
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
167 ret = queue_len;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
168 queue_len = ev->queue_begin->numevents;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
169
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
170 pthread_mutex_unlock(&ev->queue_lock);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
171 } else {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
172 // wait for events
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
173 ret = epoll_wait(ep, events, EV_MAX_EVENTS, EV_IDLE_TIMEOUT * 1000);
547
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
174 if(ret == -1) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
175 if(errno != EINTR) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
176 if(!ev_close) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
177 log_ereport(LOG_CATASTROPHE, "epoll_wait failed: %s", strerror(errno));
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
178 }
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
179 break;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
180 }
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
181 continue;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
182 }
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 }
543
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
184
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
185 int numfinished = 0;
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
186 ev->base.numret = 0;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 for(int i=0;i<ret;i++) {
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
188 Event *event = events[i].data.ptr;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
189 if(!event) {
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
190 // the only epoll_event without Event ptr is from eventfd
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
191
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
192 uint64_t eventfd_r = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
193 ssize_t r = read(ev->event_fd, &eventfd_r, sizeof(uint64_t));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
194 if(r > 0) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
195 queue_len = eventfd_r;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
196 } else {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
197 log_ereport(LOG_FAILURE, "eventhandler: eventfd read failed: %s", strerror(errno));
192
6a145e13d933 replaces eventfd with pipe and closes aio branch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
198 }
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
199
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
200 continue;
533
2d6099ba2a7c simplify ev_handle_events on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 531
diff changeset
201 }
2d6099ba2a7c simplify ev_handle_events on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 531
diff changeset
202
2d6099ba2a7c simplify ev_handle_events on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 531
diff changeset
203 if(event->fn) {
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
204 int saved_ev = event->events;
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
205 if(!event->fn(h, event)) {
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 // event fn returned 0 -> remove event from epoll
542
1327febf99c4 refactore keep alive handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 541
diff changeset
207 if(saved_ev && epoll_ctl(ep, EPOLL_CTL_DEL, event->object, NULL)) {
152
8b85c5face66 improves sessionhandler logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 133
diff changeset
208 event->error = 1;
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
209 log_ereport(
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
210 LOG_FAILURE,
152
8b85c5face66 improves sessionhandler logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 133
diff changeset
211 "epoll_ctl failed: fd: %d error: %s",
8b85c5face66 improves sessionhandler logging
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 133
diff changeset
212 event->object,
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
213 strerror(errno));
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 }
46
636e05eb48f6 cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
215
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
216 // if set, remember this event and
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
217 // execute event->finish later
46
636e05eb48f6 cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
218 if(event->finish) {
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
219 finished[numfinished++] = event;
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
220 //event->finish(ev, event);
46
636e05eb48f6 cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
221 }
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
222 } else {
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
223 if(saved_ev != event->events) {
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
224 // event type changed
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
225 struct epoll_event epev;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
226 epev.events = EPOLLET;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
227 epev.data.ptr = event;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
228
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
229 // adjust epoll events
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
230 epev.events = ev_convert2sys_events(event->events);
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
231
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
232 if(epoll_ctl(ep, EPOLL_CTL_MOD, event->object, &epev)) {
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
233 log_ereport(
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
234 LOG_FAILURE,
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
235 "epoll_wait failed: %s",
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
236 strerror(errno));
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
237 }
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 126
diff changeset
238 }
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 }
547
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
240 } else if(event == &shutdown_event) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
241 ev_instance_close(h);
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 }
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
244 // call event finish handlers
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
245 for(int i=0;i<numfinished;i++) {
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
246 Event *event = finished[i];
537
ad44e72fbf50 add extra nullptr check in the event loop to handle the case when the finish ptr is set to NULL after it was already scheduled
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 533
diff changeset
247 // check again if the finish callback is set
ad44e72fbf50 add extra nullptr check in the event loop to handle the case when the finish ptr is set to NULL after it was already scheduled
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 533
diff changeset
248 if(finished[i]->finish) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
249 finished[i]->finish(h, event);
537
ad44e72fbf50 add extra nullptr check in the event loop to handle the case when the finish ptr is set to NULL after it was already scheduled
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 533
diff changeset
250 }
529
cd606400f0ba change execution order of event handler and event finish functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
251 }
531
9b15b1f72bef change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 529
diff changeset
252 // execute return calls
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
253 for(int i=0;i<ev->base.numret;i++) {
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
254 EVReturn ret = ev->base.fnreturn[i];
531
9b15b1f72bef change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 529
diff changeset
255 nsapi_saf_return(ret.sn, ret.rq, ret.ret);
9b15b1f72bef change nsapi_function_return behavior: move saf return to the end of the event cycle
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 529
diff changeset
256 }
543
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
257
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
258 if(ret == 0 || ++loop_ctn >= EV_IDLE_LOOP_CTN) {
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
259 watchlist_check(&ev->base, 0);
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
260 loop_ctn = 0;
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
261 }
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 }
552
4ed0e46aa9dc add test for sending multiple events to an eventhandler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 547
diff changeset
263
547
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
264 // epoll fd is already closed
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
265
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
266 ev_queue_free(ev->queue_begin);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
267 pthread_mutex_destroy(&ev->queue_lock);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
268 close(ev->event_fd);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
269 free(ev);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
270 }
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
271
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
272 void ev_queue_free(EventQueue *queue) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
273 while(queue) {
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
274 EventQueue *next = queue->next;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
275 free(queue);
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
276 queue = next;
280bf87c8689 add functions to stop event handlers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 545
diff changeset
277 }
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
280 int ev_convert2sys_events(int events) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
281 int e = EPOLLET;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
282 if((events & EVENT_POLLIN) == EVENT_POLLIN) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
283 e |= EPOLLIN;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 }
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
285 if((events & EVENT_POLLOUT) == EVENT_POLLOUT) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
286 e |= EPOLLOUT;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
287 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
288 return e;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
291 int ev_pollin(EventHandler *h, int fd, Event *event) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
292 EventHandlerLinux *ev = (EventHandlerLinux*)h;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 event->object = (intptr_t)fd;
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
294 event->events = EVENT_POLLIN;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 struct epoll_event epev;
543
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
296 epev.events = EPOLLIN | EPOLLRDHUP | EPOLLET; // input event, edge triggered
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 epev.data.ptr = event;
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
298 return epoll_ctl(ev->ep, EPOLL_CTL_ADD, fd, &epev);
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
301 int ev_pollout(EventHandler *h, int fd, Event *event) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
302 EventHandlerLinux *ev = (EventHandlerLinux*)h;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 event->object = (intptr_t)fd;
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
304 event->events = EVENT_POLLOUT;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 struct epoll_event epev;
543
3335f431a91b implement keep-alive timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 542
diff changeset
306 epev.events = EPOLLOUT | EPOLLRDHUP | EPOLLET; // input event, edge triggered
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 epev.data.ptr = event;
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
308 return epoll_ctl(ev->ep, EPOLL_CTL_ADD, fd, &epev);
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
309 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
310
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
311 int ev_remove_poll(EventHandler *h, int fd) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
312 EventHandlerLinux *ev = (EventHandlerLinux*)h;
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
313 return epoll_ctl(ev->ep, EPOLL_CTL_DEL, fd, NULL);
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
314 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
315
187
4384bfbb7e26 adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
316 int event_send(EventHandler *h, Event *event) {
541
1e1fca11aaff refactore EventHandler: add common fields to base struct
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 537
diff changeset
317 EventHandlerLinux *ev = (EventHandlerLinux*)h;
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
318 event->object = 0;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
319 event->events = 0;
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
320
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
321 int err = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
322 pthread_mutex_lock(&ev->queue_lock);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
323
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
324 // add event to the last block
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
325 EventQueue *block = ev->queue_end;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
326 if(block->numevents >= EV_MAX_EVENTS) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
327 // last block is full
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
328 // create a new block or just use a reserved block
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
329 if(ev->num_reserve > 0) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
330 block = ev->reserve_block[ev->num_reserve-1];
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
331 ev->num_reserve--;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
332 } else {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
333 block = malloc(sizeof(EventQueue));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
334 if(!block) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
335 block = NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
336 err = 1;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
337 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
338 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
339
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
340 if(block) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
341 ev->queue_end->next = block;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
342 ev->queue_end = block;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
343
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
344 block->numevents = 0;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
345 block->next = NULL;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
346 }
192
6a145e13d933 replaces eventfd with pipe and closes aio branch
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 187
diff changeset
347 }
545
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
348
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
349 if(block) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
350 block->events[block->numevents++] = event;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
351 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
352
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
353
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
354 pthread_mutex_unlock(&ev->queue_lock);
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
355
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
356 if(!err) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
357 uint64_t data = 1;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
358 ssize_t r = write(ev->event_fd, &data, sizeof(uint64_t));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
359 if(r == 0) {
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
360 log_ereport(LOG_FAILURE, "eventhandler: failed to send event: %s", strerror(errno));
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
361 err = 1;
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
362 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
363 }
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
364
720893ec7d48 new linux event_send implementation, replace event pipes with eventfd
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 543
diff changeset
365 return err;
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 }
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
368 // TODO: remove this fake aio
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
369 int ev_aioread(int fd, aiocb_s *cb) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
370 ssize_t result = pread(fd, cb->buf, cb->nbytes, cb->offset);
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
371 cb->result = result;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
372 if(result < 0) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
373 cb->result_errno = errno;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
374 }
187
4384bfbb7e26 adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
375 return event_send(cb->evhandler, cb->event);
41
bb7a1f5a8b48 added Linux support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 }
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
377
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
378 int ev_aiowrite(int fd, aiocb_s *cb) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
379 ssize_t result = pwrite(fd, cb->buf, cb->nbytes, cb->offset);
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
380 cb->result = result;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
381 if(result < 0) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
382 cb->result_errno = errno;
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
383 }
187
4384bfbb7e26 adds platform independent aio functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 185
diff changeset
384 return event_send(cb->evhandler, cb->event);
185
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
385 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
386
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
387
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
388 int event_pollin(EventHandler *ev, SYS_NETFD fd, Event *event) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
389 return ((IOStream*)fd)->poll(fd, ev, IO_POLL_IN, event);
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
390 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
391
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
392 int event_pollout(EventHandler *ev, SYS_NETFD fd, Event *event) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
393 return ((IOStream*)fd)->poll(fd, ev, IO_POLL_OUT, event);
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
394 }
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
395
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
396 int event_removepoll(EventHandler *ev, SYS_NETFD fd) {
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
397 return ((IOStream*)fd)->poll(fd, ev, IO_POLL_NONE, NULL);
b4d7ccf4e06d implements new event handler and aio on linux
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 152
diff changeset
398 }

mercurial