aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-02-22 17:11:14 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-02-22 17:15:37 +0100
commit76ead75d0a873e8a6170e336fc6b35dedb67b7dd (patch)
tree04b153869a59527492af7d5f58d6588aa68f6733
parent2cbaf4139ae768ff5a79c79d389045b4ef4dd0e6 (diff)
allow osmo_stream_srv_send() to destroy the connectionstsp/destroy_conn_with_zero_msg
If a zero-length message buffer is sent, destroy the corresponding connection. Change-Id: I7e01fece294a77bf673c540f6c3310cff79da123
-rw-r--r--src/stream.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/stream.c b/src/stream.c
index 8a1be38..49873ed 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -237,6 +237,10 @@ static int osmo_stream_cli_write(struct osmo_stream_cli *cli)
}
LOGP(DLINP, LOGL_ERROR, "error to send\n");
}
+
+ if (msgb_length(msg) == 0)
+ osmo_stream_cli_destroy(cli);
+
msgb_free(msg);
return 0;
}
@@ -828,6 +832,10 @@ static void osmo_stream_srv_write(struct osmo_stream_srv *conn)
if (ret < 0) {
LOGP(DLINP, LOGL_ERROR, "error to send\n");
}
+
+ if (msgb_length(msg) == 0)
+ osmo_stream_srv_destroy(conn);
+
msgb_free(msg);
}
@@ -931,7 +939,8 @@ void osmo_stream_srv_destroy(struct osmo_stream_srv *conn)
/*! \brief Enqueue data to be sent via an Osmocom stream server
* \param[in] conn Stream Server through which we want to send
- * \param[in] msg Message buffer to enqueue in transmit queue */
+ * \param[in] msg Message buffer to enqueue in transmit queue. If this buffer has zero length,
+ * the corresponding connection will be destroyed. */
void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg)
{
msgb_enqueue(&conn->tx_queue, msg);