<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13012">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_voicemail: Add lock_file_cleanup configuration option<br><br>The functionality added in ASTERISK~20207 to clean up orphaned voicemail<br>lock files causes problems on systems where voicemail is stored on<br>network filesystems and potentially other exotic setups.<br><br>It is now disabled by default and needs to be enabled in voicemail.conf<br>by setting 'lock_file_cleanup' to 'yes.'<br><br>ASTERISK-28567 #close<br><br>Change-Id: I33454b7e7079dc406149aab9a2df3dae18476825<br>---<br>M apps/app_voicemail.c<br>M configs/samples/voicemail.conf.sample<br>A doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt<br>3 files changed, 24 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/12/13012/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c</span><br><span>index 1134ccd..ad6f820 100644</span><br><span>--- a/apps/app_voicemail.c</span><br><span>+++ b/apps/app_voicemail.c</span><br><span>@@ -928,6 +928,8 @@</span><br><span> </span><br><span> static char VM_SPOOL_DIR[PATH_MAX];</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int perform_orphaned_lock_file_cleanup;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static char ext_pass_cmd[128];</span><br><span> static char ext_pass_check_cmd[128];</span><br><span> </span><br><span>@@ -14498,6 +14500,10 @@</span><br><span>                      ast_log(AST_LOG_WARNING, "Failed to set alert levels for voicemail taskprocessor.\n");</span><br><span>             }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+         if ((val = ast_variable_retrieve(cfg, "general", "lock_file_cleanup"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 perform_orphaned_lock_file_cleanup = ast_true(val);</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>          /* load mailboxes from users.conf */</span><br><span>                 if (ucfg) {</span><br><span>                  for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {</span><br><span>@@ -15362,9 +15368,6 @@</span><br><span>  /* compute the location of the voicemail spool directory */</span><br><span>  snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  /* Now that we have a spool directory, clean up old lock files */</span><br><span style="color: hsl(0, 100%, 40%);">-       cleanup_orphaned_lock_files(VM_SPOOL_DIR);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>   if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) {</span><br><span>                 ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor.  MWI will not work\n");</span><br><span>      }</span><br><span>@@ -15374,6 +15377,11 @@</span><br><span>                 return AST_MODULE_LOAD_DECLINE;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* Clean up old lock files, if desired */</span><br><span style="color: hsl(120, 100%, 40%);">+     if (perform_orphaned_lock_file_cleanup) {</span><br><span style="color: hsl(120, 100%, 40%);">+             cleanup_orphaned_lock_files(VM_SPOOL_DIR);</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  res = ast_register_application_xml(app, vm_exec);</span><br><span>    res |= ast_register_application_xml(app2, vm_execmain);</span><br><span>      res |= ast_register_application_xml(app3, vm_box_exists);</span><br><span>diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample</span><br><span>index 30054b5..430ea2f 100644</span><br><span>--- a/configs/samples/voicemail.conf.sample</span><br><span>+++ b/configs/samples/voicemail.conf.sample</span><br><span>@@ -201,6 +201,14 @@</span><br><span> ;                    ; 30 seconds.</span><br><span> ;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+; If Asterisk crashes while someone is leaving a voicemail, it is possible for</span><br><span style="color: hsl(120, 100%, 40%);">+; lock files to be left on the filesystem which will prevent the user from being</span><br><span style="color: hsl(120, 100%, 40%);">+; able to check their messages and receive new ones. Setting 'lock_file_cleanup'</span><br><span style="color: hsl(120, 100%, 40%);">+; to 'yes' will instruct Asterisk to remove all lock files on startup. If you</span><br><span style="color: hsl(120, 100%, 40%);">+; have a large number of voicemail users, or your voicemail is stored on</span><br><span style="color: hsl(120, 100%, 40%);">+; network-attached storage, you probably don't want to set this.</span><br><span style="color: hsl(120, 100%, 40%);">+;lock_file_cleanup=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ; -----------------------------------------------------------------------------</span><br><span> ; IMAP configuration settings only</span><br><span> ;   These settings are only applicable when Asterisk is compiled with IMAP support.</span><br><span>diff --git a/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt b/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..21dd32e</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/voicemail-lock-cleanup-conf.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_voicemail.c</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The functionality to clean up orphaned lock files is now configurable by</span><br><span style="color: hsl(120, 100%, 40%);">+a new configuration option in voicemail.conf named 'lock_file_cleanup.'</span><br><span style="color: hsl(120, 100%, 40%);">+The default is 'no.'</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13012">change 13012</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13012"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: I33454b7e7079dc406149aab9a2df3dae18476825 </div>
<div style="display:none"> Gerrit-Change-Number: 13012 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>