[asterisk-commits] app voicemail: IMAP logout on reload/unload (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 19 08:52:12 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5866 )

Change subject: app_voicemail: IMAP logout on reload/unload
......................................................................

app_voicemail: IMAP logout on reload/unload

Closing IMAP connection on module reload or unload.

ASTERISK-24052 #close

Change-Id: I2a40182aa9ef249fa6865d33570430e9ada68525
---
M apps/app_voicemail.c
1 file changed, 23 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 8f50e11..a951680 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -13134,10 +13134,25 @@
 		return;
 	}
 
+	ast_mutex_lock(&vms->lock);
 	vms->mailstream = mail_close(vms->mailstream);
+	ast_mutex_unlock(&vms->lock);
+
 	vmstate_delete(vms);
 }
 
+static void imap_close_subscribed_mailboxes(void)
+{
+	struct mwi_sub *mwi_sub;
+
+	AST_RWLIST_RDLOCK(&mwi_subs);
+	AST_RWLIST_TRAVERSE(&mwi_subs, mwi_sub, entry) {
+		if (!ast_strlen_zero(mwi_sub->mailbox)) {
+			imap_logout(mwi_sub->mailbox);
+		}
+	}
+	AST_RWLIST_UNLOCK(&mwi_subs);
+}
 #endif
 
 static int handle_unsubscribe(void *datap)
@@ -13591,7 +13606,11 @@
 	strcpy(listen_control_restart_key, DEFAULT_LISTEN_CONTROL_RESTART_KEY);
 	strcpy(listen_control_stop_key, DEFAULT_LISTEN_CONTROL_STOP_KEY);
 
-	/* Free all the users structure */	
+#ifdef IMAP_STORAGE
+	imap_close_subscribed_mailboxes();
+#endif
+
+	/* Free all the users structure */
 	free_vm_users();
 
 	/* Free all the zones structure */
@@ -14985,6 +15004,9 @@
 	ast_unload_realtime("voicemail");
 	ast_unload_realtime("voicemail_data");
 
+#ifdef IMAP_STORAGE
+	imap_close_subscribed_mailboxes();
+#endif
 	free_vm_users();
 	free_vm_zones();
 	return res;

-- 
To view, visit https://gerrit.asterisk.org/5866
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2a40182aa9ef249fa6865d33570430e9ada68525
Gerrit-Change-Number: 5866
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170619/ed941605/attachment-0001.html>


More information about the asterisk-commits mailing list