Commit 1831415f authored by vvaltman's avatar vvaltman

Fixes for listening socket

parent 0a78c370
...@@ -633,11 +633,12 @@ static void event_incoming (struct bufferevent *bev, short what, void *_arg) { ...@@ -633,11 +633,12 @@ static void event_incoming (struct bufferevent *bev, short what, void *_arg) {
close (ev->fd); close (ev->fd);
bufferevent_free (bev); bufferevent_free (bev);
ev->bev = 0; ev->bev = 0;
ev->refcnt --; if (!--ev->refcnt) { free (ev); }
} }
} }
static void accept_incoming (evutil_socket_t efd, short what, void *arg) { static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
vlogprintf (E_WARNING, "Accepting incoming connection\n");
unsigned clilen; unsigned clilen;
struct sockaddr_in cli_addr; struct sockaddr_in cli_addr;
int fd = accept (sfd, (struct sockaddr *)&cli_addr, &clilen); int fd = accept (sfd, (struct sockaddr *)&cli_addr, &clilen);
...@@ -682,7 +683,7 @@ int loop (void) { ...@@ -682,7 +683,7 @@ int loop (void) {
#endif #endif
if (sfd >= 0) { if (sfd >= 0) {
struct event *ev = event_new (tgl_state.ev_base, sfd, EV_READ, accept_incoming, 0); struct event *ev = event_new (tgl_state.ev_base, sfd, EV_READ | EV_PERSIST, accept_incoming, 0);
event_add (ev, 0); event_add (ev, 0);
} }
update_prompt (); update_prompt ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment