]> git.kaiwu.me - nginx.git/commitdiff
Win32: event flags handling edge cases in ngx_wsarecv().
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 1 Dec 2022 01:22:36 +0000 (04:22 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 1 Dec 2022 01:22:36 +0000 (04:22 +0300)
Fixed event flags handling edge cases in ngx_wsarecv() and ngx_wsarecv_chain(),
notably to always reset rev->ready in case of errors (which wasn't the case
after ngx_socket_nread() errors), and after EOF (rev->ready was not cleared
if due to a misconfiguration a zero-sized buffer was used for reading).

src/os/win32/ngx_wsarecv.c
src/os/win32/ngx_wsarecv_chain.c

index ac883107b14991d1f5ca08231730770419ab1d35..b01405e26df1d53154b885896c2062890d653538 100644 (file)
@@ -78,6 +78,7 @@ ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size)
                                      ngx_socket_nread_n " failed");
 
             if (n == NGX_ERROR) {
+                rev->ready = 0;
                 rev->error = 1;
             }
 
@@ -95,6 +96,7 @@ ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size)
     }
 
     if (bytes == 0) {
+        rev->ready = 0;
         rev->eof = 1;
     }
 
index 4f95d5a2b5b9341eb4ef51a721ff59ac124fe75c..e60389bb765ba37a6d2f4404b6d069125525847b 100644 (file)
@@ -121,6 +121,7 @@ ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
     } else if (bytes == size) {
 
         if (ngx_socket_nread(c->fd, &rev->available) == -1) {
+            rev->ready = 0;
             rev->error = 1;
             ngx_connection_error(c, ngx_socket_errno,
                                  ngx_socket_nread_n " failed");
@@ -138,6 +139,7 @@ ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
     }
 
     if (bytes == 0) {
+        rev->ready = 0;
         rev->eof = 1;
     }