[PATCH 3 of 4] QUIC: allowed ngx_quic_frame_sendto() to return NGX_AGAIN

Roman Arutyunyan arut at nginx.com
Thu Jul 6 13:57:16 UTC 2023


# HG changeset patch
# User Roman Arutyunyan <arut at nginx.com>
# Date 1679920727 -14400
#      Mon Mar 27 16:38:47 2023 +0400
# Node ID a1ea543d009311765144351b2557c00c8e6445bf
# Parent  f98ff9b62d2bccac10b603b8183eca2ff0f4183e
QUIC: allowed ngx_quic_frame_sendto() to return NGX_AGAIN.

Previously, NGX_AGAIN returned by ngx_send() was treated by
ngx_quic_frame_sendto() as error, which triggered errors in its callers.
However, a blocked socket is not an error.  Now NGX_AGAIN is passed as is to
the ngx_quic_frame_sendto() callers, which can safely ignore it.

diff --git a/src/event/quic/ngx_event_quic_migration.c b/src/event/quic/ngx_event_quic_migration.c
--- a/src/event/quic/ngx_event_quic_migration.c
+++ b/src/event/quic/ngx_event_quic_migration.c
@@ -46,7 +46,7 @@ ngx_quic_handle_path_challenge_frame(ngx
      * An endpoint MUST expand datagrams that contain a PATH_RESPONSE frame
      * to at least the smallest allowed maximum datagram size of 1200 bytes.
      */
-    if (ngx_quic_frame_sendto(c, &frame, 1200, pkt->path) != NGX_OK) {
+    if (ngx_quic_frame_sendto(c, &frame, 1200, pkt->path) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
@@ -544,13 +544,13 @@ ngx_quic_send_path_challenge(ngx_connect
      */
 
      /* same applies to PATH_RESPONSE frames */
-    if (ngx_quic_frame_sendto(c, &frame, 1200, path) != NGX_OK) {
+    if (ngx_quic_frame_sendto(c, &frame, 1200, path) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
     ngx_memcpy(frame.u.path_challenge.data, path->challenge2, 8);
 
-    if (ngx_quic_frame_sendto(c, &frame, 1200, path) != NGX_OK) {
+    if (ngx_quic_frame_sendto(c, &frame, 1200, path) == NGX_ERROR) {
         return NGX_ERROR;
     }
 
diff --git a/src/event/quic/ngx_event_quic_output.c b/src/event/quic/ngx_event_quic_output.c
--- a/src/event/quic/ngx_event_quic_output.c
+++ b/src/event/quic/ngx_event_quic_output.c
@@ -1236,7 +1236,7 @@ ngx_quic_frame_sendto(ngx_connection_t *
 
     sent = ngx_quic_send(c, res.data, res.len, path->sockaddr, path->socklen);
     if (sent < 0) {
-        return NGX_ERROR;
+        return sent;
     }
 
     path->sent += sent;


More information about the nginx-devel mailing list