Hi I have the following scenario, and want to verify the expected outcome
pthread_wrlock_rdlock(&(server->lock)); if (server->is_connected) { struct send_packets_args *send_packets_args; send_packets_args = malloc(sizeof (struct send_packets_args)); // Initialize send_packets_args to contain buffer to send, and length of buffer to send event_base_once(base, server->socket, EV_WRITE, send_packets, (void *) send_packets_args, NULL); pthread_wrlock_unlock(&(server->lock)); event_base_loop(base, EVLOOP_NONBLOCK); } else pthread_wrlock_unlock(&(server->lock)); In my callback after I'm done with the sending I perform the cleaning up (free the send_packets_args) Now my question, if at the moment I release my read lock above, the connection to the server is lost and server->socket is closed. Will the callback send_packets get called? I want to know the expected outcome because I need to make sure I'm not leaking memory allocated for the send_packets_args that gets freed as the final step of the send_packets callback. Thanks Regards Sherif.