fix hashmap

This commit is contained in:
2024-11-10 18:15:53 +01:00
parent f1612dad0f
commit 454daa148e
3 changed files with 69 additions and 14 deletions

View File

@@ -78,7 +78,7 @@ void handle_clients(int sockfd) {
setnonblocking(client_fd);
epoll_ctl_add(epfd, client_fd, EPOLLIN);
hm_insert(clients, client_fd, &their_sa);
hm_push(clients, client_fd, &their_sa);
int bytes_sent = send(client_fd, msg, msg_len, 0);
fprintf(stdout, "[server] Sent %d bytes\n", bytes_sent);
@@ -113,9 +113,13 @@ void handle_clients(int sockfd) {
free(revents);
close(epfd);
/* Close all the file descriptors */
for (size_t i = 0; i < HASHMAP_MAX_CLIENTS; ++i) {
close(clients[i].sockfd);
/* TODO: close collisions */
}
hm_free(clients);
}
void epoll_ctl_add(int epfd, int sockfd, uint32_t events) {