forked from Silverfish/proton-bridge
Do not unpause event loop if other mailbox is still fetching
This commit is contained in:
@ -454,8 +454,8 @@ func (im *imapMailbox) ListMessages(isUID bool, seqSet *imap.SeqSet, items []ima
|
|||||||
// EXPUNGE cannot be sent during listing and can come only from
|
// EXPUNGE cannot be sent during listing and can come only from
|
||||||
// the event loop, so we prevent any server side update to avoid
|
// the event loop, so we prevent any server side update to avoid
|
||||||
// the problem.
|
// the problem.
|
||||||
im.storeUser.PauseEventLoop(true)
|
im.user.pauseEventLoop()
|
||||||
defer im.storeUser.PauseEventLoop(false)
|
defer im.user.unpauseEventLoop()
|
||||||
|
|
||||||
var markAsReadIDs []string
|
var markAsReadIDs []string
|
||||||
markAsReadMutex := &sync.Mutex{}
|
markAsReadMutex := &sync.Mutex{}
|
||||||
|
|||||||
@ -42,11 +42,9 @@ type imapUser struct {
|
|||||||
currentAddressLowercase string
|
currentAddressLowercase string
|
||||||
|
|
||||||
appendInProcess sync.WaitGroup
|
appendInProcess sync.WaitGroup
|
||||||
}
|
|
||||||
|
|
||||||
// This method should eventually no longer be necessary. Everything should go via store.
|
eventLoopPausingCounter int
|
||||||
func (iu *imapUser) client() pmapi.Client {
|
eventLoopPausingLocker sync.Locker
|
||||||
return iu.user.GetTemporaryPMAPIClient()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newIMAPUser returns struct implementing go-imap/user interface.
|
// newIMAPUser returns struct implementing go-imap/user interface.
|
||||||
@ -78,9 +76,41 @@ func newIMAPUser(
|
|||||||
storeAddress: storeAddress,
|
storeAddress: storeAddress,
|
||||||
|
|
||||||
currentAddressLowercase: strings.ToLower(address),
|
currentAddressLowercase: strings.ToLower(address),
|
||||||
|
|
||||||
|
eventLoopPausingLocker: &sync.Mutex{},
|
||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This method should eventually no longer be necessary. Everything should go via store.
|
||||||
|
func (iu *imapUser) client() pmapi.Client {
|
||||||
|
return iu.user.GetTemporaryPMAPIClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
// pauseEventLoop pauses event loop and increases the number of mailboxes which
|
||||||
|
// is performing action forbidding event loop to run (such as FETCH which needs
|
||||||
|
// UIDs to be stable and thus EXPUNGE cannot be done during the request).
|
||||||
|
func (iu *imapUser) pauseEventLoop() {
|
||||||
|
iu.eventLoopPausingLocker.Lock()
|
||||||
|
defer iu.eventLoopPausingLocker.Unlock()
|
||||||
|
|
||||||
|
iu.eventLoopPausingCounter++
|
||||||
|
iu.storeUser.PauseEventLoop(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// unpauseEventLoop unpauses event loop but only if no other request is not
|
||||||
|
// performing action forbidding event loop to run (see pauseEventLoop).
|
||||||
|
func (iu *imapUser) unpauseEventLoop() {
|
||||||
|
iu.eventLoopPausingLocker.Lock()
|
||||||
|
defer iu.eventLoopPausingLocker.Unlock()
|
||||||
|
|
||||||
|
if iu.eventLoopPausingCounter > 0 {
|
||||||
|
iu.eventLoopPausingCounter--
|
||||||
|
}
|
||||||
|
if iu.eventLoopPausingCounter == 0 {
|
||||||
|
iu.storeUser.PauseEventLoop(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (iu *imapUser) isSubscribed(labelID string) bool {
|
func (iu *imapUser) isSubscribed(labelID string) bool {
|
||||||
subscriptionExceptions := iu.backend.getCacheList(iu.storeUser.UserID(), SubscriptionException)
|
subscriptionExceptions := iu.backend.getCacheList(iu.storeUser.UserID(), SubscriptionException)
|
||||||
exceptions := strings.Split(subscriptionExceptions, ";")
|
exceptions := strings.Split(subscriptionExceptions, ";")
|
||||||
|
|||||||
@ -52,3 +52,4 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* GODT-900 Remove \Deleted flag after re-importing the message (do not delete messages by moving to local folder and back).
|
* GODT-900 Remove \Deleted flag after re-importing the message (do not delete messages by moving to local folder and back).
|
||||||
|
* GODT-908 Do not unpause event loop if other mailbox is still fetching.
|
||||||
|
|||||||
Reference in New Issue
Block a user