2011-03-04 [colin] 3.7.8cvs63
authorColin Leroy <colin@colino.net>
Fri, 4 Mar 2011 15:50:16 +0000 (15:50 +0000)
committerColin Leroy <colin@colino.net>
Fri, 4 Mar 2011 15:50:16 +0000 (15:50 +0000)
* 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)

ChangeLog
PATCHSETS
configure.ac
src/common/utils.c
src/common/w32_unistd.c
src/common/w32lib.h
src/exporthtml.c
src/mimeview.c
src/mimeview.h

index 1fb14e84b26811c30a8bb13842ce89ac90477fe1..e15e633b8bb9bc5920eb933059cfb2494650c08b 100644 (file)
--- 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
index 5208ea8b271c094159a7f9b02e75090caeabcc9a..fa1bf7b418dd3385f1698e8ba48497f809d2b1d2 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
index 900d78115314739c869d139d3094ca89ebc5e6cb..92c90a56d102516d38b7ad0d126da4db741b362f 100644 (file)
@@ -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=
 
index 89c1ac2aed579df9daf7b7d8cb41e5ab6acf2ad0..93907ea51227210e1e57e961640751787e33e8ea 100644 (file)
 
 #include <glib/gi18n.h>
 
+#ifdef USE_PTHREAD
+#include <pthread.h>
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -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);
index 08c199f68a5e9bb09df1f2350389c5692a0cdb7a..d2635811c4830cf12058edcdfd546637eeddc553 100644 (file)
 
 #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 );
 }
index f93d7d488dc520a51f542983075dafb168c72b2a..135883294153314de25203fff72bbd2d8faf1884 100644 (file)
@@ -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 );
 
-\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
index d2be67985ad2dac01a34080a48b1ce179436e985..e399e4e6e6609f2c6da27db24494586cff0f81c6 100644 (file)
 #  include "config.h"
 #endif
 
+#ifdef USE_PTHREAD
+#include <pthread.h>
+#endif
+
 #include <sys/stat.h>
 #include <dirent.h>
 #include <errno.h>
index db7fa554fb94853537b701d41d1a9addf7be9a6a..1533bd6e89bba657587ba1b87b8f487d84a9701b 100644 (file)
@@ -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
 
index af896d022ad84aea792d41557c43e6b463373d79..2d360ba70cf68e8d6578b94f910d3a64ce4154f7 100644 (file)
@@ -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;