<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13581">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add vty_is_active()<br><br>For async callbacks it is useful to determine whether a given VTY pointer is still valid.<br><br>For example, in osmo-msc, a silent call can be triggered by VTY, which causes a<br>Paging. The paging_cb then writes to the VTY console that the silent call has<br>succeeded. Unless the telnet vty session has already ended, in which case<br>osmo-msc crashes; e.g. from an osmo_interact_vty.py command invocation. With<br>this function, osmo-msc can ask whether the vty pointer passed to the paging<br>callback is still active, and skip vty_out() if not.<br><br>Change-Id: I42cf2af47283dd42c101faae0fac293c3a68d599<br>---<br>M include/osmocom/vty/vty.h<br>M src/vty/telnet_interface.c<br>2 files changed, 12 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h</span><br><span>index 8d2e1b3..03a2924 100644</span><br><span>--- a/include/osmocom/vty/vty.h</span><br><span>+++ b/include/osmocom/vty/vty.h</span><br><span>@@ -2,6 +2,7 @@</span><br><span> </span><br><span> #include <stdio.h></span><br><span> #include <stdarg.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdbool.h></span><br><span> </span><br><span> #include <osmocom/core/linuxlist.h></span><br><span> </span><br><span>@@ -192,6 +193,7 @@</span><br><span> void vty_reset (void);</span><br><span> struct vty *vty_new (void);</span><br><span> struct vty *vty_create (int vty_sock, void *priv);</span><br><span style="color: hsl(120, 100%, 40%);">+bool vty_is_active(struct vty *vty);</span><br><span> int vty_out (struct vty *, const char *, ...) VTY_PRINTF_ATTRIBUTE(2, 3);</span><br><span> int vty_out_va(struct vty *vty, const char *format, va_list ap);</span><br><span> int vty_out_newline(struct vty *);</span><br><span>diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c</span><br><span>index dc23b12..a1fc999 100644</span><br><span>--- a/src/vty/telnet_interface.c</span><br><span>+++ b/src/vty/telnet_interface.c</span><br><span>@@ -197,6 +197,16 @@</span><br><span>   return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+bool vty_is_active(struct vty *vty)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    struct telnet_connection *connection;</span><br><span style="color: hsl(120, 100%, 40%);">+ llist_for_each_entry(connection, &active_connections, entry) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (connection->vty == vty)</span><br><span style="color: hsl(120, 100%, 40%);">+                        return true;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+     return false;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! callback from core VTY code about VTY related events */</span><br><span> void vty_event(enum event event, int sock, struct vty *vty)</span><br><span> {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13581">change 13581</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/13581"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I42cf2af47283dd42c101faae0fac293c3a68d599 </div>
<div style="display:none"> Gerrit-Change-Number: 13581 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Vadim Yanitskiy <axilirator@gmail.com> </div>