#endif
/*** unistd ***/
-uid_t getuid( void );
int setpgid( pid_t pid, pid_t pgid );
pid_t getppid( void );
pid_t fork( void );
unsigned int sleep( unsigned int seconds );
-int link( const char *oldpath, const char *newpath );
/*** stdlib ***/
long int random( void );
char *read_w32_registry_string( char *parent, char *section, char *key );
char *get_content_type_from_registry_with_ext( char *ext );
-\f
-/* Simulate thread-safe versions of some functions. */
-#define gmtime_r(time, resultp) gmtime (time)
-#define localtime_r(time, resultp) localtime (time)
-#define asctime_r(time, buffer) asctime (time)
-#define ctime_r(time, buffer) ctime (time)
-
#endif
must_free = mimeview->check_data->free_after_use;
must_destroy = mimeview->check_data->destroy_mimeview;
- if (mimeview->check_data->cancel_th) {
+ if (mimeview->check_data->cancel_th_init) {
debug_print("killing canceller thread\n");
+ mimeview->check_data->cancel_th_init = FALSE;
pthread_cancel(mimeview->check_data->cancel_th);
- mimeview->check_data->cancel_th = 0;
}
g_free(mimeview->check_data);
if (mimeinfo && mimeinfo == mimeview->check_data->siginfo) {
privacy_mimeinfo_check_signature(mimeinfo);
- if (mimeview->check_data->cancel_th) {
+ if (mimeview->check_data && mimeview->check_data->cancel_th_init) {
+ mimeview->check_data->cancel_th_init = FALSE;
pthread_cancel(mimeview->check_data->cancel_th);
- mimeview->check_data->cancel_th = 0;
}
} else {
/* that's strange! we changed message without
/* wait for a few seconds... */
debug_print("waiting a while\n");
- sleep(5);
+ g_usleep(5 * 1000 * 1000);
if (!mimeview->check_data)
return NULL; /* nothing to kill, it's done in time :) */
/* too late, go away checker thread */
debug_print("killing checker thread\n");
- pthread_cancel(mimeview->check_data->th);
-
+ if (mimeview->check_data->th_init) {
+ mimeview->check_data->th_init = FALSE;
+ pthread_cancel(mimeview->check_data->th);
+ }
+
/* tell upstream it was a timeout */
mimeview->check_data->timeout = TRUE;
/* use g_timeout so that GUI updates is done from the
if (!mimeview->check_data)
return;
debug_print("killing checker thread NOW\n");
- pthread_cancel(mimeview->check_data->th);
+ if (mimeview->check_data->th_init) {
+ mimeview->check_data->th_init = FALSE;
+ pthread_cancel(mimeview->check_data->th);
+ }
/* tell upstream it was a timeout */
mimeview->check_data->timeout = TRUE;
g_free(mimeview->check_data);
mimeview->check_data = NULL;
return;
- } else
+ } else {
mimeview->check_data->th = th;
+ mimeview->check_data->th_init = TRUE;
+ }
/* create the killer thread */
pthread_create(&th2, &detach2,
mimeview);
mimeview->check_data->cancel_th = th2;
+ mimeview->check_data->cancel_th_init = TRUE;
}
#endif