fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-pcap/+/42846?usp=email )


Change subject: tls: do not treat GNUTLS_E_AGAIN/INTERRUPTED as fatal on read
......................................................................

tls: do not treat GNUTLS_E_AGAIN/INTERRUPTED as fatal on read

osmo_tls_client_bfd_cb() treated any non-positive return from
gnutls_record_recv() as a fatal error and tore down the session.  On a
non-blocking socket gnutls_record_recv() can return GNUTLS_E_AGAIN or
GNUTLS_E_INTERRUPTED (both negative but non-fatal), which would drop
an otherwise healthy TLS session.  Handle them as retryable, mirroring
the existing logic in tls_write().

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Change-Id: If2f842b202dd08c07dffe3770c51cf0ce886beee
---
M src/osmo_tls.c
1 file changed, 5 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/46/42846/1

diff --git a/src/osmo_tls.c b/src/osmo_tls.c
index 8524ee3..f06f50e 100644
--- a/src/osmo_tls.c
+++ b/src/osmo_tls.c
@@ -264,7 +264,11 @@

        if (what & OSMO_FD_READ) {
                int rc = tls_read(sess);
-               if (rc <= 0) {
+               /* A non-blocking read may legitimately return GNUTLS_E_AGAIN or
+                * GNUTLS_E_INTERRUPTED; these are not errors, just retry 
later. */
+               if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {
+                       /* nothing to do, wait for the next read event */
+               } else if (rc <= 0) {
                        sess->error(sess);
                        return rc;
                }

--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/42846?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: If2f842b202dd08c07dffe3770c51cf0ce886beee
Gerrit-Change-Number: 42846
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>

Reply via email to