correctly handle slowly-arriving incoming data
[beanstalkd.git] / srv.c
blob71f9608c621891b61e26fae3f06c1b57cdc92ef1
1 /* Copyright 2011 Keith Rarick
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "t.h"
18 #include <stdlib.h>
19 #include <sys/socket.h>
20 #include <event.h>
21 #include "dat.h"
24 void
25 srv(int fd)
27 int r;
29 r = listen(fd, 1024);
30 if (r == -1) {
31 twarn("listen");
32 return;
35 accept_handler = (evh)h_accept;
36 unbrake();
37 event_dispatch();
38 twarnx("event_dispatch error");
39 exit(1);