commit-mailutils
[Top][All Lists]
Advanced

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

[SCM] GNU Mailutils branch, master, updated. release-2.2-299-g68d83f0


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-299-g68d83f0
Date: Sun, 19 Dec 2010 20:28:29 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=68d83f0d247aaa3331bf8e4a29b89687c9b2e6ea

The branch, master has been updated
       via  68d83f0d247aaa3331bf8e4a29b89687c9b2e6ea (commit)
       via  094f5d94f39d5476e33dfb4e38e394746972ec74 (commit)
      from  ee7479485f6b252eb131533a6a7d1ab20283719e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 68d83f0d247aaa3331bf8e4a29b89687c9b2e6ea
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Dec 19 22:26:28 2010 +0200

    maildir: speed up mailbox scanning
    
    * include/mailutils/sys/amd.h (_amd_message_lookup_or_insert): New proto.
    * libmailutils/base/amd.c (_amd_message_lookup_or_insert): New function.
    (_amd_message_insert): Rewrite using _amd_message_lookup_or_insert.
    * libproto/maildir/mbox.c (maildir_message_cmp): Stop comparison on
    ':'.
    (maildir_message_lookup): Remove.
    (maildir_scan_dir): Use _amd_message_lookup_or_insert.
    
    * po/POTFILES.in: Update.

commit 094f5d94f39d5476e33dfb4e38e394746972ec74
Author: Sergey Poznyakoff <address@hidden>
Date:   Sun Dec 19 19:00:58 2010 +0200

    Minor fixes.
    
    * include/mailutils/debug.h (mu_debug_log_nl): New proto.
    * libmailutils/diag/debug.c (mu_debug_log_nl): New function.
    * libmailutils/mailer/progmailer.c: Use mu_debug_log_nl.
    * libmailutils/server/acl.c: Likewise.
    Also, use MU_DEBUG_TRACE9 instead of the numeric value.
    
    * libmailutils/filter/iconvflt.c (_iconv_filter): Register encoder
    (same as decoder).

-----------------------------------------------------------------------

Summary of changes:
 include/mailutils/debug.h        |    2 +
 include/mailutils/sys/amd.h      |    3 ++
 libmailutils/base/amd.c          |   35 ++++++++++++++++----
 libmailutils/diag/debug.c        |    6 +++
 libmailutils/filter/iconvflt.c   |    2 +-
 libmailutils/mailer/progmailer.c |    2 +-
 libmailutils/server/acl.c        |   18 +++++-----
 libproto/maildir/mbox.c          |   67 ++++++++++++++++---------------------
 po/POTFILES.in                   |    1 -
 9 files changed, 79 insertions(+), 57 deletions(-)

diff --git a/include/mailutils/debug.h b/include/mailutils/debug.h
index adad023..d5673a4 100644
--- a/include/mailutils/debug.h
+++ b/include/mailutils/debug.h
@@ -71,6 +71,8 @@ void mu_debug_log (const char *fmt, ...) MU_PRINTFLIKE(1,2);
 void mu_debug_log_begin (const char *fmt, ...) MU_PRINTFLIKE(1,2);
 void mu_debug_log_cont (const char *fmt, ...) MU_PRINTFLIKE(1,2);
 void mu_debug_log_end (const char *fmt, ...) MU_PRINTFLIKE(1,2);
+void mu_debug_log_nl (void);
+
   
   
 #define MU_ASSERT(expr)                                                \
diff --git a/include/mailutils/sys/amd.h b/include/mailutils/sys/amd.h
index fde26da..2bc8dc7 100644
--- a/include/mailutils/sys/amd.h
+++ b/include/mailutils/sys/amd.h
@@ -106,6 +106,9 @@ struct _amd_data
 
 int amd_init_mailbox (mu_mailbox_t mailbox, size_t mhd_size,
                      struct _amd_data **pmhd);
+int _amd_message_lookup_or_insert (struct _amd_data *amd,
+                                  struct _amd_message *key,
+                                  size_t *pindex);
 int _amd_message_insert (struct _amd_data *mhd, struct _amd_message *msg);
 int amd_message_stream_open (struct _amd_message *mhm);
 void amd_message_stream_close (struct _amd_message *mhm);
diff --git a/libmailutils/base/amd.c b/libmailutils/base/amd.c
index b41ff21..f77cf3a 100644
--- a/libmailutils/base/amd.c
+++ b/libmailutils/base/amd.c
@@ -1336,27 +1336,48 @@ amd_cleanup (void *arg)
   mu_locker_unlock (mailbox->locker);
 }
 
+int
+_amd_message_lookup_or_insert (struct _amd_data *amd,
+                              struct _amd_message *key,
+                              size_t *pindex)
+{
+  int result = 0;
+  size_t index;
+  if (amd_msg_lookup (amd, key, &index))
+    {
+      /* Not found. Index points to the array cell where msg would
+        be placed */
+      result = amd_array_expand (amd, index);
+      if (result)
+       return result;
+      else
+       result = MU_ERR_NOENT;
+    }
+  else
+    result = 0;
+  *pindex = index;
+  return result;
+}
+
 /* Insert message msg into the message list on the appropriate position */
 int
 _amd_message_insert (struct _amd_data *amd, struct _amd_message *msg)
 {
   size_t index;
+  int rc = _amd_message_lookup_or_insert (amd, msg, &index);
 
-  if (amd_msg_lookup (amd, msg, &index))
+  if (rc == MU_ERR_NOENT)
     {
-      /* Not found. Index is the index of the array cell where msg
-        must be placed */
-      int rc = amd_array_expand (amd, index);
-      if (rc)
-       return rc;
       amd->msg_array[index] = msg;
       msg->amd = amd;
     }
-  else
+  else if (rc == 0)
     {
       /*FIXME: Found? Shouldn't happen */
       return EEXIST;
     }
+  else
+    return rc;
   return 0;
 }
 
diff --git a/libmailutils/diag/debug.c b/libmailutils/diag/debug.c
index 70f1d5a..a71a846 100644
--- a/libmailutils/diag/debug.c
+++ b/libmailutils/diag/debug.c
@@ -357,3 +357,9 @@ mu_debug_log_end (const char *fmt, ...)
   mu_stream_write (mu_strerr, "\n", 1, NULL);
   va_end (ap);
 }
+
+void
+mu_debug_log_nl ()
+{
+  mu_stream_write (mu_strerr, "\n", 1, NULL);
+}
diff --git a/libmailutils/filter/iconvflt.c b/libmailutils/filter/iconvflt.c
index fbd3066..3c9565f 100644
--- a/libmailutils/filter/iconvflt.c
+++ b/libmailutils/filter/iconvflt.c
@@ -246,7 +246,7 @@ alloc_state (void **pret, int mode MU_ARG_UNUSED, int argc, 
const char **argv)
 static struct _mu_filter_record _iconv_filter = {
   "ICONV",
   alloc_state,
-  NULL,
+  _icvt_decoder,
   _icvt_decoder  
 };
 
diff --git a/libmailutils/mailer/progmailer.c b/libmailutils/mailer/progmailer.c
index aa5cfda..73f81e7 100644
--- a/libmailutils/mailer/progmailer.c
+++ b/libmailutils/mailer/progmailer.c
@@ -154,7 +154,7 @@ mu_progmailer_open (struct _mu_progmailer *pm, char **argv)
       mu_debug_log_begin ("exec %s argv:", pm->command);
       for (i = 0; argv[i]; i++)
         mu_debug_log_cont (" %s", argv[i]);
-      mu_debug_log_end ("");
+      mu_debug_log_nl ();
     }
   close (tunnel[0]);
 
diff --git a/libmailutils/server/acl.c b/libmailutils/server/acl.c
index af55188..5cebc99 100644
--- a/libmailutils/server/acl.c
+++ b/libmailutils/server/acl.c
@@ -397,10 +397,10 @@ int
 _acl_match (struct _mu_acl_entry *ent, struct sockaddr *sa, int salen)
 {
 #define RESMATCH(word)                                   \
-  if (mu_debug_level_p (MU_DEBCAT_ACL, 10))     \
+  if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))     \
     mu_debug_log_end ("%s; ", word);
                                                              
-  if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
+  if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
     {
       struct in_addr a;
       
@@ -653,7 +653,7 @@ _run_entry (void *item, void *data)
 
   rp->idx++;
 
-  if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
+  if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
     {
       const char *s = "undefined";
       mu_acl_action_to_string (ent->action, &s);
@@ -679,13 +679,13 @@ _run_entry (void *item, void *data)
            char *s;
            if (ent->arg && expand_arg (ent->arg, rp, &s) == 0)
              {
-               if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
+               if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
                  mu_debug_log_end ("%s", s);
                free (s);
              }
            else
              {
-               if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
+               if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
                  {
                    debug_sockaddr (rp->sa, rp->salen);
                    mu_debug_log_end ("");
@@ -721,8 +721,8 @@ _run_entry (void *item, void *data)
        }
     }
   
-  if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
-     mu_debug_log_end ("");
+  if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
+     mu_debug_log_nl ();
   
   return status;
 }
@@ -747,11 +747,11 @@ mu_acl_check_sockaddr (mu_acl_t acl, const struct 
sockaddr *sa, int salen,
     }
   r.salen = salen;
   
-  if (mu_debug_level_p (MU_DEBCAT_ACL, 10))
+  if (mu_debug_level_p (MU_DEBCAT_ACL, MU_DEBUG_TRACE9))
     {
       mu_debug_log_begin ("Checking sockaddr ");
       debug_sockaddr (r.sa, r.salen);
-      mu_debug_log_end ("");
+      mu_debug_log_nl ();
     }
 
   r.idx = 0;
diff --git a/libproto/maildir/mbox.c b/libproto/maildir/mbox.c
index 02b090e..1f245ec 100644
--- a/libproto/maildir/mbox.c
+++ b/libproto/maildir/mbox.c
@@ -164,11 +164,8 @@ maildir_message_cmp (struct _amd_message *a, struct 
_amd_message *b)
     if ((rc = (*name_a - *name_b)))
       return rc;
 
-  if (*name_a == ':' && *name_b == ':')
-    {
-      name_a++;
-      name_b++;
-    }
+  if ((*name_a == ':' || *name_a == 0) && (*name_b == ':' || *name_b == 0))
+    return 0;
 
   return *name_a - *name_b;
 }
@@ -579,33 +576,14 @@ maildir_deliver_new (struct _amd_data *amd, DIR *dir)
   return 0;
 }
 
-static struct _maildir_message *
-maildir_message_lookup (struct _amd_data *amd, char *file_name)
-{
-  struct _maildir_message *msg;
-  char *p = strchr (file_name, ':');
-  size_t length = p ? p - file_name : strlen (file_name);
-  size_t i;
-  
-  /*FIXME: Replace linear search with binary one! */
-  for (i = 0; i < amd->msg_count; i++)
-    {
-      msg = (struct _maildir_message *) amd->msg_array[i];
-
-      if (strlen (msg->file_name) <= length
-         && memcmp (msg->file_name, file_name, length) == 0)
-       return msg;
-    }
-  return NULL;
-}
-
 static int
 maildir_scan_dir (struct _amd_data *amd, DIR *dir, char *dirname)
 {
   struct dirent *entry;
-  struct _maildir_message *msg;
+  struct _maildir_message *msg, key;
   char *p;
-  int insert;
+  size_t index;
+  int rc = 0;
 
   while ((entry = readdir (dir)))
     {
@@ -615,18 +593,32 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir, char 
*dirname)
          break;
 
        default:
-         msg = maildir_message_lookup (amd, entry->d_name);
-         if (msg)
+         key.file_name = entry->d_name;
+         rc = _amd_message_lookup_or_insert (amd,
+                                             (struct _amd_message *)&key,
+                                             &index);
+         if (rc == MU_ERR_NOENT)
            {
-             free (msg->file_name);
-             insert = 0;
+             /* Message not found. Index pointd to the array cell where it
+                would be placed */
+             msg = calloc (1, sizeof (*msg));
+             if (!msg)
+               {
+                 rc = ENOMEM;
+                 break;
+               }
+             amd->msg_array[index] = (struct _amd_message *)msg;
+             msg->amd_message.amd = amd;
+             rc = 0;
            }
-         else
+         else if (rc == 0)
            {
-             msg = calloc (1, sizeof(*msg));
-             insert = 1;
+             msg = (struct _maildir_message *)amd->msg_array[index];
+             free (msg->file_name);
            }
-         
+         else
+           break;
+             
          msg->dir = dirname;
          msg->file_name = strdup (entry->d_name);
 
@@ -636,11 +628,10 @@ maildir_scan_dir (struct _amd_data *amd, DIR *dir, char 
*dirname)
          else
            msg->amd_message.attr_flags = 0;
          msg->amd_message.orig_flags = msg->amd_message.attr_flags;
-         if (insert)
-           _amd_message_insert (amd, (struct _amd_message*) msg);
        }
     }
-  return 0;
+
+  return rc;
 }
 
 static int
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 90d5cd9..949a0b0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -37,7 +37,6 @@ lib/tcpwrap.c
 lib/xmalloc.c
 lib/strexit.c
 
-libmu_argp/auth.c
 libmu_argp/cmdline.c
 libmu_argp/common.c
 libmu_argp/mu_argp.c


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]