comparison src/core/ngx_resolver.c @ 7808:eb54227110f0

Resolver: added missing event handling after reading. If we need to be notified about further events, ngx_handle_read_event() needs to be called after a read event is processed. Without this, an event can be removed from the kernel and won't be reported again, notably when using oneshot event methods, such as eventport on Solaris. While here, error handling is also added, similar to one present in ngx_resolver_tcp_read(). This is not expected to make a difference and mostly added for consistency.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 28 Mar 2021 17:45:31 +0300
parents 8fe7ebe5adc4
children fdc3d40979b0
comparison
equal deleted inserted replaced
7807:e0844646099b 7808:eb54227110f0
1561 rec = c->data; 1561 rec = c->data;
1562 1562
1563 do { 1563 do {
1564 n = ngx_udp_recv(c, buf, NGX_RESOLVER_UDP_SIZE); 1564 n = ngx_udp_recv(c, buf, NGX_RESOLVER_UDP_SIZE);
1565 1565
1566 if (n < 0) { 1566 if (n == NGX_AGAIN) {
1567 return; 1567 break;
1568 }
1569
1570 if (n == NGX_ERROR) {
1571 goto failed;
1568 } 1572 }
1569 1573
1570 ngx_resolver_process_response(rec->resolver, buf, n, 0); 1574 ngx_resolver_process_response(rec->resolver, buf, n, 0);
1571 1575
1572 } while (rev->ready); 1576 } while (rev->ready);
1577
1578 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
1579 goto failed;
1580 }
1581
1582 return;
1583
1584 failed:
1585
1586 ngx_close_connection(rec->udp);
1587 rec->udp = NULL;
1573 } 1588 }
1574 1589
1575 1590
1576 static void 1591 static void
1577 ngx_resolver_tcp_write(ngx_event_t *wev) 1592 ngx_resolver_tcp_write(ngx_event_t *wev)