]> git.kaiwu.me - nginx.git/commitdiff
QUIC: separate event handling functions.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 9 Sep 2021 13:55:00 +0000 (16:55 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 9 Sep 2021 13:55:00 +0000 (16:55 +0300)
The functions ngx_quic_handle_read_event() and ngx_quic_handle_write_event()
are added.  Previously this code was a part of ngx_handle_read_event() and
ngx_handle_write_event().

The change simplifies ngx_handle_read_event() and ngx_handle_write_event()
by moving QUIC-related code to a QUIC source file.

src/event/ngx_event.c
src/event/quic/ngx_event_quic.h
src/event/quic/ngx_event_quic_streams.c

index d61eda25e1b27302fd79ab36e8e6c72bb2cef991..aa47ccf9f694dd37a3ad3147ea03e66ba8cbd85b 100644 (file)
@@ -273,15 +273,7 @@ ngx_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
     c = rev->data;
 
     if (c->quic) {
-
-        if (!rev->active && !rev->ready) {
-            rev->active = 1;
-
-        } else if (rev->active && (rev->ready || (flags & NGX_CLOSE_EVENT))) {
-            rev->active = 0;
-        }
-
-        return NGX_OK;
+        return ngx_quic_handle_read_event(rev, flags);
     }
 
 #endif
@@ -358,28 +350,18 @@ ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
 
     c = wev->data;
 
-    if (lowat) {
-        if (ngx_send_lowat(c, lowat) == NGX_ERROR) {
-            return NGX_ERROR;
-        }
-    }
-
 #if (NGX_QUIC)
-
     if (c->quic) {
+        return ngx_quic_handle_write_event(wev, lowat);
+    }
+#endif
 
-        if (!wev->active && !wev->ready) {
-            wev->active = 1;
-
-        } else if (wev->active && wev->ready) {
-            wev->active = 0;
+    if (lowat) {
+        if (ngx_send_lowat(c, lowat) == NGX_ERROR) {
+            return NGX_ERROR;
         }
-
-        return NGX_OK;
     }
 
-#endif
-
     if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
 
         /* kqueue, epoll */
index d425cee31687e8ff28c48fd1c9f1ac766580ddb1..dda1e385e46ff13e7712b7e12698965ba8586a6a 100644 (file)
@@ -93,6 +93,8 @@ void ngx_quic_shutdown_connection(ngx_connection_t *c, ngx_uint_t err,
     const char *reason);
 ngx_int_t ngx_quic_reset_stream(ngx_connection_t *c, ngx_uint_t err);
 uint32_t ngx_quic_version(ngx_connection_t *c);
+ngx_int_t ngx_quic_handle_read_event(ngx_event_t *rev, ngx_uint_t flags);
+ngx_int_t ngx_quic_handle_write_event(ngx_event_t *wev, size_t lowat);
 ngx_int_t ngx_quic_get_packet_dcid(ngx_log_t *log, u_char *data, size_t len,
     ngx_str_t *dcid);
 ngx_int_t ngx_quic_derive_key(ngx_log_t *log, const char *label,
index a4f4cb57cce4e54b5fb2309c70aba429302c5703..69c7220cfd176bbdc80071ddd3bb0015d7389173 100644 (file)
@@ -1470,3 +1470,31 @@ ngx_quic_update_flow(ngx_connection_t *c, uint64_t last)
 
     return NGX_OK;
 }
+
+
+ngx_int_t
+ngx_quic_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
+{
+    if (!rev->active && !rev->ready) {
+        rev->active = 1;
+
+    } else if (rev->active && (rev->ready || (flags & NGX_CLOSE_EVENT))) {
+        rev->active = 0;
+    }
+
+    return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_quic_handle_write_event(ngx_event_t *wev, size_t lowat)
+{
+    if (!wev->active && !wev->ready) {
+        wev->active = 1;
+
+    } else if (wev->active && wev->ready) {
+        wev->active = 0;
+    }
+
+    return NGX_OK;
+}