From: Colin Leroy Date: Fri, 4 Mar 2011 15:50:16 +0000 (+0000) Subject: 2011-03-04 [colin] 3.7.8cvs63 X-Git-Tag: REL_3_7_9~16 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=ec9cbb7e8f9fdc00d73d1c44f971fe0f9e329762 2011-03-04 [colin] 3.7.8cvs63 * src/mimeview.c * src/mimeview.h Fix segfault on Windows * src/exporthtml.c * src/common/utils.c * src/common/w32_unistd.c * src/common/w32lib.h Rationalize use of time_r() funcs (pthread do define them) --- diff --git a/ChangeLog b/ChangeLog index 1fb14e84b..e15e633b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-03-04 [colin] 3.7.8cvs63 + + * src/mimeview.c + * src/mimeview.h + Fix segfault on Windows + * src/exporthtml.c + * src/common/utils.c + * src/common/w32_unistd.c + * src/common/w32lib.h + Rationalize use of time_r() funcs (pthread do define them) + 2011-03-02 [pawel] 3.7.8cvs62 * src/wizard.c diff --git a/PATCHSETS b/PATCHSETS index 5208ea8b2..fa1bf7b41 100644 --- a/PATCHSETS +++ b/PATCHSETS @@ -4136,3 +4136,4 @@ ( cvs diff -u -r 1.24.2.21 -r 1.24.2.22 src/common/Makefile.am; ) > 3.7.8cvs60.patchset ( cvs diff -u -r 1.1.2.81 -r 1.1.2.82 src/wizard.c; ) > 3.7.8cvs61.patchset ( cvs diff -u -r 1.1.2.82 -r 1.1.2.83 src/wizard.c; ) > 3.7.8cvs62.patchset +( cvs diff -u -r 1.155.2.97 -r 1.155.2.98 src/Makefile.am; cvs diff -u -r 1.5.2.29 -r 1.5.2.30 src/exporthtml.c; cvs diff -u -r 1.83.2.167 -r 1.83.2.168 src/mimeview.c; cvs diff -u -r 1.20.2.31 -r 1.20.2.32 src/mimeview.h; cvs diff -u -r 1.36.2.191 -r 1.36.2.192 src/common/utils.c; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/common/w32_unistd.c; cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/common/w32lib.h; ) > 3.7.8cvs63.patchset diff --git a/configure.ac b/configure.ac index 900d78115..92c90a56d 100644 --- a/configure.ac +++ b/configure.ac @@ -12,7 +12,7 @@ MINOR_VERSION=7 MICRO_VERSION=8 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=62 +EXTRA_VERSION=63 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/src/common/utils.c b/src/common/utils.c index 89c1ac2ae..93907ea51 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -27,6 +27,10 @@ #include +#ifdef USE_PTHREAD +#include +#endif + #include #include #include @@ -3528,9 +3532,7 @@ time_t tzoffset_sec(time_t *now) { struct tm gmt, *lt; gint off; -#ifndef G_OS_WIN32 struct tm buf1, buf2; -#endif #ifdef G_OS_WIN32 if (now && *now < 0) return 0; @@ -3564,9 +3566,7 @@ gchar *tzoffset(time_t *now) struct tm gmt, *lt; gint off; gchar sign = '+'; -#ifndef G_OS_WIN32 struct tm buf1, buf2; -#endif #ifdef G_OS_WIN32 if (now && *now < 0) return 0; @@ -3604,10 +3604,8 @@ void get_rfc822_date(gchar *buf, gint len) time_t t; gchar day[4], mon[4]; gint dd, hh, mm, ss, yyyy; -#ifndef G_OS_WIN32 struct tm buf1; gchar buf2[BUFFSIZE]; -#endif t = time(NULL); lt = localtime_r(&t, &buf1); @@ -3836,9 +3834,7 @@ gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr) struct tm *lt; time_t t; gchar *addr; -#ifndef G_OS_WIN32 struct tm buft; -#endif t = time(NULL); lt = localtime_r(&t, &buft); diff --git a/src/common/w32_unistd.c b/src/common/w32_unistd.c index 08c199f68..d2635811c 100644 --- a/src/common/w32_unistd.c +++ b/src/common/w32_unistd.c @@ -23,10 +23,6 @@ #include "w32lib.h" -uid_t getuid( void ){ - return 1; -} - int setpgid( pid_t pid, pid_t pgid ){ return -1; } @@ -40,14 +36,10 @@ pid_t fork( void ){ } unsigned int sleep( unsigned int seconds ){ - _sleep( seconds ); + _sleep(seconds * 1000); return 0; } -int link( const char *oldpath, const char *newpath ){ - return -1; -} - int usleep( unsigned long usec ){ return sleep( 1 ); } diff --git a/src/common/w32lib.h b/src/common/w32lib.h index f93d7d488..135883294 100644 --- a/src/common/w32lib.h +++ b/src/common/w32lib.h @@ -185,12 +185,10 @@ int gettimeofday( struct timeval *tv, struct timezone *tz ); #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 ); @@ -213,11 +211,4 @@ int write_w32_registry_dword( char *parent, char *section, char *value, int data char *read_w32_registry_string( char *parent, char *section, char *key ); char *get_content_type_from_registry_with_ext( char *ext ); - -/* 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 diff --git a/src/exporthtml.c b/src/exporthtml.c index d2be67985..e399e4e6e 100644 --- a/src/exporthtml.c +++ b/src/exporthtml.c @@ -25,6 +25,10 @@ # include "config.h" #endif +#ifdef USE_PTHREAD +#include +#endif + #include #include #include diff --git a/src/mimeview.c b/src/mimeview.c index db7fa554f..1533bd6e8 100644 --- a/src/mimeview.c +++ b/src/mimeview.c @@ -947,10 +947,10 @@ static void mimeview_check_data_reset(MimeView *mimeview) 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); @@ -1029,9 +1029,9 @@ static void *mimeview_check_sig_worker_thread(void *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 @@ -1060,15 +1060,18 @@ static void *mimeview_check_sig_cancel_thread(void *data) /* 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 @@ -1085,7 +1088,10 @@ static void mimeview_check_sig_cancel_now(MimeView *mimeview) 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; @@ -1122,8 +1128,10 @@ static void mimeview_check_sig_in_thread(MimeView *mimeview) 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, @@ -1131,6 +1139,7 @@ static void mimeview_check_sig_in_thread(MimeView *mimeview) mimeview); mimeview->check_data->cancel_th = th2; + mimeview->check_data->cancel_th_init = TRUE; } #endif diff --git a/src/mimeview.h b/src/mimeview.h index af896d022..2d360ba70 100644 --- a/src/mimeview.h +++ b/src/mimeview.h @@ -49,6 +49,9 @@ struct _SigCheckData { pthread_t th; pthread_t cancel_th; + gboolean th_init; + gboolean cancel_th_init; + MimeInfo *siginfo; gboolean free_after_use; gboolean destroy_mimeview;