<p>Patch set 5:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4; color: #000000;">Code-Review -1</span></p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11013">View Change</a></p><p>10 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/11013/5/include/asterisk/stasis.h">File include/asterisk/stasis.h:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/include/asterisk/stasis.h@518">Patch Set #5, Line 518:</a> <code style="font-family:monospace,monospace">struct stasis_topic *stasis_topic_create(const char *name);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think topic names ultimately should be unique and descriptive themselves. To that end I'm going to be auditing the codebase and improving this for topics and subscriptions. I think the cleanest option is probably to have this code do a check for a topic of the same name when creating, and if one exists then to append a unique part to the end of the passed in name. Example:</p><p style="white-space: pre-wrap; word-wrap: break-word;">A topic named "pjsip" is created.<br>Another topic named "pjsip" is created but the code appends some unique data turning it into "pjsip-349d93".</p><p style="white-space: pre-wrap; word-wrap: break-word;">This guarantees the topic names are unique, and as the topic names are not actually used by the API itself - whether the name passed in is used or not doesn't actually matter.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/include/asterisk/stasis.h@521">Patch Set #5, Line 521:</a> <code style="font-family:monospace,monospace"> * \brief Create a new topic with given detail.</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This now creates one with uniqueid and detail</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/include/asterisk/stasis.h@522">Patch Set #5, Line 522:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;"> * \param uniqueid Uniqueid of the new topic.<br> * \param name Name of the new topic.<br> * \param detail Detail of the new topic.<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">To me this seems as though things are getting overloaded with different fields.</p><p style="white-space: pre-wrap; word-wrap: break-word;">What's the difference between the uniqueid, name, and detail. What should they all provide? What should a topic creator place in each? What's the difference between topic and uniqueid? What should go into detail?</p><p style="white-space: pre-wrap; word-wrap: break-word;">A topic name is supposed to adequately describe its purpose, so I'm not sure what detail adds.</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c">File main/stasis.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@434">Patch Set #5, Line 434:</a> <code style="font-family:monospace,monospace">        ast_log(LOG_DEBUG, "Destroying topic. uniqueid: %s, name: %s, detail: %s\n",</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should use ast_debug with a sufficiently high log level.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@487">Patch Set #5, Line 487:</a> <code style="font-family:monospace,monospace"> if (!topic || !name || !detail) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">What if they're empty?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@495">Patch Set #5, Line 495:</a> <code style="font-family:monospace,monospace">         ast_log(LOG_ERROR, "The same topic is already exist. name: %s\n", name);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should use ast_debug with a sufficiently high log level.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@557">Patch Set #5, Line 557:</a> <code style="font-family:monospace,monospace">     if (!uniqueid || !name || !detail) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">What if these are empty?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@560">Patch Set #5, Line 560:</a> <code style="font-family:monospace,monospace">        ast_log(LOG_DEBUG, "Creating topic. uniqueid: %s, name: %s, detail: %s\n",</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should use ast_debug with a sufficiently high log level.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@565">Patch Set #5, Line 565:</a> <code style="font-family:monospace,monospace">           ast_log(LOG_DEBUG, "Topic is already exist. uniqueid:%s, name: %s, detail: %s\n",</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This should use ast_debug with a sufficiently high log level.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/11013/5/main/stasis.c@1172">Patch Set #5, Line 1172:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">     tmp_subscription = AST_VECTOR_GET_CMP(&topic->subscribers, sub, TOPIC_SUBSCRIPTION_CMP);<br>       if (!tmp_subscription) {<br>              AST_VECTOR_APPEND(&topic->subscribers, sub);<br>   }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">In what case will the subscription be added twice? Have you encountered a scenario?</p><p style="white-space: pre-wrap; word-wrap: break-word;">This seems like a separate change/fix.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11013">change 11013</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/+/11013"/><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: Ie86d125d2966f93de74ee00f47ae6fbc8c081c5f </div>
<div style="display:none"> Gerrit-Change-Number: 11013 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Thu, 07 Mar 2019 11:48:53 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-Has-Labels: Yes </div>
<div style="display:none"> Gerrit-MessageType: comment </div>