Add TODOs

This commit is contained in:
Night Kaly 2024-09-21 15:41:36 +01:00
parent c67915a41c
commit 380a8deb31
Signed by: night0721
GPG key ID: 957D67B8DB7A119B
2 changed files with 5 additions and 1 deletions

View file

@ -112,6 +112,7 @@ void *receive_worker(void *arg)
} else { } else {
/* Terminate decrypted data so we don't print random bytes */ /* Terminate decrypted data so we don't print random bytes */
decrypted[data_len] = '\0'; decrypted[data_len] = '\0';
/* TODO: Use mutext before add messgae */
add_message(from, to, decrypted, data_len, time(NULL)); add_message(from, to, decrypted, data_len, time(NULL));
show_chat(from); show_chat(from);
send_notification(from, decrypted); send_notification(from, decrypted);

View file

@ -104,6 +104,7 @@ void *thread_worker(void *arg)
while (1) { while (1) {
int num_events = epoll_wait(thread->epoll_fd, events, MAX_EVENTS, -1); int num_events = epoll_wait(thread->epoll_fd, events, MAX_EVENTS, -1);
if (num_events == -1) { if (num_events == -1) {
/* TODO: pthread exit? */
error(0, "epoll_wait"); error(0, "epoll_wait");
} }
for (int i = 0; i < num_events; i++) { for (int i = 0; i < num_events; i++) {
@ -111,11 +112,12 @@ void *thread_worker(void *arg)
if (events[i].events & EPOLLIN) { if (events[i].events & EPOLLIN) {
/* Handle packet */ /* Handle packet */
/* TODO: Mutex lock when handle packet */
packet_t pkt; packet_t pkt;
int status = verify_packet(&pkt, client->fd); int status = verify_packet(&pkt, client->fd);
if (status != ZSM_STA_SUCCESS) { if (status != ZSM_STA_SUCCESS) {
if (status == ZSM_STA_CLOSED_CONNECTION) { if (status == ZSM_STA_CLOSED_CONNECTION) {
/* TODO: Remove client from thread */ /* TODO: Remove client from thread, epollctldel, close fd */
error(0, "Client closed connection"); error(0, "Client closed connection");
} else { } else {
error(0, "Error verifying packet"); error(0, "Error verifying packet");
@ -221,6 +223,7 @@ int main(int argc, char **argv)
/* Assign new client to a thread /* Assign new client to a thread
* TODO: Loop everythread to see which client is unintialised * TODO: Loop everythread to see which client is unintialised
* TODO: Use mutex before add client
* Clients distributed by a rotation(round-robin) * Clients distributed by a rotation(round-robin)
*/ */
thread_t *thread = &threads[num_thread]; thread_t *thread = &threads[num_thread];