XQuartz: Don't forget to destroy the mutex and cond after we're done with them
This commit is contained in:
parent
dd0f8a0f59
commit
c3558bb8cd
|
@ -203,15 +203,15 @@ static void socket_handoff_thread(void *arg) {
|
||||||
fprintf(stderr, "Failed to create socket: %s - %s\n", filename, strerror(errno));
|
fprintf(stderr, "Failed to create socket: %s - %s\n", filename, strerror(errno));
|
||||||
|
|
||||||
data->retval = EXIT_FAILURE;
|
data->retval = EXIT_FAILURE;
|
||||||
pthread_mutex_unlock(&data->lock);
|
|
||||||
pthread_cond_broadcast(&data->cond);
|
pthread_cond_broadcast(&data->cond);
|
||||||
|
pthread_mutex_unlock(&data->lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let the dispatch thread now tell the caller that we're ready */
|
/* Let the dispatch thread now tell the caller that we're ready */
|
||||||
data->retval = EXIT_SUCCESS;
|
data->retval = EXIT_SUCCESS;
|
||||||
pthread_mutex_unlock(&data->lock);
|
|
||||||
pthread_cond_broadcast(&data->cond);
|
pthread_cond_broadcast(&data->cond);
|
||||||
|
pthread_mutex_unlock(&data->lock);
|
||||||
|
|
||||||
if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
|
if(connect(handoff_fd, servaddr, servaddr_len) < 0) {
|
||||||
fprintf(stderr, "Failed to connect to socket: %s - %s\n", filename, strerror(errno));
|
fprintf(stderr, "Failed to connect to socket: %s - %s\n", filename, strerror(errno));
|
||||||
|
@ -227,6 +227,7 @@ static void socket_handoff_thread(void *arg) {
|
||||||
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
|
kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
|
||||||
handoff_data_t handoff_data;
|
handoff_data_t handoff_data;
|
||||||
|
|
||||||
|
/* Initialize our data */
|
||||||
pthread_mutex_init(&handoff_data.lock, NULL);
|
pthread_mutex_init(&handoff_data.lock, NULL);
|
||||||
pthread_cond_init(&handoff_data.cond, NULL);
|
pthread_cond_init(&handoff_data.cond, NULL);
|
||||||
strlcpy(handoff_data.socket_filename, socket_filename, STRING_T_SIZE);
|
strlcpy(handoff_data.socket_filename, socket_filename, STRING_T_SIZE);
|
||||||
|
@ -235,7 +236,13 @@ kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
|
||||||
|
|
||||||
create_thread(socket_handoff_thread, &handoff_data);
|
create_thread(socket_handoff_thread, &handoff_data);
|
||||||
|
|
||||||
|
/* Wait for our return value */
|
||||||
pthread_cond_wait(&handoff_data.cond, &handoff_data.lock);
|
pthread_cond_wait(&handoff_data.cond, &handoff_data.lock);
|
||||||
|
pthread_mutex_unlock(&handoff_data.lock);
|
||||||
|
|
||||||
|
/* Cleanup */
|
||||||
|
pthread_cond_destroy(&handoff_data.cond);
|
||||||
|
pthread_mutex_destroy(&handoff_data.lock);
|
||||||
|
|
||||||
return handoff_data.retval;
|
return handoff_data.retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user