Removed double free, improved error checking

This commit is contained in:
2022-07-02 12:12:22 -05:00
parent 6db24d8ab6
commit ddd62990b3
7 changed files with 53 additions and 35 deletions

View File

@@ -97,8 +97,11 @@ void runServer(int connfd, Sitefile *site, int *pending, int id,
}
for (i = 1; i < connCount; i++) {
if (updateConnection(connections + i, site))
goto remove;
if (fds[i].revents & POLLIN) {
createFormatLog("Connection %d has data", i);
if (updateConnection(connections + i, site))
goto remove;
}
continue;
remove:
freeConnection(connections + i);
@@ -115,6 +118,7 @@ remove:
Stream *newstream;
int newfd;
int portind;
createLog("Main fd has data");
newfd = recvFd(connfd);
if (newfd < 0) {
createLog("Message received that included an invalid fd, quitting");