diff --git a/imap/mupdate.c b/imap/mupdate.c index b6cc1cb..c1fbf15 100644 --- a/imap/mupdate.c +++ b/imap/mupdate.c @@ -2369,6 +2369,7 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) struct txn *tid = NULL; int ret = 0; int err = 0; + int tcount = 0; rock.pool = pool; @@ -2416,6 +2417,7 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0), r->server, r->acl, &tid); + tcount++; } } /* Okay, dump these two */ @@ -2442,6 +2444,7 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) err++; } else { mboxlist_deleteremote(l->mailbox, &tid); + tcount++; } local_boxes.head = l->next; } else /* (ret > 0) */ { @@ -2450,8 +2453,16 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0), r->server, r->acl, &tid); + tcount++; remote_boxes->head = r->next; } + if (tcount >= 256) { + syslog(LOG_NOTICE, + "hit 256 changes, committing partial mupdate sync"); + mboxlist_commit(tid); + tid = NULL; + tcount = 0; + } } if(l && !r) { @@ -2464,9 +2475,17 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) err++; } else { mboxlist_deleteremote(l->mailbox, &tid); + tcount++; } local_boxes.head = l->next; l = local_boxes.head; + if (tcount >= 256) { + syslog(LOG_NOTICE, + "hit 256 changes, committing partial mupdate sync"); + mboxlist_commit(tid); + tid = NULL; + tcount = 0; + } } } else if (r && !l) { /* we have more inserts to do */ @@ -2475,8 +2494,16 @@ int mupdate_synchronize(struct mbent_queue *remote_boxes, struct mpool *pool) (r->t == SET_RESERVE ? MBTYPE_RESERVE : 0), r->server, r->acl, &tid); + tcount++; remote_boxes->head = r->next; r = remote_boxes->head; + if (tcount >= 256) { + syslog(LOG_NOTICE, + "hit 256 changes, committing partial mupdate sync"); + mboxlist_commit(tid); + tid = NULL; + tcount = 0; + } } }