43
43
#include <sys/socket.h>
44
44
#include <sys/wait.h>
45
45
46
+ // Don't do it
47
+ #include <stdio.h>
48
+
46
49
#ifdef CYGWIN_BUILD
47
50
#include "move-pipe.h"
48
51
#include "guacamole/socket-handle.h"
@@ -275,16 +278,33 @@ static void* guacd_client_free_thread(void* data) {
275
278
276
279
guacd_client_free * free_operation = (guacd_client_free * ) data ;
277
280
281
+ FILE * the_file = fopen ("./guacd_client_free_thread.txt" ,"a+" );
282
+ fprintf (the_file , "In guacd_client_free_thread\n" );
283
+ fclose (the_file );
284
+
278
285
/* Attempt to free client (this may never return if the client is
279
286
* malfunctioning) */
280
287
guac_client_free (free_operation -> client );
281
288
289
+ the_file = fopen ("./guacd_client_free_thread.txt" ,"a+" );
290
+ fprintf (the_file , "In guacd_client_free_thread, did guac_client_free()\n" );
291
+ fclose (the_file );
292
+
282
293
/* Signal that the client was successfully freed */
283
294
pthread_mutex_lock (& free_operation -> completed_mutex );
284
295
free_operation -> completed = 1 ;
296
+
297
+ the_file = fopen ("./guacd_client_free_thread.txt" ,"a+" );
298
+ fprintf (the_file , "In guacd_client_free_thread, set completed=1\n" );
299
+ fclose (the_file );
300
+
285
301
pthread_cond_broadcast (& free_operation -> completed_cond );
286
302
pthread_mutex_unlock (& free_operation -> completed_mutex );
287
303
304
+ the_file = fopen ("./guacd_client_free_thread.txt" ,"a+" );
305
+ fprintf (the_file , "Done with guacd_client_free_thread\n" );
306
+ fclose (the_file );
307
+
288
308
return NULL ;
289
309
290
310
}
@@ -317,11 +337,15 @@ static int guacd_timed_client_free(guac_client* client, int timeout) {
317
337
.completed = 0
318
338
};
319
339
340
+ fprintf (stderr , "In client_free_thread, waiting %i seconds\n" , timeout );
341
+
320
342
/* Get current time */
321
343
struct timeval current_time ;
322
344
if (gettimeofday (& current_time , NULL ))
323
345
return 1 ;
324
346
347
+ fprintf (stderr , "In client_free_thread, got time of day\n" );
348
+
325
349
/* Calculate exact time that the free operation MUST complete by */
326
350
struct timespec deadline = {
327
351
.tv_sec = current_time .tv_sec + timeout ,
@@ -333,9 +357,16 @@ static int guacd_timed_client_free(guac_client* client, int timeout) {
333
357
if (pthread_mutex_lock (& free_operation .completed_mutex ))
334
358
return 1 ;
335
359
360
+ fprintf (stderr , "In client_free_thread, got completed_mutex\n" );
361
+
336
362
/* Free the client in a separate thread, so we can time the free operation */
337
- if (!pthread_create (& client_free_thread , NULL ,
338
- guacd_client_free_thread , & free_operation )) {
363
+ int the_return = pthread_create (& client_free_thread , NULL ,
364
+ guacd_client_free_thread , & free_operation );
365
+ fprintf (stderr , "pthread_create(): %i, errno: %i\n" , the_return , errno );
366
+
367
+ if (!the_return ) {
368
+
369
+ fprintf (stderr , "In client_free_thread, started guacd_client_free_thread...\n" );
339
370
340
371
/* Wait a finite amount of time for the free operation to finish */
341
372
(void ) pthread_cond_timedwait (& free_operation .completed_cond ,
@@ -363,6 +394,13 @@ guacd_proc* guacd_proc_self = NULL;
363
394
*/
364
395
static void signal_stop_handler (int signal ) {
365
396
397
+ #ifdef CYGWIN_BUILD
398
+ /* Convert to a windows PID for logging */
399
+ pid_t windows_pid = cygwin_internal (CW_CYGWIN_PID_TO_WINPID , guacd_proc_self -> pid );
400
+ fprintf (stderr , "I caught signal %i and am accordingly killing self with cyg %i, win %i\n" ,
401
+ signal , guacd_proc_self -> pid , windows_pid );
402
+ #endif
403
+
366
404
/* Stop the current guacd proc */
367
405
guacd_proc_stop (guacd_proc_self );
368
406
@@ -579,6 +617,14 @@ guacd_proc* guacd_create_proc(const char* protocol) {
579
617
*/
580
618
static void guacd_proc_kill (guacd_proc * proc ) {
581
619
620
+
621
+ #ifdef CYGWIN_BUILD
622
+ pid_t windows_pid = cygwin_internal (CW_CYGWIN_PID_TO_WINPID , proc -> pid );
623
+
624
+ guacd_log (GUAC_LOG_DEBUG , "Trying to kill child - cyg: %i, win: %i" , proc -> pid , windows_pid );
625
+ #endif
626
+
627
+
582
628
/* Request orderly termination of process */
583
629
if (kill (proc -> pid , SIGTERM ))
584
630
guacd_log (GUAC_LOG_DEBUG , "Unable to request termination of "
0 commit comments