<p>Frederic LE FOLL has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13310">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_chanisavail/cdr: ChanIsAvail sometimes fails to deactivate CDR.<br><br>Retries may be necessary for CDR deactivation on temporary channel.<br>Temporary channel lifespan is very short and CDR deactivation request<br>through AST_CDR_FLAG_DISABLE_ALL flag may happen when CDR is not<br>available yet.<br><br>ASTERISK-28636<br><br>Change-Id: I1cbe09e8d2169c0962c1195133ff260d291f2074<br>---<br>M apps/app_chanisavail.c<br>1 file changed, 20 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/10/13310/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c</span><br><span>index 446bce1..d9a7e26 100644</span><br><span>--- a/apps/app_chanisavail.c</span><br><span>+++ b/apps/app_chanisavail.c</span><br><span>@@ -179,7 +179,26 @@</span><br><span>                                      ast_str_append(&tmp_availcause, 0, "%s%s", ast_str_strlen(tmp_availcause) ? "&" : "", tmp);</span><br><span> </span><br><span>                                        /* Disable CDR for this temporary channel. */</span><br><span style="color: hsl(0, 100%, 40%);">-                                   ast_cdr_set_property(ast_channel_name(tempchan), AST_CDR_FLAG_DISABLE_ALL);</span><br><span style="color: hsl(120, 100%, 40%);">+                                   /* XXX Should this be conditioned to an option, due to performance cost? */</span><br><span style="color: hsl(120, 100%, 40%);">+                                   do {</span><br><span style="color: hsl(120, 100%, 40%);">+                                          int res;</span><br><span style="color: hsl(120, 100%, 40%);">+                                              int attempt;</span><br><span style="color: hsl(120, 100%, 40%);">+                                          const int max_attempts = 20;            /* 20 attempts max */</span><br><span style="color: hsl(120, 100%, 40%);">+                                         const useconds_t delay_us = 500;        /* 500µs x 20 attempts => give-up after 10ms max */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                                             /* Retries may be necessary:</span><br><span style="color: hsl(120, 100%, 40%);">+                                           * ast_cdr_set_property() may be executed too soon, before CDR is present in CDRs container.</span><br><span style="color: hsl(120, 100%, 40%);">+                                           */</span><br><span style="color: hsl(120, 100%, 40%);">+                                           for (attempt = 1; attempt <= max_attempts && (res = ast_cdr_set_property(ast_channel_name(tempchan), AST_CDR_FLAG_DISABLE_ALL)) != 0; attempt++)</span><br><span style="color: hsl(120, 100%, 40%);">+                                                   usleep(delay_us);</span><br><span style="color: hsl(120, 100%, 40%);">+                                             if (res != 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                       ast_log(AST_LOG_NOTICE, "Failed to disable CDRs on channel %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                                           ast_channel_name(tempchan));</span><br><span style="color: hsl(120, 100%, 40%);">+                                          } else if (attempt > 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                                                  ast_debug(1, "Finally succeeded in disabling CDRs on channel %s, attempt:%d\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                                                             ast_channel_name(tempchan), attempt);</span><br><span style="color: hsl(120, 100%, 40%);">+                                         }</span><br><span style="color: hsl(120, 100%, 40%);">+                                     } while(0);</span><br><span> </span><br><span>                                      ast_hangup(tempchan);</span><br><span>                                        tempchan = NULL;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13310">change 13310</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/+/13310"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I1cbe09e8d2169c0962c1195133ff260d291f2074 </div>
<div style="display:none"> Gerrit-Change-Number: 13310 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Frederic LE FOLL <frederic.lefoll@c-s.fr> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>