From 67f4aeff1febc9bf750a927052c467fee15ba276 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Dec 2016 14:10:35 +0100 Subject: [PATCH 1/7] standardize on 'int' for message sizes that's what the sources already assumed anyway. size_t is total overkill, as No Email Ever (TM) will exceed 2GiB. this also fixes a harmless format string warning in 32 bit builds. --- src/driver.h | 4 ++-- src/sync.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/driver.h b/src/driver.h index dcf9255..3b3ae1b 100644 --- a/src/driver.h +++ b/src/driver.h @@ -39,7 +39,7 @@ typedef struct store_conf { const char *flat_delim; const char *map_inbox; const char *trash; - uint max_size; /* off_t is overkill */ + int max_size; /* off_t is overkill */ char trash_remote_new, trash_only_new; } store_conf_t; @@ -64,7 +64,7 @@ typedef struct message { struct message *next; struct sync_rec *srec; /* string_list_t *keywords; */ - size_t size; /* zero implies "not fetched" */ + int size; /* zero implies "not fetched" */ int uid; uchar flags, status; char tuid[TUIDL]; diff --git a/src/sync.c b/src/sync.c index 4fb2026..835547a 100644 --- a/src/sync.c +++ b/src/sync.c @@ -1369,7 +1369,7 @@ box_loaded( int sts, void *aux ) uid = tmsg->uid; if (DFlags & DEBUG_SYNC) { make_flags( tmsg->flags, fbuf ); - printf( svars->ctx[t]->opts & OPEN_SIZE ? " message %5d, %-4s, %6lu: " : " message %5d, %-4s: ", uid, fbuf, tmsg->size ); + printf( svars->ctx[t]->opts & OPEN_SIZE ? " message %5d, %-4s, %6d: " : " message %5d, %-4s: ", uid, fbuf, tmsg->size ); } idx = (uint)((uint)uid * 1103515245U) % hashsz; while (srecmap[idx].uid) { From 2457b2baa329384294488b8eb9803a4c86788fad Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 15 Feb 2017 17:25:59 +0100 Subject: [PATCH 2/7] don't arbitrarily limit UIDs to a billion, part 2 imap_find_new_msgs() had the same fixed limit as imap_load_box(). amends 815822d8. --- src/drv_imap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 83b0358..1fa727f 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -2637,7 +2637,7 @@ imap_find_new_msgs_p2( imap_store_t *ctx, struct imap_cmd *gcmd, int response ) } INIT_IMAP_CMD(imap_cmd_simple, cmd, cmdp->gen.callback, cmdp->gen.callback_aux) imap_exec( (imap_store_t *)ctx, &cmd->gen, imap_done_simple_box, - "UID FETCH %d:1000000000 (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])", cmdp->uid ); + "UID FETCH %d:" stringify(INT_MAX) " (UID BODY.PEEK[HEADER.FIELDS (X-TUID)])", cmdp->uid ); } /******************* imap_list_store *******************/ From 3ebb066aba7249bc85d4fd6adebe48eb543719a7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 28 Jan 2017 18:26:12 +0100 Subject: [PATCH 3/7] make -DN print also the sent data --- src/drv_imap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/drv_imap.c b/src/drv_imap.c index 1fa727f..3d66243 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -302,6 +302,12 @@ send_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd ) iov[0].len = bufl; iov[0].takeOwn = KeepOwn; if (litplus) { + if (DFlags & DEBUG_NET_ALL) { + printf( "%s>>>>>>>>>\n", ctx->label ); + fwrite( cmd->param.data, cmd->param.data_len, 1, stdout ); + printf( "%s>>>>>>>>>\n", ctx->label ); + fflush( stdout ); + } iov[1].buf = cmd->param.data; iov[1].len = cmd->param.data_len; iov[1].takeOwn = GiveOwn; @@ -1338,6 +1344,12 @@ imap_socket_read( void *aux ) if (cmdp->param.data) { if (cmdp->param.to_trash) ctx->trashnc = TrashKnown; /* Can't get NO [TRYCREATE] any more. */ + if (DFlags & DEBUG_NET_ALL) { + printf( "%s>>>>>>>>>\n", ctx->label ); + fwrite( cmdp->param.data, cmdp->param.data_len, 1, stdout ); + printf( "%s>>>>>>>>>\n", ctx->label ); + fflush( stdout ); + } iov[0].buf = cmdp->param.data; iov[0].len = cmdp->param.data_len; iov[0].takeOwn = GiveOwn; From f62b3c7be96a194854073bca1478586f0f63d9dc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 15 Feb 2017 11:45:52 +0100 Subject: [PATCH 4/7] fix mislabeling of test --- src/run-tests.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 7c7d3fd..829791c 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -222,7 +222,7 @@ my @X51 = ( [ 6, 3, 0, 2, 2, "FS", 4, 4, "", 5, 5, "", 6, 6, "" ], ); -test("max messages + expire", \@x50, \@X51, @O51); +test("max messages + expunge", \@x50, \@X51, @O51); ################################################################################ From f934e995d6f871c3ca269835b2f990f63055c9fc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 11 Mar 2017 13:27:53 +0100 Subject: [PATCH 5/7] don't populate sync record map with invalid UIDs this would obviously just bloat the hash with nonsense, slowing down the actual lookup later. --- src/sync.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sync.c b/src/sync.c index 835547a..485e419 100644 --- a/src/sync.c +++ b/src/sync.c @@ -1356,6 +1356,8 @@ box_loaded( int sts, void *aux ) if (srec->status & S_DEAD) continue; uid = srec->uid[t]; + if (uid <= 0) + continue; idx = (uint)((uint)uid * 1103515245U) % hashsz; while (srecmap[idx].uid) if (++idx == hashsz) From b45e711da588c5111c64345c50afa76a1b6ceeda Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 14 Mar 2017 11:09:38 +0100 Subject: [PATCH 6/7] autotest: remove stray close() call from printstate() --- src/run-tests.pl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 829791c..d8ff1b6 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -603,7 +603,6 @@ sub printstate(@) print shift(@t).", ".shift(@t).", \"".shift(@t)."\""; } print " ],\n"; - close FILE; } # \@chan_state From 62808c900367d8019c249513a9cfcbc81d053fdc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 14 Mar 2017 11:10:35 +0100 Subject: [PATCH 7/7] autotest: use warnings --- src/run-tests.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/run-tests.pl b/src/run-tests.pl index d8ff1b6..d1121c5 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -16,6 +16,7 @@ # along with this program. If not, see . # +use warnings; use strict; use File::Path;