[pan2: 189/268] fixes gkd threads issues (threaded code now uses gkd_thread_enter() and gdk_thread_leave() )



commit 36981bafc021f87949d212258dcbfb0c403d1fc2
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Wed Nov 9 10:47:29 2011 +0100

    fixes gkd threads issues
    (threaded code now uses gkd_thread_enter() and gdk_thread_leave() )

 pan/gui/gui.cc                   |    2 ++
 pan/gui/pan.cc                   |    2 ++
 pan/tasks/socket-impl-openssl.cc |   16 +++++++---------
 3 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index e1a89d5..3eaa121 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1307,6 +1307,7 @@ bool GUI::deletion_confirmation_dialog()
 bool GUI :: confirm_accept_new_cert_dialog(GtkWindow * parent, X509* cert, const Quark& server)
 {
   bool ret(false);
+  gdk_threads_enter();
   GtkWidget * d = gtk_message_dialog_new (
     parent,
     GtkDialogFlags(GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
@@ -1323,6 +1324,7 @@ bool GUI :: confirm_accept_new_cert_dialog(GtkWindow * parent, X509* cert, const
   gtk_dialog_set_default_response (GTK_DIALOG(d), GTK_RESPONSE_NO);
   ret = gtk_dialog_run (GTK_DIALOG(d)) == GTK_RESPONSE_YES;
   gtk_widget_destroy(d);
+  gdk_threads_leave();
   return ret;
 }
 #endif
diff --git a/pan/gui/pan.cc b/pan/gui/pan.cc
index a96f253..d2debbd 100644
--- a/pan/gui/pan.cc
+++ b/pan/gui/pan.cc
@@ -25,6 +25,7 @@ extern "C" {
   #include <glib/gi18n.h>
   #include <gtk/gtk.h>
   #include <gmime/gmime.h>
+  #include <X11/Xlib.h>
 }
 
 #ifdef G_OS_WIN32
@@ -265,6 +266,7 @@ main (int argc, char *argv[])
   textdomain (GETTEXT_PACKAGE);
 
   g_thread_init (0);
+  gdk_threads_init ();
   g_mime_init (GMIME_ENABLE_RFC2047_WORKAROUNDS);
 
   bool gui(true), nzb(false), verbosed(false);
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index ce7fcf1..aea118e 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -288,7 +288,7 @@ namespace
     GIOSSLChannel *chan = (GIOSSLChannel *)handle;
     g_io_channel_unref(chan->giochan);
     SSL_free(chan->ssl);
-
+    std::cerr<<"ssl free\n";
     g_free(chan);
   }
 }
@@ -298,12 +298,7 @@ GIOChannelSocketSSL :: ~GIOChannelSocketSSL ()
 
   _certstore.remove_listener(this);
 
-  GIOSSLChannel *chan = (GIOSSLChannel *)_channel;
-
-//  std::cerr << LINE_ID << " destroying socket " << this << ", "<<chan->ssl<<", "<<_session<<", ";
-
-  _session = SSL_get1_session(chan->ssl);
-  _certstore.add_session(_session);
+  std::cerr << LINE_ID << " destroying socket " << this <<std::endl;
 
 //  std::cerr<<_session<<std::endl;
 
@@ -312,6 +307,9 @@ GIOChannelSocketSSL :: ~GIOChannelSocketSSL ()
 
   if (_channel)
   {
+    GIOSSLChannel *chan = (GIOSSLChannel *)_channel;
+    _session = SSL_get1_session(chan->ssl);
+    _certstore.add_session(_session);
     g_io_channel_shutdown (_channel, true, 0);
     ssl_free(_channel);
     g_string_free(_channel->read_buf,true);
@@ -793,8 +791,8 @@ GIOChannelSocketSSL :: ssl_get_iochannel(GIOChannel *handle, gboolean verify)
     g_io_channel_set_flags (handle, G_IO_FLAG_NONBLOCK, 0);
     return gchan;
   } else
-  {
-    std::cerr<<"handshake ret "<<ret<<std::endl;
+  { ;
+//    std::cerr<<"handshake ret "<<ret<<std::endl;
   }
   return 0;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]