[Asterisk-code-review] app_voicemail: Add lock_file_cleanup configuration option (...asterisk[13])

Sean Bright asteriskteam at digium.com
Mon Oct 7 12:41:34 CDT 2019


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13012


Change subject: app_voicemail: Add lock_file_cleanup configuration option
......................................................................

app_voicemail: Add lock_file_cleanup configuration option

The functionality added in ASTERISK~20207 to clean up orphaned voicemail
lock files causes problems on systems where voicemail is stored on
network filesystems and potentially other exotic setups.

It is now disabled by default and needs to be enabled in voicemail.conf
by setting 'lock_file_cleanup' to 'yes.'

ASTERISK-28567 #close

Change-Id: I33454b7e7079dc406149aab9a2df3dae18476825
---
M apps/app_voicemail.c
M configs/samples/voicemail.conf.sample
A doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt
3 files changed, 24 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/13012/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 1134ccd..ad6f820 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -928,6 +928,8 @@
 
 static char VM_SPOOL_DIR[PATH_MAX];
 
+static int perform_orphaned_lock_file_cleanup;
+
 static char ext_pass_cmd[128];
 static char ext_pass_check_cmd[128];
 
@@ -14498,6 +14500,10 @@
 			ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");
 		}
 
+		if ((val = ast_variable_retrieve(cfg, "general", "lock_file_cleanup"))) {
+			perform_orphaned_lock_file_cleanup = ast_true(val);
+		}
+
 		/* load mailboxes from users.conf */
 		if (ucfg) {
 			for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
@@ -15362,9 +15368,6 @@
 	/* compute the location of the voicemail spool directory */
 	snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
 
-	/* Now that we have a spool directory, clean up old lock files */
-	cleanup_orphaned_lock_files(VM_SPOOL_DIR);
-
 	if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) {
 		ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor.  MWI will not work\n");
 	}
@@ -15374,6 +15377,11 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
+	/* Clean up old lock files, if desired */
+	if (perform_orphaned_lock_file_cleanup) {
+		cleanup_orphaned_lock_files(VM_SPOOL_DIR);
+	}
+
 	res = ast_register_application_xml(app, vm_exec);
 	res |= ast_register_application_xml(app2, vm_execmain);
 	res |= ast_register_application_xml(app3, vm_box_exists);
diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample
index 30054b5..430ea2f 100644
--- a/configs/samples/voicemail.conf.sample
+++ b/configs/samples/voicemail.conf.sample
@@ -201,6 +201,14 @@
 ;                    ; 30 seconds.
 ;
 
+; If Asterisk crashes while someone is leaving a voicemail, it is possible for
+; lock files to be left on the filesystem which will prevent the user from being
+; able to check their messages and receive new ones. Setting 'lock_file_cleanup'
+; to 'yes' will instruct Asterisk to remove all lock files on startup. If you
+; have a large number of voicemail users, or your voicemail is stored on
+; network-attached storage, you probably don't want to set this.
+;lock_file_cleanup=yes
+
 ; -----------------------------------------------------------------------------
 ; IMAP configuration settings only
 ;   These settings are only applicable when Asterisk is compiled with IMAP support.
diff --git a/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt b/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt
new file mode 100644
index 0000000..21dd32e
--- /dev/null
+++ b/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt
@@ -0,0 +1,5 @@
+Subject: app_voicemail.c
+
+The functionality to clean up orphaned lock files is now configurable by
+a new configuration option in voicemail.conf named 'lock_file_cleanup.'
+The default is 'no.'

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13012
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I33454b7e7079dc406149aab9a2df3dae18476825
Gerrit-Change-Number: 13012
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191007/ee5ae203/attachment.html>


More information about the asterisk-code-review mailing list