pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/34079 )


Change subject: stream_cli: Proper handling of send() socket errors
......................................................................

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
---
M src/stream_cli.c
1 file changed, 22 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/79/34079/1

diff --git a/src/stream_cli.c b/src/stream_cli.c
index 0e075b8..e90b5e4 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -288,9 +288,15 @@
        }

        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, "error to send: %s\n", 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);

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/34079
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I462cb176ebc51f3e99ee796310e8665144c84ccc
Gerrit-Change-Number: 34079
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-MessageType: newchange

Reply via email to