Seems better by now -> TODO cleanup

This commit is contained in:
Ano-sys
2025-02-07 18:33:46 +01:00
parent f856a4fa82
commit 097ca6a6d3
208 changed files with 135393 additions and 639928 deletions
+9 -9
View File
@@ -65,7 +65,7 @@ TYPE get_request_type(const char *request){
void* workerFunc(void *args){
if(!args){
// perror("[THREAD] Invalid arguments");
perror("[THREAD] Invalid arguments");
return NULL;
}
int port = *(int*)args;
@@ -73,26 +73,26 @@ void* workerFunc(void *args){
void *context = zmq_ctx_new();
if(!context){
// perror("[THREAD] Failed to create context");
perror("[THREAD] Failed to create context");
return NULL;
}
void *responder = zmq_socket(context, ZMQ_REP);
if(!responder){
// perror("[THREAD] Failed to create socket");
perror("[THREAD] Failed to create socket");
zmq_ctx_destroy(context);
return NULL;
}
int timeout = SEND_RECV_TIMEOUT;
zmq_setsockopt(responder, ZMQ_RCVTIMEO, &timeout, sizeof(timeout));
zmq_setsockopt(responder, ZMQ_SNDTIMEO, &timeout, sizeof(timeout));
// int timeout = SEND_RECV_TIMEOUT;
// zmq_setsockopt(responder, ZMQ_RCVTIMEO, &timeout, sizeof(timeout));
// zmq_setsockopt(responder, ZMQ_SNDTIMEO, &timeout, sizeof(timeout));
char addr[22];
snprintf(addr, sizeof(addr), "tcp://localhost:%d", port);
int rc = zmq_bind(responder, addr);
if(rc != 0){
// perror("Failed to connect");
perror("Failed to connect");
zmq_close(responder);
zmq_ctx_destroy(context);
return NULL;
@@ -105,7 +105,7 @@ void* workerFunc(void *args){
char request[MESSAGE_LENGTH] = {0};
int bytes_recv = zmq_recv(responder, request, MESSAGE_LENGTH, 0);
if(bytes_recv < 3){ // minimal receive is TYPE
// perror("Failed to receive valid request");
perror("[THREAD] Failed to receive valid request");
continue;
}
@@ -144,7 +144,7 @@ void* workerFunc(void *args){
// fprintf(stderr, "Sending content: %s\n", ret);
if(zmq_send(responder, ret, strlen(ret) + 1, 0) < 0){
// perror("Failed to send response");
perror("[THREAD] Failed to send response");
zmq_close(responder);
zmq_ctx_destroy(context);
}