1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

fix-revents-inherited-from-old-socket-bug.patch

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2010-11-12 11:47:39 +00:00
parent 47943ae82d
commit 85ba32fcbf
2 changed files with 17 additions and 6 deletions

View file

@ -169,7 +169,6 @@ libwebsocket_read(struct libwebsocket *wsi, unsigned char * buf, size_t len)
"conn user space\n");
goto bail;
}
fprintf(stderr, "user allocated %d at %p for wsi %p\n", wsi->protocol->per_session_data_size, wsi->user_space, wsi);
} else
wsi->user_space = NULL;

View file

@ -280,7 +280,7 @@ int libwebsocket_create_server(int port,
n = poll(fds, fds_count, 50);
if (n < 0 || fds[0].revents & (POLLERR | POLLHUP)) {
// fprintf(stderr, "Listen Socket dead\n");
fprintf(stderr, "Listen Socket dead\n");
goto fatal;
}
if (n == 0) /* poll timeout */
@ -379,6 +379,13 @@ int libwebsocket_create_server(int port,
fds[fds_count].events = POLLIN;
fds[fds_count++].fd = fd;
/*
* make sure NO events are seen yet on this new socket
* (otherwise we inherit old fds[client].revents from
* previous socket there and die mysteriously! )
*/
fds[client].revents = 0;
}
/* check for activity on client sockets */
@ -389,7 +396,8 @@ int libwebsocket_create_server(int port,
if (fds[client].revents & (POLLERR | POLLHUP)) {
fprintf(stderr, "Session Socket dead\n");
debug("Session Socket %d %p (fd=%d) dead\n",
client, wsi[client], fds[client]);
libwebsocket_close_and_free_session(
wsi[client]);
@ -429,12 +437,16 @@ int libwebsocket_create_server(int port,
* socket handle and wsi from our service list
*/
nuke_this:
for (n = client; n < fds_count - 1; n++) {
debug("nuking wsi %p, fsd_count = %d\n",
wsi[client], fds_count - 1);
fds_count--;
for (n = client; n < fds_count; n++) {
fds[n] = fds[n + 1];
wsi[n] = wsi[n + 1];
}
fds_count--;
client--;
break;
}
poll_out: