Hello community,

here is the log from the commit of package imapfilter for openSUSE:Factory 
checked in at 2018-03-05 13:45:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/imapfilter (Old)
 and      /work/SRC/openSUSE:Factory/.imapfilter.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "imapfilter"

Mon Mar  5 13:45:22 2018 rev:40 rq:582543 version:2.6.11

Changes:
--------
--- /work/SRC/openSUSE:Factory/imapfilter/imapfilter.changes    2017-09-09 
20:26:22.307468573 +0200
+++ /work/SRC/openSUSE:Factory/.imapfilter.new/imapfilter.changes       
2018-03-05 13:45:51.422574836 +0100
@@ -1,0 +2,13 @@
+Thu Mar  1 23:51:55 UTC 2018 - [email protected]
+
+- specfile:
+  * update copyright year
+
+- update to version 2.6.11:
+  * Support for interrupting IDLE mode with SIGUSR1/SIGUSR2.
+  * New "persist" option to try to recover a connection indefinitely.
+  * New "range" option to limit messages included in a range.
+  * Bug fix; always close selected mailbox before check_status().
+  * Bug fix; closing of selected mailbox twice with fetch_message().
+
+-------------------------------------------------------------------

Old:
----
  imapfilter-2.6.10.tar.gz

New:
----
  imapfilter-2.6.11.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ imapfilter.spec ++++++
--- /var/tmp/diff_new_pack.Oy8Gsr/_old  2018-03-05 13:45:52.330541981 +0100
+++ /var/tmp/diff_new_pack.Oy8Gsr/_new  2018-03-05 13:45:52.330541981 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package imapfilter
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -21,7 +21,7 @@
 License:        MIT
 Group:          Productivity/Networking/Email/Utilities
 Url:            https://github.com/lefcha/imapfilter
-Version:        2.6.10
+Version:        2.6.11
 Release:        0
 Source:         %{name}-%{version}.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ imapfilter-2.6.10.tar.gz -> imapfilter-2.6.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/LICENSE 
new/imapfilter-2.6.11/LICENSE
--- old/imapfilter-2.6.10/LICENSE       2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/LICENSE       2017-11-19 10:38:24.000000000 +0100
@@ -1,4 +1,4 @@
-Copyright (c) 2001-2016 Eleftherios Chatzimparmpas
+Copyright (c) 2001-2017 Eleftherios Chatzimparmpas
 
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/NEWS new/imapfilter-2.6.11/NEWS
--- old/imapfilter-2.6.10/NEWS  2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/NEWS  2017-11-19 10:38:24.000000000 +0100
@@ -1,3 +1,10 @@
+IMAPFilter 2.6.11 - 19 Nov 2017
+  - Support for interrupting IDLE mode with SIGUSR1/SIGUSR2.
+  - New "persist" option to try to recover a connection indefinitely.
+  - New "range" option to limit messages included in a range.
+  - Bug fix; always close selected mailbox before check_status().
+  - Bug fix; closing of selected mailbox twice with fetch_message().
+
 IMAPFilter 2.6.10 - 16 Dec 2016
   - Bug fix; segmentation fault on some OpenSSL builds.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/doc/imapfilter_config.5 
new/imapfilter-2.6.11/doc/imapfilter_config.5
--- old/imapfilter-2.6.10/doc/imapfilter_config.5       2016-12-16 
08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/doc/imapfilter_config.5       2017-11-19 
10:38:24.000000000 +0100
@@ -1,4 +1,4 @@
-.Dd Nov 26, 2016
+.Dd Nov 11, 2017
 .Dt IMAPFILTER_CONFIG 5
 .Os
 .Sh NAME
@@ -149,11 +149,14 @@
 action for many messages at once.  When this option is set, the client will try
 to break up these requests into smaller requests, that each operates on fewer
 messages at a time.  A good value for this would be
-.Dq 50,
+.Dq 50 .
 This variable takes a
 .Vt number
 as a value.  Default is
-.Dq 0 . 
+.Dq 0 .
+See also the
+.Va range
+option which is related.
 .It Va namespace
 When enabled, the program gets the namespace of the user's personal mailboxes,
 and applies automatically the prefix and hierarchy delimiter to any mailboxes
@@ -164,10 +167,37 @@
 (ie.  nothing) as the prefix, regardless of the folder
 format of the mail server.  This must be disabled, if the user wants to
 manually specify mailbox names (eg. because they are not part of the user's
-personal namespace mailboxes).  This variable takes
+personal namespace mailboxes).  This variable takes a
 .Vt boolean
 as a value.  Default is
 .Dq true .
+.It Va persist
+When the
+.Va recover
+option is enabled, the recovery function tries to restore the lost session, but
+if it fails to do so it gives up with an error.  In some cases a temporary
+network problem might cause the recovery function to fail, but the connection
+could be reestablished when trying a bit later.  By enabling this option, the
+recovery function will be called repeatedly after a timeout, thus it will
+persist when trying to restore the session.  Note, that this will case the
+execution of the configuration file to be halted at the point of failure until
+the session is restored, which can have side effects to other established
+sessions, for example they might get dropped by the server after a while.  This
+variable
+takes a
+.Vt boolean
+as a value.  Default is
+.Dq false .
+.It Va range
+Some servers have problems handling long sequence number ranges, and by setting
+this option, the number of messages included in each range can be limited.  A
+good value for this would be
+.Dq 50 .
+This variable takes a
+.Vt number
+as a value.  By default no such limit is imposed.  See also the
+.Va limit
+option which is related.
 .It Va recover
 With this option it is possible to control the recovery functionality, which
 restores a session (the connection to the server and the IMAP state at the
@@ -520,6 +550,14 @@
 useful when the
 .Va wakeonany
 option has been enabled.
+.Pp
+Apart from an event received by the server, the SIGUSR1 or SIGUSR2 signals can
+also interrupt the IDLE mode at any time, and the execution of the
+configuration file will then continue from the next line after the
+.Fn enter_idle .
+In this case only the value
+.Dq true
+is returned.
 .El
 .Pp
 Examples:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/auth.c 
new/imapfilter-2.6.11/src/auth.c
--- old/imapfilter-2.6.10/src/auth.c    2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/auth.c    2017-11-19 10:38:24.000000000 +0100
@@ -20,7 +20,7 @@
        unsigned char *resp, *buf, *out;
        unsigned char md[EVP_MAX_MD_SIZE], mdhex[EVP_MAX_MD_SIZE * 2 + 1];
        unsigned int mdlen;
-#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)
        HMAC_CTX *ctx;
 #else
        HMAC_CTX ctx;
@@ -32,7 +32,7 @@
 
        EVP_DecodeBlock(resp, chal, strlen((char *)(chal)));
 
-#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
+#if OPENSSL_VERSION_NUMBER >= 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)
        ctx = HMAC_CTX_new();
        HMAC_Init_ex(ctx, (const unsigned char *)pass, strlen(pass),
            EVP_md5(), NULL);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/cert.c 
new/imapfilter-2.6.11/src/cert.c
--- old/imapfilter-2.6.10/src/cert.c    2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/cert.c    2017-11-19 10:38:24.000000000 +0100
@@ -44,7 +44,8 @@
        if (!((verify == X509_V_OK) ||
            (verify == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ||
            (verify == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY))) {
-               error("certificate verification failed; %d\n", verify);
+               error("certificate verification failed; %s\n",
+                     X509_verify_cert_error_string(verify));
                goto fail;
        }
 
@@ -63,7 +64,7 @@
                                goto fail;
                        break;
                case -1:
-                       error("certificate mismatch occured\n");
+                       error("certificate mismatch occurred\n");
                        goto fail;
                }
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/common.lua 
new/imapfilter-2.6.11/src/common.lua
--- old/imapfilter-2.6.10/src/common.lua        2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/common.lua        2017-11-19 10:38:24.000000000 
+0100
@@ -67,7 +67,7 @@
             a = m
             z = m
         else
-            if m == z + 1 then
+            if m == z + 1 and m - a <= options.range then
                 z = m
             else
                 if a == z then
@@ -158,7 +158,7 @@
             end
         end
         return bs
-    else 
+    else
         for k, v in ipairs(val) do
             local new = tostring(key) .. '.' .. tostring(k)
             bs[new] = v
@@ -228,7 +228,7 @@
         _parse_number(b)
     end
     if _parse_space(b) then _parse_nstring(b) end
-    if _parse_space(b) then 
+    if _parse_space(b) then
         s = _parse_dsp(b)
         if s then bp['name'] = s end
     end
@@ -300,7 +300,7 @@
     if not p then return end
     if #p == 0 then
         bp[1] = p
-    else 
+    else
         for k, v in pairs(p) do
             if type(k) == 'number' then
                 bp[k] = v
@@ -361,7 +361,7 @@
         end
         _parse_rpar(b)
     elseif _parse_nil(b) then
-    end  
+    end
 end
 
 function _parse_lang(b)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/core.c 
new/imapfilter-2.6.11/src/core.c
--- old/imapfilter-2.6.10/src/core.c    2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/core.c    2017-11-19 10:38:24.000000000 +0100
@@ -64,12 +64,12 @@
        /*
         * RFC 822: message == header + body
         * RFC 3501: body == header + text
-        * 
+        *
         * RFC 3501 notation is used internally, and RFC 822 notation is used
         * for the interface available to the user.
         */
        { "fetchheader", ifcore_fetchheader },
-       { "fetchbody", ifcore_fetchtext }, 
+       { "fetchbody", ifcore_fetchtext },
 
        { "fetchfields", ifcore_fetchfields },
        { "fetchstructure", ifcore_fetchstructure },
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/imapfilter.c 
new/imapfilter-2.6.11/src/imapfilter.c
--- old/imapfilter-2.6.10/src/imapfilter.c      2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/imapfilter.c      2017-11-19 10:38:24.000000000 
+0100
@@ -118,6 +118,7 @@
        open_debug();
        create_homedir();
        catch_signals();
+       ignore_user_signals();
        open_log();
        if (opts.config == NULL)
                opts.config = get_filepath("config.lua");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/imapfilter.h 
new/imapfilter-2.6.11/src/imapfilter.h
--- old/imapfilter-2.6.10/src/imapfilter.h      2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/imapfilter.h      2017-11-19 10:38:24.000000000 
+0100
@@ -47,6 +47,7 @@
 #define STATUS_READONLY                        8
 #define STATUS_TRYCREATE               9
 #define STATUS_TIMEOUT                 10
+#define STATUS_INTERRUPT                11
 
 #define STATUS_DRYRUN                   STATUS_OK
 
@@ -61,6 +62,9 @@
 #define LINE_MAX                       2048
 #endif
 
+/* Wait retry timeout, in seconds, on network problems. */
+#define WAIT_RETRY_TIMEOUT              60
+
 
 /* Program's options. */
 typedef struct options {
@@ -210,12 +214,14 @@
 /*     signal.c        */
 void catch_signals(void);
 void release_signals(void);
+void ignore_user_signals(void);
+void catch_user_signals(void);
 
 /*     socket.c        */
 int open_connection(session *ssn);
 int close_connection(session *ssn);
 ssize_t socket_read(session *ssn, char *buf, size_t len, long timeout,
-    int timeoutfail);
+    int timeoutfail, int *interrupt);
 ssize_t socket_write(session *ssn, const char *buf, size_t len);
 int open_secure_connection(session *ssn);
 int close_secure_connection(session *ssn);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/lua.c 
new/imapfilter-2.6.11/src/lua.c
--- old/imapfilter-2.6.10/src/lua.c     2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/lua.c     2017-11-19 10:38:24.000000000 +0100
@@ -138,6 +138,7 @@
        set_table_boolean("expunge", 1);
        set_table_number("keepalive", 29);
        set_table_boolean("namespace", 1);
+       set_table_boolean("persist", 0);
        set_table_string("recover", "all");
        set_table_boolean("reenter", 1);
        set_table_boolean("starttls", 1);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/mailbox.lua 
new/imapfilter-2.6.11/src/mailbox.lua
--- old/imapfilter-2.6.10/src/mailbox.lua       2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/mailbox.lua       2017-11-19 10:38:24.000000000 
+0100
@@ -76,6 +76,7 @@
 
 function Mailbox._cached_close(self)
     if not self._check_connection(self) then return end
+    if self._account._account.selected == nil then return end
     local r = ifcore.close(self._account._account.session)
     self._check_result(self, 'close', r)
     if r == false then return false end
@@ -111,7 +112,7 @@
         query = mesgs
     elseif type(criteria) == 'string' then
         query = mesgs .. ' ' .. criteria
-    else 
+    else
         query = _make_query(criteria, mesgs)
     end
 
@@ -382,7 +383,6 @@
 
 function Mailbox._fetch_message(self, messages)
     if not messages or #messages == 0 then return end
-    if self._cached_select(self) ~= true then return end
 
     local header = self._fetch_header(self, messages)
     local body = self._fetch_body(self, messages)
@@ -398,8 +398,6 @@
         end
     end
 
-    if options.close == true then self._cached_close(self) end
-
     return results
 end
 
@@ -501,6 +499,9 @@
 
 function Mailbox.check_status(self)
     if not self._check_connection(self) then return end
+    if self._account._account.selected == self._mailbox then
+        self._cached_close(self)
+    end
     local r, exist, recent, unseen, uidnext =
         ifcore.status(self._account._account.session,self._mailbox)
     self._check_result(self, 'status', r)
@@ -527,7 +528,7 @@
 function Mailbox.add_flags(self, flags, messages)
     _check_required(flags, 'table')
     _check_required(messages, 'table')
-    
+
     local mesgs = _extract_messages(self, messages)
     local r = self._flag_messages(self, 'add', flags, mesgs)
     if options.info == true and r == true then
@@ -798,7 +799,7 @@
         print('Appended message of ' .. #message .. ' octets to ' ..
               self._string .. '.')
     end
-    
+
     return true
 end
 
@@ -1063,7 +1064,7 @@
 
 function Mailbox.enter_idle(self)
     if self._cached_select(self) ~= true then return false end
-   
+
     if not self._check_connection(self) then return end
     local r, event = ifcore.idle(self._account._account.session)
     self._check_result(self, 'idle', r)
@@ -1071,7 +1072,11 @@
 
     if options.close == true then self._cached_close(self) end
 
-    return true, string.upper(event)
+    if type(event) == 'string' then
+        return true, string.upper(event)
+    else
+        return true
+    end
 end
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/namespace.c 
new/imapfilter-2.6.11/src/namespace.c
--- old/imapfilter-2.6.10/src/namespace.c       2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/namespace.c       2017-11-19 10:38:24.000000000 
+0100
@@ -10,7 +10,7 @@
 buffer cbuf;                   /* Conversion buffer. */
 
 
-static const char base64[] = 
+static const char base64[] =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
 
 
@@ -65,7 +65,7 @@
        int n, o;
        char *c;
 
-       if (!strcasecmp(mbox, "INBOX")) 
+       if (!strcasecmp(mbox, "INBOX"))
                return mbox;
 
        if ((prefix == NULL && delim == '\0') ||
@@ -102,7 +102,7 @@
        unsigned char ucp[4], ucplast, ucptemp;
        int padding, shift;
 
-       buffer_check(&nbuf, strlen(mbox)); 
+       buffer_check(&nbuf, strlen(mbox));
        buffer_reset(&nbuf);
        xstrncpy(nbuf.data, mbox, nbuf.size);
        nbuf.len = strlen(nbuf.data);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/options.lua 
new/imapfilter-2.6.11/src/options.lua
--- old/imapfilter-2.6.10/src/options.lua       2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/options.lua       2017-11-19 10:38:24.000000000 
+0100
@@ -5,3 +5,4 @@
 options.close = false
 options.info = true
 options.limit = 0
+options.range = math.huge
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/request.c 
new/imapfilter-2.6.11/src/request.c
--- old/imapfilter-2.6.10/src/request.c 2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/request.c 2017-11-19 10:38:24.000000000 +0100
@@ -33,10 +33,16 @@
        switch ((F)) {                                                         \
        case -1:                                                               \
                if ((!strcasecmp(get_option_string("recover"), "all") ||       \
-                   !strcasecmp(get_option_string("recover"), "errors")) &&    \
-                   request_login(&ssn, NULL, NULL, NULL, NULL, NULL,          \
-                       NULL) != -1)                                           \
-                       return STATUS_NONE;                                    \
+                   !strcasecmp(get_option_string("recover"), "errors")))      \
+                       for (;;) {                                             \
+                               if (request_login(&ssn, NULL, NULL, NULL,      \
+                                   NULL, NULL, NULL) != -1)                   \
+                                       return STATUS_NONE;                    \
+                               if (get_option_boolean("persist"))             \
+                                       sleep(WAIT_RETRY_TIMEOUT);             \
+                               else                                           \
+                                       break;                                 \
+                       }                                                      \
                return -1;                                                     \
        case STATUS_BYE:                                                       \
                close_connection(ssn);                                         \
@@ -156,7 +162,7 @@
 request_login(session **ssnptr, const char *server, const char *port, const
     char *ssl, const char *user, const char *pass, const char *oauth2)
 {
-       int t, r, rg = -1, rl = -1; 
+       int t, r, rg = -1, rl = -1;
        session *ssn = *ssnptr;
        
        if (*ssnptr && (*ssnptr)->socket != -1)
@@ -609,7 +615,7 @@
        if (opts.dryrun)
                return STATUS_DRYRUN;
 
-       TRY(t = send_request(ssn, "UID STORE %s %sFLAGS.SILENT (%s)", mesg, 
+       TRY(t = send_request(ssn, "UID STORE %s %sFLAGS.SILENT (%s)", mesg,
            (!strncasecmp(mode, "add", 3) ? "+" :
            !strncasecmp(mode, "remove", 6) ? "-" : ""), flags));
        TRY(r = response_generic(ssn, t));
@@ -675,7 +681,7 @@
            (date ? date : ""), (date ? "\"" : ""), mesglen));
        TRY(r = response_continuation(ssn, t));
        if (r == STATUS_CONTINUE) {
-               TRY(send_continuation(ssn, mesg, mesglen)); 
+               TRY(send_continuation(ssn, mesg, mesglen));
                TRY(r = response_generic(ssn, t));
        }
 
@@ -692,7 +698,7 @@
                    (date ? date : ""), (date ? "\"" : ""), mesglen));
                TRY(r = response_continuation(ssn, t));
                if (r == STATUS_CONTINUE) {
-                       TRY(send_continuation(ssn, mesg, mesglen)); 
+                       TRY(send_continuation(ssn, mesg, mesglen));
                        TRY(r = response_generic(ssn, t));
                }
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/response.c 
new/imapfilter-2.6.11/src/response.c
--- old/imapfilter-2.6.10/src/response.c        2016-12-16 08:11:27.000000000 
+0100
+++ new/imapfilter-2.6.11/src/response.c        2017-11-19 10:38:24.000000000 
+0100
@@ -68,7 +68,7 @@
 };
 
 
-int receive_response(session *ssn, char *buf, long timeout, int timeoutfail);
+int receive_response(session *ssn, char *buf, long timeout, int timeoutfail, 
int *interrupt);
 
 int check_tag(char *buf, session *ssn, int tag);
 int check_bye(char *buf);
@@ -80,12 +80,12 @@
  * Read data the server sent.
  */
 int
-receive_response(session *ssn, char *buf, long timeout, int timeoutfail)
+receive_response(session *ssn, char *buf, long timeout, int timeoutfail, int 
*interrupt)
 {
        ssize_t n;
 
        if ((n = socket_read(ssn, buf, INPUT_BUF, timeout ? timeout :
-           (long)(get_option_number("timeout")), timeoutfail)) == -1)
+           (long)(get_option_number("timeout")), timeoutfail, interrupt)) == 
-1)
                return -1;
 
 
@@ -219,7 +219,7 @@
 
        do {
                buffer_check(&ibuf, ibuf.len + INPUT_BUF);
-               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
+               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1, 
NULL)) ==
                    -1)
                        return -1;
                ibuf.len += n;
@@ -249,7 +249,7 @@
 
        do {
                buffer_check(&ibuf, ibuf.len + INPUT_BUF);
-               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
+               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1, 
NULL)) ==
                    -1)
                        return -1;
                ibuf.len += n;
@@ -279,7 +279,7 @@
 
        buffer_reset(&ibuf);
 
-       if (receive_response(ssn, ibuf.data, 0, 1) == -1)
+       if (receive_response(ssn, ibuf.data, 0, 1, NULL) == -1)
                return -1;
 
        verbose("S (%d): %s", ssn->socket, ibuf.data);
@@ -619,7 +619,7 @@
                return r;
 
        re = &responses[RESPONSE_FETCH];
-       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) { 
+       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) {
                s = xstrndup(ibuf.data + re->pmatch[1].rm_so,
                    re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
 
@@ -660,7 +660,7 @@
                return r;
 
        re = &responses[RESPONSE_FETCH];
-       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) { 
+       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) {
                s = xstrndup(ibuf.data + re->pmatch[1].rm_so,
                    re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
 
@@ -692,7 +692,7 @@
                return r;
 
        re = &responses[RESPONSE_FETCH];
-       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) { 
+       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) {
                s = xstrndup(ibuf.data + re->pmatch[1].rm_so,
                    re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
 
@@ -724,7 +724,7 @@
                return r;
 
        re = &responses[RESPONSE_FETCH];
-       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) { 
+       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) {
                s = xstrndup(ibuf.data + re->pmatch[1].rm_so,
                    re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
 
@@ -756,7 +756,7 @@
                return r;
 
        re = &responses[RESPONSE_FETCH];
-       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) { 
+       if (!regexec(re->preg, ibuf.data, re->nmatch, re->pmatch, 0)) {
                s = xstrndup(ibuf.data + re->pmatch[1].rm_so,
                    re->pmatch[1].rm_eo - re->pmatch[1].rm_so);
 
@@ -797,7 +797,7 @@
 
        do {
                buffer_check(&ibuf, ibuf.len + INPUT_BUF);
-               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1)) ==
+               if ((n = receive_response(ssn, ibuf.data + ibuf.len, 0, 1, 
NULL)) ==
                    -1)
                        return -1;
                ibuf.len += n;
@@ -843,6 +843,7 @@
 {
        regexp *re;
        ssize_t n;
+       int eintr = 0;
 
        if (tag == -1)
                return -1;
@@ -855,9 +856,13 @@
                do {
                        buffer_check(&ibuf, ibuf.len + INPUT_BUF);
                        n = receive_response(ssn, ibuf.data + ibuf.len,
-                           get_option_number("keepalive") * 60, 0);
-                       if (n < 0)
-                               return -1;
+                           get_option_number("keepalive") * 60, 0, &eintr);
+                       if (n < 0) {
+                               if (eintr)
+                                       return STATUS_INTERRUPT;
+                               else
+                                       return -1;
+                       }
                        if (n == 0)
                                return STATUS_TIMEOUT;
                        ibuf.len += n;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/signal.c 
new/imapfilter-2.6.11/src/signal.c
--- old/imapfilter-2.6.10/src/signal.c  2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/signal.c  2017-11-19 10:38:24.000000000 +0100
@@ -4,6 +4,7 @@
 
 
 void signal_handler(int sig);
+void user_signal_handler(int sig);
 
 
 /*
@@ -20,7 +21,7 @@
 
 
 /*
- * Release signals and reset them to default action.
+ * Reset signals to default action.
  */
 void
 release_signals(void)
@@ -33,7 +34,7 @@
 
 
 /*
- * Signal handler for signals that cause termination of program.
+ * Signal handler for signals that cause program's termination.
  */
 void
 signal_handler(int sig)
@@ -43,3 +44,39 @@
 
        fatal(ERROR_SIGNAL, "killed by signal %d\n", sig);
 }
+
+
+/*
+ * Ignore user-defined signals.
+ */
+void
+ignore_user_signals(void)
+{
+
+       signal(SIGUSR1, SIG_IGN);
+       signal(SIGUSR2, SIG_IGN);
+}
+
+
+/*
+ * Catch user-defined signals.
+ */
+void
+catch_user_signals(void)
+{
+
+       signal(SIGUSR1, user_signal_handler);
+       signal(SIGUSR2, user_signal_handler);
+}
+
+
+/*
+ * Signal handler for user-defined signals.
+ */
+void
+user_signal_handler(int sig)
+{
+
+       (void)sig;
+       ignore_user_signals();
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/socket.c 
new/imapfilter-2.6.11/src/socket.c
--- old/imapfilter-2.6.10/src/socket.c  2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/socket.c  2017-11-19 10:38:24.000000000 +0100
@@ -237,7 +237,7 @@
  * Read data from socket.
  */
 ssize_t
-socket_read(session *ssn, char *buf, size_t len, long timeout, int timeoutfail)
+socket_read(session *ssn, char *buf, size_t len, long timeout, int 
timeoutfail, int *interrupt)
 {
        int s;
        ssize_t r;
@@ -261,31 +261,48 @@
 
        FD_ZERO(&fds);
        FD_SET(ssn->socket, &fds);
- 
+
        if (ssn->sslconn) {
-               if (SSL_pending(ssn->sslconn) > 0 ||
-                   ((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
-                   FD_ISSET(ssn->socket, &fds))) {
+               if (SSL_pending(ssn->sslconn) > 0) {
                        r = socket_secure_read(ssn, buf, len);
-
                        if (r <= 0)
                                goto fail;
+               } else {
+                       if (interrupt != NULL)
+                               catch_user_signals();
+                       if ((s = select(ssn->socket + 1, &fds, NULL, NULL, 
tvp)) > 0) {
+                               if (interrupt != NULL)
+                                       ignore_user_signals();
+                               if (FD_ISSET(ssn->socket, &fds)) {
+                                       r = socket_secure_read(ssn, buf, len);
+                                       if (r <= 0)
+                                               goto fail;
+                               }
+                       }
                }
        } else {
-               if ((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
-                   FD_ISSET(ssn->socket, &fds)) {
-                       r = read(ssn->socket, buf, len);
-
-                       if (r == -1) {
-                               error("reading data; %s\n", strerror(errno));
-                               goto fail;
-                       } else if (r == 0) {
-                               goto fail;
+               if (interrupt != NULL)
+                       catch_user_signals();
+               if ((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0) {
+                       if (interrupt != NULL)
+                               ignore_user_signals();
+                       if (FD_ISSET(ssn->socket, &fds)) {
+                               r = read(ssn->socket, buf, len);
+                               if (r == -1) {
+                                       error("reading data; %s\n", 
strerror(errno));
+                                       goto fail;
+                               } else if (r == 0) {
+                                       goto fail;
+                               }
                        }
                }
        }
 
        if (s == -1) {
+               if (interrupt != NULL && errno == EINTR) {
+                       *interrupt = 1;
+                       return -1;
+               }
                error("waiting to read from socket; %s\n", strerror(errno));
                goto fail;
        } else if (s == 0 && timeoutfail) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/imapfilter-2.6.10/src/version.h 
new/imapfilter-2.6.11/src/version.h
--- old/imapfilter-2.6.10/src/version.h 2016-12-16 08:11:27.000000000 +0100
+++ new/imapfilter-2.6.11/src/version.h 2017-11-19 10:38:24.000000000 +0100
@@ -3,10 +3,10 @@
 
 
 /* Program's version number. */
-#define VERSION                "2.6.10"
+#define VERSION                "2.6.11"
 
 /* Program's copyright. */
-#define COPYRIGHT      "Copyright (c) 2001-2016 Eleftherios Chatzimparmpas"
+#define COPYRIGHT      "Copyright (c) 2001-2017 Eleftherios Chatzimparmpas"
 
 
 #endif                         /* VERSION_H */


Reply via email to