Index: trunk/loreley/src/loreley/net_unix.cc |
— | — | @@ -132,40 +132,6 @@ |
133 | 133 | |
134 | 134 | static void sig_exit(int, short, void *); |
135 | 135 | |
136 | | -ioloop_t *ioloop; |
137 | | - |
138 | | -char current_time_str[30]; |
139 | | -char current_time_short[30]; |
140 | | -time_t current_time; |
141 | | - |
142 | | -static void secondly_sched(void); |
143 | | - |
144 | | -bool wnet_exit; |
145 | | -vector<wsocket *> awaks; |
146 | | -size_t cawak; |
147 | | - |
148 | | -void |
149 | | -wnet_add_accept_wakeup(wsocket *s) |
150 | | -{ |
151 | | - awaks.push_back(s); |
152 | | -} |
153 | | - |
154 | | -net::event secondly_ev; |
155 | | - |
156 | | -static void |
157 | | -secondly_update(void) |
158 | | -{ |
159 | | - WDEBUG("secondly_update"); |
160 | | - wnet_set_time(); |
161 | | - secondly_sched(); |
162 | | -} |
163 | | - |
164 | | -static void |
165 | | -secondly_sched(void) |
166 | | -{ |
167 | | - secondly_ev.schedule(secondly_update, 1000); |
168 | | -} |
169 | | - |
170 | 136 | pthread_cond_t iot_ready; |
171 | 137 | pthread_mutex_t iot_ready_m; |
172 | 138 | |
— | — | @@ -194,13 +160,6 @@ |
195 | 161 | return NULL; |
196 | 162 | } |
197 | 163 | |
198 | | - |
199 | | - |
200 | | -ioloop_t::ioloop_t(void) |
201 | | -{ |
202 | | - prepare(); |
203 | | -} |
204 | | - |
205 | 164 | void |
206 | 165 | ioloop_t::prepare(void) |
207 | 166 | { |
— | — | @@ -238,63 +197,8 @@ |
239 | 198 | } |
240 | 199 | wlog.notice(format("net: initialised, using libevent %s (%s)") |
241 | 200 | % event_get_version() % event_get_method()); |
242 | | - secondly_sched(); |
243 | 201 | } |
244 | 202 | |
245 | | -void |
246 | | -ioloop_t::_accept(wsocket *s, int) |
247 | | -{ |
248 | | - wsocket *newe; |
249 | | -static rate_limited_logger enfile_log(60, ll_warn, "accept error: %s"); |
250 | | - |
251 | | - if ((newe = s->accept("HTTP client", prio_norm)) == NULL) { |
252 | | - if (errno == ENFILE || errno == EMFILE) |
253 | | - enfile_log.log(strerror(errno)); |
254 | | - else |
255 | | - wlog.warn(format("accept error: %s") % strerror(errno)); |
256 | | - s->readback(bind(&ioloop_t::_accept, this, _1, _2), -1); |
257 | | - return; |
258 | | - } |
259 | | - |
260 | | - s->readback(bind(&ioloop_t::_accept, this, _1, _2), -1); |
261 | | - |
262 | | - newe->nonblocking(true); |
263 | | - |
264 | | - if (cawak == awaks.size()) |
265 | | - cawak = 0; |
266 | | -char buf[sizeof(wsocket *) * 2]; |
267 | | - memcpy(buf, &newe, sizeof(newe)); |
268 | | - memcpy(buf + sizeof(newe), &s, sizeof(s)); |
269 | | - WDEBUG(format("_accept, lsnr=%d") % s); |
270 | | - |
271 | | - if (awaks[cawak]->write(buf, sizeof(wsocket *) * 2) < 0) { |
272 | | - wlog.error(format("writing to thread wakeup socket: %s") |
273 | | - % strerror(errno)); |
274 | | - exit(1); |
275 | | - } |
276 | | - cawak++; |
277 | | - return; |
278 | | -} |
279 | | - |
280 | | -void |
281 | | -wnet_set_time(void) |
282 | | -{ |
283 | | -struct tm *now; |
284 | | - time_t old = current_time; |
285 | | - size_t n; |
286 | | - |
287 | | - current_time = time(NULL); |
288 | | - if (current_time == old) |
289 | | - return; |
290 | | - |
291 | | - now = gmtime(¤t_time); |
292 | | - |
293 | | - n = strftime(current_time_str, sizeof(current_time_str), "%a, %d %b %Y %H:%M:%S GMT", now); |
294 | | - assert(n); |
295 | | - n = strftime(current_time_short, sizeof(current_time_short), "%Y-%m-%d %H:%M:%S", now); |
296 | | - assert(n); |
297 | | -} |
298 | | - |
299 | 203 | namespace net { |
300 | 204 | |
301 | 205 | void |