Fixed memory leak, freed things properly, and rearranged some things

This commit is contained in:
2022-07-01 08:48:05 -05:00
parent d843ffab93
commit ad88090956
2 changed files with 35 additions and 11 deletions

View File

@@ -102,12 +102,13 @@ void runServer(int connfd, Sitefile *site, int *pending, int id,
continue;
remove:
freeConnection(connections + i);
connCount--;
--connCount;
memcpy(fds + i, fds + connCount - 1,
sizeof(struct pollfd));
memcpy(connections + i, fds + connCount,
sizeof(struct pollfd));
pending[id]--;
--pending[id];
--i;
}
if (fds[0].revents & POLLIN) {