<p>Hoernchen <strong>uploaded patch set #20</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/25432">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Add multithreading for the virtual trunk<br><br>The idea is rather easy: do not disturb the code too much, so each<br>thread operates on a mgcp_trunk sub-trunk that has<br>- (it is) a mgcp_trunk structure just like the parent trunk<br>- some thread-specific information in struct per_thread_info<br>* this exists in the sub-trunk, as a SINGLE pointer (this_thread_info)<br>to the threads own info<br>- a different endpoint begin offset<br>- and different number of endpoint<br>- a private copy (!) of the mgcp_config structure that allows selective<br>updates of config settings during runtime using the vty<br><br>The thread-trunks doen't really know that they are not a full trunk, as<br>far as actual "mgw-operation" is concerned<br><br>Most of the other changes deal with the (t)alloc contexts to ensure<br>proper parent contexts that are not mixed between threads, the only<br>talloc that is threadsafe is the null context with disabled null<br>tracking, which is plain old malloc.<br><br>A parent trunk is configured using the vty/config as usual, so it also<br>has all the endpoints, but those are just not being used by anything,<br>all of the structs just exist to allow parsing and configuring, but the<br>updates are then also sent to the trunk threads. It contains the<br>thread_info array which has one per_thread_info struct entry for every<br>trunkthread of this trunk.<br><br>Communication betwen the main threads and the trunk thread(s) work by<br>sending messages through<br>- the mgcp msg queue for mgcp commands, which the thread then ansers by<br>writing to the socket, the queue back to the main thread is currently<br>unused.<br>- the cfg/vty command queue for vty commands and vty settings, that are<br>parsed and filtered by the threads own functions, the return queue to<br>the main thread is only being used to block it during vty show commands<br>that print in threads.<br><br>MGCP message handling is therefore split between a quick parsing in the<br>main thread to determine which endpoint (-> thread) should handle the<br>command and wrapping the command in a interthread queue buffer before<br>submitting it to one (or multiple) threads, and the usual processing<br>within the sub-trunk threads.<br><br>Multithreading is by default disabled unless "number threads" in the<br>config file exists.<br><br>Multithreading is disabled for e1 trunks due to the complexity of the<br>code and a lack of test coverage that reliably proves the absence of<br>threading related issues, so e1 is still being handled by the main<br>thread. Multithreading is also disabled for all trunks if osmux is<br>configured, also due to complexity and the fact that one osmux trunk is<br>limited to 256 calls due to the CID anyway, which can be handled within<br>one (main) thread.<br><br>That being said the code is ready to enable threads for all of that,<br>it's just not possible to prove that it will not implode at some point..<br><br>Change-Id: I31be8253600c8af0a43c967d0d128f5ba7b16260<br>---<br>M include/osmocom/mgcp/Makefile.am<br>M include/osmocom/mgcp/mgcp.h<br>M include/osmocom/mgcp/mgcp_endp.h<br>A include/osmocom/mgcp/mgcp_threads.h<br>M include/osmocom/mgcp/mgcp_trunk.h<br>M src/libosmo-mgcp/Makefile.am<br>M src/libosmo-mgcp/mgcp_e1.c<br>M src/libosmo-mgcp/mgcp_endp.c<br>M src/libosmo-mgcp/mgcp_protocol.c<br>A src/libosmo-mgcp/mgcp_threads.c<br>A src/libosmo-mgcp/mgcp_threads_vty.c<br>M src/libosmo-mgcp/mgcp_trunk.c<br>M src/libosmo-mgcp/mgcp_vty.c<br>M src/osmo-mgw/mgw_main.c<br>M tests/mgcp/mgcp_test.c<br>15 files changed, 1,209 insertions(+), 352 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/32/25432/20</pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/25432">change 25432</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-mgw/+/25432"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-mgw </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I31be8253600c8af0a43c967d0d128f5ba7b16260 </div>
<div style="display:none"> Gerrit-Change-Number: 25432 </div>
<div style="display:none"> Gerrit-PatchSet: 20 </div>
<div style="display:none"> Gerrit-Owner: Hoernchen <ewild@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>