Skip to content

Commit e69809e

Browse files
committed
mod_smtp_delivery_external: Abort cleanly if unloaded while busy.
If the queue_handler thread is in the middle of attempting to deliver a message when an unload is requested, the current operation will be interrupted and fail with EINTR. This was intended to interrupt bbs_safe_sleep_interrupt and cause it to abort the loop. However, the delivery operation would get interrupted and we would simply continue on to calling bbs_safe_sleep_interrupt, and because this is after the thread was interrupted, we would not exit as we are supposed. Check if an unload is in progress after any queue delivery attempts and prior to calling bbs_safe_sleep_interrupt again, so that we unload regardless of what the thread is doing when interrupted. LBBS-144 #close
1 parent f9c9a95 commit e69809e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

modules/mod_smtp_delivery_external.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,10 @@ static void *queue_handler(void *unused)
16561656
* we want this time. */
16571657
last_periodic_queue_run = time(NULL);
16581658

1659+
if (unloading) {
1660+
break; /* If we got interrupted by unload_module, it may be time to exit now */
1661+
}
1662+
16591663
/* Don't use usleep, as the SIGURG signal doesn't succeed in interrupting it */
16601664
if (bbs_safe_sleep_interrupt(SEC_MS((int) queue_interval))) {
16611665
bbs_debug(5, "Safe sleep returned\n");

0 commit comments

Comments
 (0)