diff --git a/src/guacd/proc.c b/src/guacd/proc.c index d9e92cacf7..3da138d328 100644 --- a/src/guacd/proc.c +++ b/src/guacd/proc.c @@ -151,7 +151,7 @@ static void* guacd_user_thread(void* data) { * * @param proc * The process that the user is being added to. - + * @param handle * The handle associated with the user's connection to guacd. * @@ -279,33 +279,16 @@ static void* guacd_client_free_thread(void* data) { guacd_client_free* free_operation = (guacd_client_free*) data; - FILE* the_file = fopen("./guacd_client_free_thread.txt","a+"); - fprintf(the_file, "In guacd_client_free_thread\n"); - fclose(the_file); - /* Attempt to free client (this may never return if the client is * malfunctioning) */ guac_client_free(free_operation->client); - the_file = fopen("./guacd_client_free_thread.txt","a+"); - fprintf(the_file, "In guacd_client_free_thread, did guac_client_free()\n"); - fclose(the_file); - /* Signal that the client was successfully freed */ pthread_mutex_lock(&free_operation->completed_mutex); free_operation->completed = 1; - - the_file = fopen("./guacd_client_free_thread.txt","a+"); - fprintf(the_file, "In guacd_client_free_thread, set completed=1\n"); - fclose(the_file); - pthread_cond_broadcast(&free_operation->completed_cond); pthread_mutex_unlock(&free_operation->completed_mutex); - the_file = fopen("./guacd_client_free_thread.txt","a+"); - fprintf(the_file, "Done with guacd_client_free_thread\n"); - fclose(the_file); - return NULL; } @@ -355,14 +338,13 @@ static int guacd_timed_client_free(guac_client* client, int timeout) { return 1; /* Free the client in a separate thread, so we can time the free operation */ - int the_return = pthread_create(&client_free_thread, NULL, - guacd_client_free_thread, &free_operation); - - if (!the_return) + if (!pthread_create(&client_free_thread, NULL, + guacd_client_free_thread, &free_operation)) { /* Wait a finite amount of time for the free operation to finish */ (void) pthread_cond_timedwait(&free_operation.completed_cond, &free_operation.completed_mutex, &deadline); + } (void) pthread_mutex_unlock(&free_operation.completed_mutex); @@ -442,7 +424,7 @@ static void guacd_exec_proc(guacd_proc* proc, const char* protocol) { struct sigaction signal_stop_action = { .sa_handler = signal_stop_handler }; sigaction(SIGINT, &signal_stop_action, NULL); sigaction(SIGTERM, &signal_stop_action, NULL); - + #ifdef WINDOWS_BUILD /* Add each received file handle as a new user */ @@ -465,7 +447,7 @@ static void guacd_exec_proc(guacd_proc* proc, const char* protocol) { owner = 0; } - + cleanup_client: /* Request client to stop/disconnect */ @@ -488,11 +470,8 @@ static void guacd_exec_proc(guacd_proc* proc, const char* protocol) { /* Verify whether children were all properly reaped */ pid_t child_pid; while ((child_pid = waitpid(0, NULL, WNOHANG)) > 0) { - guacd_log(GUAC_LOG_DEBUG, "Automatically reaped unreaped " - "(zombie) child process with PID %i.", - child_pid); - + "(zombie) child process with PID %i.", child_pid); } /* If running children remain, warn and forcibly kill */ @@ -601,8 +580,6 @@ static void guacd_proc_kill(guacd_proc* proc) { /* Wait for all processes within process group to terminate */ pid_t child_pid; while ((child_pid = waitpid(-proc->pid, NULL, 0)) > 0 || errno == EINTR) { - - guacd_log(GUAC_LOG_DEBUG, "Child process %i of connection \"%s\" has terminated", child_pid, proc->client->connection_id); } @@ -629,7 +606,7 @@ void guacd_proc_stop(guacd_proc* proc) { if (shutdown(proc->fd_socket, SHUT_RDWR) == -1) guacd_log(GUAC_LOG_ERROR, "Unable to shutdown internal socket for " "connection %s. Corresponding process may remain running but " - "inactive. errno: %i", proc->client->connection_id, errno); + "inactive.", proc->client->connection_id); /* Clean up our end of the socket */ close(proc->fd_socket);