Skip to content
Permalink
Browse files

Handle iMIP/IMAP race condition in multi-pod mode.

  • Loading branch information...
cyrusdaboo committed Jul 15, 2015
1 parent 6d1e5c9 commit 9d50cb773e9638dd80587cde059b42c9414e21db
@@ -624,7 +624,7 @@ def cbGotMessage(self, results, messageList):
self.log.debug("IMAP in cbGotMessage")
try:
messageData = results.values()[0]['RFC822']
except IndexError:
except (IndexError, KeyError):
# results will be empty unless the "twistedmail-imap-flags-anywhere"
# patch from http://twistedmatrix.com/trac/ticket/1105 is applied
self.log.error("Skipping empty results -- apply twisted patch!")
@@ -60,6 +60,13 @@ def decorateTransaction(txn):
module = getModule(__name__)
self.dataPath = module.filePath.sibling("data")

self.wp = None
self.store.queuer.callWithNewProposals(self._proposalCallback)


def _proposalCallback(self, wp):
self.wp = wp


def dataFile(self, name):
"""
@@ -183,6 +190,7 @@ def test_processDSN(self):
calBody = template % token
result = (yield self.receiver.processDSN(calBody, "xyzzy"))
self.assertEquals(result, MailReceiver.INJECTION_SUBMITTED)
yield self.wp.whenExecuted()


@inlineCallbacks
@@ -205,6 +213,7 @@ def test_processReply(self):

result = (yield self.receiver.processReply(msg))
self.assertEquals(result, MailReceiver.INJECTION_SUBMITTED)
yield self.wp.whenExecuted()


def test_processReplyMissingOrganizer(self):
@@ -436,6 +445,33 @@ def stubCbFlagDeleted(result):
self.assertEquals(self.flagDeletedResult, "xyzzy")


@inlineCallbacks
def test_missingIMAPMessages(self):
"""
Make sure L{IMAP4DownloadProtocol.cbGotMessage} can deal with missing messages.
"""

class DummyResult(object):
def __init__(self):
self._values = []

def values(self):
return self._values

noResult = DummyResult()
missingKey = DummyResult()
missingKey.values().append({})

imap4 = IMAP4DownloadProtocol()
imap4.messageUIDs = []
imap4.fetchNextMessage = lambda : None

result = yield imap4.cbGotMessage(noResult, [])
self.assertTrue(result is None)
result = yield imap4.cbGotMessage(missingKey, [])
self.assertTrue(result is None)



class StubFactory(object):

0 comments on commit 9d50cb7

Please sign in to comment.
You can’t perform that action at this time.