Fixes for listening socket
This commit is contained in:
parent
0a78c37078
commit
1831415fff
5
loop.c
5
loop.c
@ -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) {
|
|||||||
#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 ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user