<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 1: Code-Review+1</p><p style="white-space: pre-wrap; word-wrap: break-word;">why do we have a log mutex in the first place?  I did some research into multithreadded logging using libosmocore and found that the only critical part would be adding/removing of log targets at runtime (the linked list of log targets).  However, during the actual log output / log write, as long as you don't use LOGPC, IIRC you should be fine.  Every fprintf should be atomic, whether to stdout or to any other file.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;"> Hi, good point. I did some reseach and here are my conclusions:</p><ul><li>Agree, the only "really dangerous" part seems to be log targets.</li></ul><p style="white-space: pre-wrap; word-wrap: break-word;">Some nuisances or weird situations of not using mutex:</p><ul><li>unordered timestamps on generated output (th1 generates timestamp, th2 preempts th1 generates timestamp and prints, th1 prints).</li><li>color tag left opened if color is disabled through VTY (log color is disabled while other thread is in the middle of generating log line).</li></ul><p style="white-space: pre-wrap; word-wrap: break-word;">So the important cases are basically a thread calling LOGPSRC while another calls:</p><ul><li>race conditons during llog_targets_reopen()->log_target_file_reopen()</li><li>logging_vty.c "logging enable", "log syslog local", "log gsmtap", "log stderr", etc. -> log_add_target() -> append to the list osmo_log_target_list</li><li>logging_vty.c "logging disable" -> log_del_target() -> osmo_log_target_list</li></ul><p style="white-space: pre-wrap; word-wrap: break-word;">so I think all in all there should be a mutex. But actually the one in osmo-trx doesn't seem to be covering the VTY commands AFAICT, so it's really not useful against big issues (but it's useful against nuisances explained first).</p><p style="white-space: pre-wrap; word-wrap: break-word;">The steps to procede should be IMHO:</p><ul><li>Keep the mutex for now in osmo-trx to at least solve nuisances.</li><li>Add some sort of multithread support in libosmocore's logging system (by adding an internal mutex around log targets (and list), and enabling using the mutex through a libosmocore public API (such as log_enable_multithread_support(bool enable)).</li><li>Once libosmocore has that multithread support, drop the osmo-trx mutex and use the libosmocore API.</li></ul><p><a href="https://gerrit.osmocom.org/c/osmo-trx/+/14645">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-trx/+/14645">change 14645</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/c/osmo-trx/+/14645"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-trx </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I473e57479f8ae98a84ad00b76ff338f79f732236 </div>
<div style="display:none"> Gerrit-Change-Number: 14645 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Tue, 02 Jul 2019 13:58:03 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>