Fixed connection removal
This commit is contained in:
17
src/runner.c
17
src/runner.c
@@ -98,14 +98,22 @@ void runServer(int connfd, Sitefile *site, volatile int *pending, int id) {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
remove:
|
remove:
|
||||||
freeConnection(connections + i);
|
{
|
||||||
--connCount;
|
int remove, replace;
|
||||||
memcpy(fds + i, fds + connCount - 1,
|
remove = i;
|
||||||
|
replace = connCount - 1;
|
||||||
|
freeConnection(connections + remove);
|
||||||
|
|
||||||
|
memcpy(fds + remove, fds + replace,
|
||||||
sizeof(struct pollfd));
|
sizeof(struct pollfd));
|
||||||
memcpy(connections + i, fds + connCount,
|
memcpy(connections + remove, fds + replace,
|
||||||
sizeof(struct pollfd));
|
sizeof(struct pollfd));
|
||||||
|
|
||||||
--pending[id];
|
--pending[id];
|
||||||
|
|
||||||
--i;
|
--i;
|
||||||
|
--connCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fds[0].revents & POLLIN) {
|
if (fds[0].revents & POLLIN) {
|
||||||
@@ -123,6 +131,7 @@ remove:
|
|||||||
if (newstream == NULL) {
|
if (newstream == NULL) {
|
||||||
createLog(
|
createLog(
|
||||||
"Stream couldn't be created from file descriptor");
|
"Stream couldn't be created from file descriptor");
|
||||||
|
shutdown(newfd, SHUT_RDWR);
|
||||||
close(newfd);
|
close(newfd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user