From 48f9a3c27f8c28c3f59bae553a8ca59ef7ca52b8 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 4 Aug 2023 17:41:03 +0200 Subject: stream_cli: Proper handling of send() socket errors Upon EAGAIN, simply re-enqueue the message and return waiting for next poll. Upon any other error, force close + reconnect. Related: OS#6134 Change-Id: I462cb176ebc51f3e99ee796310e8665144c84ccc --- src/stream_cli.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/stream_cli.c b/src/stream_cli.c index 0e075b8..778ac43 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -288,9 +288,15 @@ static int osmo_stream_cli_write(struct osmo_stream_cli *cli) } if (ret < 0) { - if (errno == EPIPE || errno == ENOTCONN) - osmo_stream_cli_reconnect(cli); - LOGSCLI(cli, LOGL_ERROR, "received error %d in response to send\n", errno); + int err = errno; + LOGSCLI(cli, LOGL_ERROR, "send(len=%u) error: %s\n", msgb_length(msg), strerror(err)); + if (err == EAGAIN) { + /* Re-add at the start of the queue to re-attempt: */ + llist_add(&msg->list, &cli->tx_queue); + return 0; + } + msgb_free(msg); + osmo_stream_cli_reconnect(cli); } msgb_free(msg); -- cgit v1.2.3