<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15897">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">client: endp fsm: add notify struct, prep for cancel-notify<br><br>Upcoming patches introduce copying notify information. Prepare by combining<br>notify info into a separate sub-struct.<br><br>Change-Id: I47c0dd112011b8cb4dc88e8efd010466d4ba6308<br>---<br>M src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c<br>1 file changed, 27 insertions(+), 19 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/97/15897/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>index 3ea1492..02054ab 100644</span><br><span>--- a/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>+++ b/src/libosmo-mgcp-client/mgcp_client_endpoint_fsm.c</span><br><span>@@ -73,6 +73,13 @@</span><br><span> </span><br><span> static struct osmo_fsm osmo_mgcpc_ep_fsm;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+struct fsm_notify {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct osmo_fsm_inst *fi;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t success;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t failure;</span><br><span style="color: hsl(120, 100%, 40%);">+ void *data;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! One connection on an endpoint, corresponding to a connection identifier (CI) as returned by the MGW.</span><br><span> * An endpoint has a fixed number of slots of these, which may or may not be in use.</span><br><span> */</span><br><span>@@ -87,10 +94,7 @@</span><br><span> bool sent;</span><br><span> enum mgcp_verb verb;</span><br><span> struct mgcp_conn_peer verb_info;</span><br><span style="color: hsl(0, 100%, 40%);">- struct osmo_fsm_inst *notify;</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t notify_success;</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t notify_failure;</span><br><span style="color: hsl(0, 100%, 40%);">- void *notify_data;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct fsm_notify notify;</span><br><span> </span><br><span> bool got_port_info;</span><br><span> struct mgcp_conn_peer rtp_info;</span><br><span>@@ -354,15 +358,17 @@</span><br><span> </span><br><span> static void on_failure(struct osmo_mgcpc_ep_ci *ci)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- struct osmo_fsm_inst *notify = ci->notify;</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t notify_failure = ci->notify_failure;</span><br><span style="color: hsl(0, 100%, 40%);">- void *notify_data = ci->notify_data;</span><br><span> struct osmo_mgcpc_ep *ep = ci->ep;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct fsm_notify notify;</span><br><span> int i;</span><br><span> </span><br><span> if (!ci->occupied)</span><br><span> return;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ /* When dispatching an event for this CI, the user may decide to trigger the next request for this conn right</span><br><span style="color: hsl(120, 100%, 40%);">+ * away. So we must be ready with a cleared *ci. Store the notify separately and clear before dispatching. */</span><br><span style="color: hsl(120, 100%, 40%);">+ notify = ci->notify;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> *ci = (struct osmo_mgcpc_ep_ci){</span><br><span> .ep = ci->ep,</span><br><span> };</span><br><span>@@ -390,8 +396,8 @@</span><br><span> if (!osmo_mgcpc_ep_fsm_check_state_chg_after_response(ci->ep->fi))</span><br><span> return;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (notify)</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_dispatch(notify, notify_failure, notify_data);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (notify.fi)</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_fsm_inst_dispatch(notify.fi, notify.failure, notify.data);</span><br><span> }</span><br><span> </span><br><span> static int update_endpoint_name(struct osmo_mgcpc_ep_ci *ci, const char *new_endpoint_name)</span><br><span>@@ -472,10 +478,10 @@</span><br><span> LOG_CI(ci, LOGL_DEBUG, "received successful response to %s: RTP=%s%s\n",</span><br><span> osmo_mgcp_verb_name(ci->verb),</span><br><span> mgcp_conn_peer_name(ci->got_port_info? &ci->rtp_info : NULL),</span><br><span style="color: hsl(0, 100%, 40%);">- ci->notify ? "" : " (not sending a notification)");</span><br><span style="color: hsl(120, 100%, 40%);">+ ci->notify.fi ? "" : " (not sending a notification)");</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ci->notify)</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_dispatch(ci->notify, ci->notify_success, ci->notify_data);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ci->notify.fi)</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_fsm_inst_dispatch(ci->notify.fi, ci->notify.success, ci->notify.data);</span><br><span> </span><br><span> osmo_mgcpc_ep_fsm_check_state_chg_after_response(ci->ep->fi);</span><br><span> }</span><br><span>@@ -584,16 +590,18 @@</span><br><span> .occupied = true,</span><br><span> /* .pending = true follows below */</span><br><span> .verb = verb,</span><br><span style="color: hsl(0, 100%, 40%);">- .notify = notify,</span><br><span style="color: hsl(0, 100%, 40%);">- .notify_success = event_success,</span><br><span style="color: hsl(0, 100%, 40%);">- .notify_failure = event_failure,</span><br><span style="color: hsl(0, 100%, 40%);">- .notify_data = notify_data,</span><br><span style="color: hsl(120, 100%, 40%);">+ .notify = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .fi = notify,</span><br><span style="color: hsl(120, 100%, 40%);">+ .success = event_success,</span><br><span style="color: hsl(120, 100%, 40%);">+ .failure = event_failure,</span><br><span style="color: hsl(120, 100%, 40%);">+ .data = notify_data,</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> };</span><br><span> osmo_strlcpy(cleared_ci.label, ci->label, sizeof(cleared_ci.label));</span><br><span> osmo_strlcpy(cleared_ci.mgcp_ci_str, ci->mgcp_ci_str, sizeof(cleared_ci.mgcp_ci_str));</span><br><span> *ci = cleared_ci;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- LOG_CI_VERB(ci, LOGL_DEBUG, "notify=%s\n", osmo_fsm_inst_name(ci->notify));</span><br><span style="color: hsl(120, 100%, 40%);">+ LOG_CI_VERB(ci, LOGL_DEBUG, "notify=%s\n", osmo_fsm_inst_name(ci->notify.fi));</span><br><span> </span><br><span> if (verb_info)</span><br><span> ci->verb_info = *verb_info;</span><br><span>@@ -693,8 +701,8 @@</span><br><span> osmo_mgcp_verb_name(ci->verb), ci->mgcp_ci_str);</span><br><span> /* The way this is designed, we actually need to forget all about the ci right away. */</span><br><span> mgcp_conn_delete(ci->mgcp_client_fi);</span><br><span style="color: hsl(0, 100%, 40%);">- if (ci->notify)</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_dispatch(ci->notify, ci->notify_success, ci->notify_data);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ci->notify.fi)</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_fsm_inst_dispatch(ci->notify.fi, ci->notify.success, ci->notify.data);</span><br><span> *ci = (struct osmo_mgcpc_ep_ci){</span><br><span> .ep = ep,</span><br><span> };</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-mgw/+/15897">change 15897</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/+/15897"/><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: I47c0dd112011b8cb4dc88e8efd010466d4ba6308 </div>
<div style="display:none"> Gerrit-Change-Number: 15897 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>