s4:lib/tls: remove tstream_tls_push_trigger_write step
authorStefan Metzmacher <metze@samba.org>
Fri, 26 Jan 2024 13:27:16 +0000 (14:27 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 23 Apr 2024 23:50:33 +0000 (23:50 +0000)
At the time of https://bugzilla.samba.org/show_bug.cgi?id=7218,
we tested this versions:
    2.4.1 -> broken
    2.4.2 -> broken
    2.6.0 -> broken
    2.8.0 -> broken
    2.8.1 -> broken
    2.8.2 -> OK
    2.8.3 -> OK
    2.8.4 -> OK
    2.8.5 -> OK
    2.8.6 -> OK
    2.10.0 -> broken
    2.10.1 -> broken
    2.10.2 -> OK

These seemed to be the fixes in gnutls upstream.

Change 2.8.1 -> 2.8.2:
http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=commitdiff;h=28fb34099edaf62e5472cc6e5e2749fed369ea01

Change 2.10.1 -> 2.10.2:
http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=commitdiff;h=0d07d8432d57805a8354ebd6c1e7829f3ab159cb

This shouldn't be a problem with recent (>= 3.6) versions of gnutls.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15621

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/lib/tls/tls_tstream.c

index 41fd6cce5e3587e3c9570c801e3be301a21cb17c..085da5e6473adf5f4e6f8ba2a67efdb742115b1d 100644 (file)
@@ -75,7 +75,6 @@ struct tstream_tls {
                off_t ofs;
                struct iovec iov;
                struct tevent_req *subreq;
-               struct tevent_immediate *im;
        } push;
 
        struct {
@@ -160,9 +159,7 @@ static void tstream_tls_retry_trigger(struct tevent_context *ctx,
        tstream_tls_retry(stream, true);
 }
 
-static void tstream_tls_push_trigger_write(struct tevent_context *ev,
-                                          struct tevent_immediate *im,
-                                          void *private_data);
+static void tstream_tls_push_done(struct tevent_req *subreq);
 
 static ssize_t tstream_tls_push_function(gnutls_transport_ptr_t ptr,
                                         const void *buf, size_t size)
@@ -173,6 +170,7 @@ static ssize_t tstream_tls_push_function(gnutls_transport_ptr_t ptr,
        struct tstream_tls *tlss =
                tstream_context_data(stream,
                struct tstream_tls);
+       struct tevent_req *subreq = NULL;
        uint8_t *nbuf;
        size_t len;
 
@@ -206,56 +204,7 @@ static ssize_t tstream_tls_push_function(gnutls_transport_ptr_t ptr,
        tlss->push.buf = nbuf;
 
        memcpy(tlss->push.buf + tlss->push.ofs, buf, len);
-
-       if (tlss->push.im == NULL) {
-               tlss->push.im = tevent_create_immediate(tlss);
-               if (tlss->push.im == NULL) {
-                       errno = ENOMEM;
-                       return -1;
-               }
-       }
-
-       if (tlss->push.ofs == 0) {
-               /*
-                * We'll do start the tstream_writev
-                * in the next event cycle.
-                *
-                * This way we can batch all push requests,
-                * if they fit into a UINT16_MAX buffer.
-                *
-                * This is important as gnutls_handshake()
-                * had a bug in some versions e.g. 2.4.1
-                * and others (See bug #7218) and it doesn't
-                * handle EAGAIN.
-                */
-               tevent_schedule_immediate(tlss->push.im,
-                                         tlss->current_ev,
-                                         tstream_tls_push_trigger_write,
-                                         stream);
-       }
-
        tlss->push.ofs += len;
-       return len;
-}
-
-static void tstream_tls_push_done(struct tevent_req *subreq);
-
-static void tstream_tls_push_trigger_write(struct tevent_context *ev,
-                                          struct tevent_immediate *im,
-                                          void *private_data)
-{
-       struct tstream_context *stream =
-               talloc_get_type_abort(private_data,
-               struct tstream_context);
-       struct tstream_tls *tlss =
-               tstream_context_data(stream,
-               struct tstream_tls);
-       struct tevent_req *subreq;
-
-       if (tlss->push.subreq) {
-               /* nothing todo */
-               return;
-       }
 
        tlss->push.iov.iov_base = (char *)tlss->push.buf;
        tlss->push.iov.iov_len = tlss->push.ofs;
@@ -265,13 +214,13 @@ static void tstream_tls_push_trigger_write(struct tevent_context *ev,
                                     tlss->plain_stream,
                                     &tlss->push.iov, 1);
        if (subreq == NULL) {
-               tlss->error = ENOMEM;
-               tstream_tls_retry(stream, false);
-               return;
+               errno = ENOMEM;
+               return -1;
        }
        tevent_req_set_callback(subreq, tstream_tls_push_done, stream);
 
        tlss->push.subreq = subreq;
+       return len;
 }
 
 static void tstream_tls_push_done(struct tevent_req *subreq)