aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-08-04 17:41:03 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-08-07 19:16:24 +0200
commit48f9a3c27f8c28c3f59bae553a8ca59ef7ca52b8 (patch)
tree05104b9acd22a7828c871c8be2b532cbc053ff32
parent3ee52742656066e60cbddd8a841d077d802c028f (diff)
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
-rw-r--r--src/stream_cli.c12
1 files 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);