src/server/daemon/event_solaris.c

Mon, 06 Mar 2017 17:32:26 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 06 Mar 2017 17:32:26 +0100
changeset 179
ef6827505bd2
parent 162
b169992137a8
child 193
aa8393527b1e
permissions
-rw-r--r--

merge srvctrl into default branch

29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e8619defde14 added event handler
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.
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e8619defde14 added event handler
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
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 #include <atomic.h>
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "event_solaris.h"
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 event_handler_t* evhandler_create(int numthreads) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 event_handler_t *ev = malloc(sizeof(event_handler_t));
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 if(ev == NULL) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 return NULL;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 ev->ports = calloc(numthreads, sizeof(int));
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 if(ev->ports == NULL) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 free(ev);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 return NULL;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 ev->nports = numthreads;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 ev->lp = 0;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 /* create ports event threads */
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 for(int i=0;i<numthreads;i++) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 /* create port */
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 ev->ports[i] = port_create();
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 if(ev->ports[i] == 0) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 free(ev->ports);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 free(ev);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 return NULL;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 /*
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 * start a new handler thread
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 * the thread needs the event port and a pointer to the event handler
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 */
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 ev_thr_conf_t *conf = malloc(sizeof(ev_thr_conf_t));
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 if(conf == NULL) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 free(ev->ports);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 free(ev);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 return NULL;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 conf->handler = ev;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 conf->port = ev->ports[i];
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
79
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
72 systhread_start(0, 0, (thrstartfunc)ev_handle_events, conf);
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
73 // TODO: error handling
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 return ev;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 void ev_handle_events(ev_thr_conf_t *conf) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 event_handler_t *ev = conf->handler;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 int port = conf->port;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 free(conf);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 port_event_t events[16];
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 struct timespec timeout;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 timeout.tv_nsec = 0;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 timeout.tv_sec = 600;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 for(;;) {
79
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
91 // wait for events
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 uint_t nev = 1;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 int ret = port_getn(port, events, 16, &nev, &timeout);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 if(ret == -1) {
79
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
95 // TODO: check for error
35
4417619a9bbd using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
96 perror("port_getn");
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 continue;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 for(int i=0;i<nev;i++) {
30
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
101 event_t *event = events[i].portev_user;
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 if(event->fn) {
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
103 int saved_ev = event->poll;
43
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
104 if(event->fn(ev, event)) {
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
105 /*
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
106 * on solaris we have to reassociate the fd after
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
107 * each event
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
108 * we do this if the event function returns 1
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
109 */
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
110
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
111 if(event->poll != saved_ev) {
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
112 // event type changed
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
113 int ne = 0;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
114 if((event->poll & EVENT_POLLIN) == EVENT_POLLIN) {
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
115 ne |= POLLIN;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
116 }
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
117 if((event->poll & EVENT_POLLOUT) == EVENT_POLLOUT) {
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
118 ne |= POLLOUT;
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
119 }
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
120 }
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
121
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
122 if(ev_poll(ev, event)) {
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
123 perror("port_associate");
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
124 }
46
636e05eb48f6 cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
125 } else if(event->finish) {
636e05eb48f6 cleaning up resources after requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
126 event->finish(ev, event);
43
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
127 }
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132
79
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 46
diff changeset
133 // returns a event handler port
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 int ev_get_port(event_handler_t *h) {
30
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
135 int nps = h->nports;
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
136 if(nps == 1) {
35
4417619a9bbd using non blocking IO for request input
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 30
diff changeset
137 return h->ports[0];
30
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
138 }
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
139
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
140 int cp = h->lp % nps;
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 atomic_inc_32(&h->lp);
30
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
142
27c7511c0e34 new proppatch, mkcol and delete method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 29
diff changeset
143 return h->ports[cp];
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 int ev_pollin(event_handler_t *h, int fd, event_t *event) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 event->object = (intptr_t)fd;
43
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
148 event->events = POLLIN;
133
87b405d61f64 improves event handler and ssl error handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
149 event->poll = EVENT_POLLIN;
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 return port_associate(
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 ev_get_port(h),
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 PORT_SOURCE_FD,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 (uintptr_t)fd,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 POLLIN,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 event);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 int ev_pollout(event_handler_t *h, int fd, event_t *event) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 event->object = (intptr_t)fd;
43
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
160 event->events = POLLOUT;
162
b169992137a8 improves cgi error handling and allows requests with empty headers
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 161
diff changeset
161 event->poll = EVENT_POLLOUT;
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 return port_associate(
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163 ev_get_port(h),
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 PORT_SOURCE_FD,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 (uintptr_t)fd,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 POLLOUT,
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 event);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 }
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169
43
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
170 int ev_poll(event_handler_t *h, event_t *event) {
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
171 return port_associate(
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
172 ev_get_port(h),
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
173 PORT_SOURCE_FD,
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
174 event->object,
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
175 event->events,
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
176 event);
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
177 }
8ac56edb4e94 fixed solaris build
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 35
diff changeset
178
29
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 int evt_send(event_handler_t *h, event_t *event) {
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 event->object = 0;
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 return port_send(ev_get_port(h), 0, event);
e8619defde14 added event handler
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 }

mercurial