summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfadhil riyanto <me@fadev.org>2024-09-29 11:11:17 +0700
committerfadhil riyanto <me@fadev.org>2024-09-29 11:11:17 +0700
commit45e9c0223b654c80df833d36533c9f2303a101e2 (patch)
tree13868e7c020d9336dcfa4cf3726252af67133882
parent62210bfeb3ed8977ad5048c8184665153182878b (diff)
add func that mark connection alive or not
Signed-off-by: fadhil riyanto <me@fadev.org>
-rw-r--r--main.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/main.c b/main.c
index c05d318..715a636 100644
--- a/main.c
+++ b/main.c
@@ -335,6 +335,18 @@ static struct sockaddr_in* get_by_fd_sockaddr(struct fd_sockaddr_list *fdsocklis
}
+static void mark_conn_inactive(struct fd_sockaddr_list *fdsocklist,
+ int fd_num)
+{
+ for(int i = 0; i < fdsocklist->size; i++) {
+ if (fdsocklist->list[i].is_active == 1 &&
+ fdsocklist->list[i].fd == fd_num) {
+
+ fdsocklist->list[i].is_active = 0;
+ }
+ }
+}
+
static pthread_t* init_get_pthread_arrptr(struct fd_sockaddr_list *fdsocklist,
int fd_num)
{
@@ -472,10 +484,16 @@ static void* start_private_conn(void* start_private_conn_details)
printf("thread xyz says: %s\n", tempbuf);
+ /* do on cleaner, parent thread
del_fd_sockaddr(srv_ctx->fd_sockaddr_list,
current_fd);
close(current_fd);
+ */
+
+ /* call when send error in future */
+ mark_conn_inactive(srv_ctx->fd_sockaddr_list,
+ current_fd);
}
static void* start_long_poll_receiver(void *srv_ctx_voidptr)
@@ -515,6 +533,8 @@ static void* start_long_poll_receiver(void *srv_ctx_voidptr)
printf("event available to read %d\n", n_ready_read);
}
+
+ /* todo: run cleaner here */
}
}