[pan2] fix giganews IP lockout on ISP IP change fixed sigsegv in socket impl



commit 5eef4fcbe24815ff73c158b4e9ddfc1fc5a48463
Author: Heinrich MÃller <henmull src gnome org>
Date:   Wed Jan 23 17:11:53 2013 +0100

    fix giganews IP lockout on ISP IP change
    fixed sigsegv in socket impl

 pan/general/locking.h        |   10 ++++++----
 pan/tasks/nntp-pool.cc       |    3 ++-
 pan/tasks/nntp.cc            |    5 ++---
 pan/tasks/socket-impl-gio.cc |    3 +++
 pan/tasks/task-groups.cc     |    7 ++++++-
 5 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/pan/general/locking.h b/pan/general/locking.h
index 2ee0e8c..e88a59c 100644
--- a/pan/general/locking.h
+++ b/pan/general/locking.h
@@ -36,7 +36,7 @@ namespace pan
   class Mutex
   {
     private:
-      static GMutex mutex;
+      GMutex mutex;
       GMutex * m;
 
     public:
@@ -44,19 +44,21 @@ namespace pan
       /** Create a new mutex */
       Mutex()
       {
-#if !GLIB_CHECK_VERSION(2,34,2)
+#if !GLIB_CHECK_VERSION(2,32,0)
         m = g_mutex_new();
 #else
-        g_mutex_init(&mutex);
         m = &mutex;
+        g_mutex_init(m);
 #endif
       }
 
       /** Destroy the mutex */
       virtual ~Mutex()
       {
-#if !GLIB_CHECK_VERSION(2,34,2)
+#if !GLIB_CHECK_VERSION(2,32,0)
         g_mutex_free(m);
+#else
+        g_mutex_clear(m);
 #endif
       }
 
diff --git a/pan/tasks/nntp-pool.cc b/pan/tasks/nntp-pool.cc
index e8b60d2..923858e 100644
--- a/pan/tasks/nntp-pool.cc
+++ b/pan/tasks/nntp-pool.cc
@@ -224,7 +224,8 @@ NNTP_Pool :: on_nntp_done (NNTP* nntp, Health health, const StringView& response
          || (s.find ("480") != s.npos) // http://bugzilla.gnome.org/show_bug.cgi?id=409085
          || (s.find ("too many") != s.npos)
          || (s.find ("limit reached") != s.npos)
-         || (s.find ("maximum number of connections") != s.npos))
+         || (s.find ("maximum number of connections") != s.npos)
+         || (s.find ("multiple") != s.npos) )
      {
        disallow_new_connections_for_n_seconds (TOO_MANY_CONNECTIONS_LOCKOUT_SECS);
      }
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index fce8106..1127960 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -63,6 +63,7 @@ NNTP :: fire_done_func (Health health, const StringView& response)
       debug ("I (" << (void*)this << ") am setting my _listener to 0");
       _listener = 0;
       l->on_nntp_done (this, health, response);
+      _compression = false;
    }
 }
 
@@ -76,7 +77,6 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
    enum State { CMD_FAIL, CMD_DONE, CMD_MORE, CMD_NEXT, CMD_RETRY };
    State state;
    StringView line (line_in);
-   std::string old_line = line;
 
    // strip off trailing \r\n
    if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n')
@@ -98,7 +98,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
 
          assert (_listener != 0);
          if (_listener)
-            _listener->on_nntp_line (this, line_in);
+            _listener->on_nntp_line (this, line);
       }
 
       if (_compression)
@@ -109,7 +109,6 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
           _listener->on_nntp_line (this, line_in);
         if (line_in.len >= 3 && strncmp(line_in.str + line_in.len - 3, ".\r\n", 3) == 0)
         {
-          _compression = false;
           _nntp_response_text = false;
           line = EOL;
           state = CMD_DONE;
diff --git a/pan/tasks/socket-impl-gio.cc b/pan/tasks/socket-impl-gio.cc
index b11e926..afeb1a3 100644
--- a/pan/tasks/socket-impl-gio.cc
+++ b/pan/tasks/socket-impl-gio.cc
@@ -286,11 +286,14 @@ GIOChannelSocket :: open (const StringView& address, int port, std::string& setm
 {
   _host.assign (address.str, address.len);
   _channel = create_channel (address, port, setme_err);
+  if (_channel)
+  {
 #ifdef G_OS_WIN32
   _id = g_io_channel_win32_get_fd(_channel);
 #else
    _id = g_io_channel_unix_get_fd(_channel);
 #endif // G_OS_WIN32
+  }
   return _channel != 0;
 }
 
diff --git a/pan/tasks/task-groups.cc b/pan/tasks/task-groups.cc
index 49b3c30..fffb701 100644
--- a/pan/tasks/task-groups.cc
+++ b/pan/tasks/task-groups.cc
@@ -149,7 +149,12 @@ TaskGroups :: on_nntp_done (NNTP              * nntp,
   else // health is OK or FAIL
   {
 
-    if (response == EOL && nntp->_compression)
+    const Quark& server(nntp->_server);
+    CompressionType comp;
+    _data.get_server_compression_type(server, comp);
+    const bool compression (comp == HEADER_COMPRESS_XFEATURE);
+
+    if (response == EOL && compression)
     {
       std::vector<std::string> lines;
       compression::inflate_gzip (&stream, lines);



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