<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmo-abis/+/19262">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ipaccess_recvmsg: Untangle code updating line<br><br>This patch untangles the code a bit by changing the order where actions<br>are taken and variables are assigned.<br><br>The only real changes in behavour are the introduced assert, and that<br>bfd->data is set to NULL before releasing the related line.<br><br>Related: OS#4624<br>Change-Id: I947f64f8fa20f87fdc84538402623a6bcf35fdf9<br>---<br>M src/input/ipaccess.c<br>1 file changed, 13 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/62/19262/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c</span><br><span>index 02a5028..d81191c 100644</span><br><span>--- a/src/input/ipaccess.c</span><br><span>+++ b/src/input/ipaccess.c</span><br><span>@@ -288,37 +288,42 @@</span><br><span>                                     "closing socket.\n");</span><br><span>                              goto err;</span><br><span>                    }</span><br><span style="color: hsl(120, 100%, 40%);">+                     /* Finally, we know which OML link is associated with</span><br><span style="color: hsl(120, 100%, 40%);">+                  * this RSL link, attach it to this socket. */</span><br><span style="color: hsl(120, 100%, 40%);">+                        new_line = sign_link->ts->line;</span><br><span>                        /* this is a bugtrap, the BSC should be using the</span><br><span>                     * virtual E1 line used by OML for this RSL link. */</span><br><span style="color: hsl(0, 100%, 40%);">-                    if (sign_link->ts->line == line) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      if (new_line == line) {</span><br><span>                              LOGP(DLINP, LOGL_ERROR,</span><br><span>                                      "Fix your BSC, you should use the "</span><br><span>                                        "E1 line used by the OML link for "</span><br><span>                                        "your RSL link.\n");</span><br><span>                               return 0;</span><br><span>                    }</span><br><span style="color: hsl(0, 100%, 40%);">-                       /* Finally, we know which OML link is associated with</span><br><span style="color: hsl(0, 100%, 40%);">-                    * this RSL link, attach it to this socket. */</span><br><span style="color: hsl(0, 100%, 40%);">-                  bfd->data = new_line = sign_link->ts->line;</span><br><span>                         e1inp_line_get2(new_line, "ipa_bfd");</span><br><span>                      ts = e1inp_line_ipa_rsl_ts(new_line, unit_data.trx_id);</span><br><span>                      newbfd = &ts->driver.ipaccess.fd;</span><br><span>                     OSMO_ASSERT(newbfd != bfd);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-                 /* get rid of our old temporary bfd */</span><br><span>                       /* preserve 'newbfd->when' flags potentially set by sign_link_up() */</span><br><span>                     osmo_fd_setup(newbfd, bfd->fd, newbfd->when | bfd->when, bfd->cb,</span><br><span style="color: hsl(0, 100%, 40%);">-                                 bfd->data, E1INP_SIGN_RSL + unit_data.trx_id);</span><br><span style="color: hsl(120, 100%, 40%);">+                                     new_line, E1INP_SIGN_RSL + unit_data.trx_id);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                       /* now we can release the dummy RSL line (old temporary bfd). */</span><br><span>                     osmo_fd_unregister(bfd);</span><br><span>                     bfd->fd = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* bfd->data holds a reference to line, drop it */</span><br><span style="color: hsl(120, 100%, 40%);">+                 OSMO_ASSERT(bfd->data == line);</span><br><span style="color: hsl(120, 100%, 40%);">+                    bfd->data = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+                  e1inp_line_put2(line, "ipa_bfd");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>                        ret = osmo_fd_register(newbfd);</span><br><span>                      if (ret < 0) {</span><br><span>                            LOGP(DLINP, LOGL_ERROR,</span><br><span>                                   "could not register FD\n");</span><br><span>                           goto err;</span><br><span>                    }</span><br><span style="color: hsl(0, 100%, 40%);">-                       /* now we can release the dummy RSL line. */</span><br><span style="color: hsl(0, 100%, 40%);">-                    e1inp_line_put2(line, "ipa_bfd");</span><br><span> </span><br><span>                      e1i_ts = ipaccess_line_ts(newbfd, new_line);</span><br><span>                         ipaccess_bsc_keepalive_fsm_alloc(e1i_ts, newbfd, "rsl_bsc_to_bts");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmo-abis/+/19262">change 19262</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/libosmo-abis/+/19262"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmo-abis </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I947f64f8fa20f87fdc84538402623a6bcf35fdf9 </div>
<div style="display:none"> Gerrit-Change-Number: 19262 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>