@@ -456,9 +456,9 @@ comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
456456 int pret ;
457457 memset (& p , 0 , sizeof (p ));
458458 p .fd = c -> fd ;
459- p .events = POLLOUT | POLLERR
459+ p .events = POLLOUT
460460#ifndef USE_WINSOCK
461- | POLLHUP
461+ | POLLERR | POLLHUP
462462#endif
463463 ;
464464# ifndef USE_WINSOCK
@@ -483,7 +483,7 @@ comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
483483# ifdef EWOULDBLOCK
484484 errno != EWOULDBLOCK &&
485485# endif
486- errno != ENOBUFS
486+ errno != ENOMEM && errno != ENOBUFS
487487#else
488488 WSAGetLastError () != WSAEINPROGRESS &&
489489 WSAGetLastError () != WSAEINTR &&
@@ -496,15 +496,19 @@ comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
496496 return 0 ;
497497 } else if ((pret < 0 &&
498498#ifndef USE_WINSOCK
499- errno == ENOBUFS
499+ ( errno == ENOBUFS /* Maybe some systems */
500+ || errno == ENOMEM /* Linux */
501+ || errno == EAGAIN ) /* Macos, solaris, openbsd */
500502#else
501503 WSAGetLastError () == WSAENOBUFS
502504#endif
503505 ) || (send_nobufs && retries > 0 )) {
504- /* ENOBUFS, and poll returned without
506+ /* ENOBUFS/ENOMEM/EAGAIN, and poll
507+ * returned without
505508 * a timeout. Or the retried send call
506- * returned ENOBUFS. It is good to
507- * wait a bit for the error to clear. */
509+ * returned ENOBUFS/ENOMEM/EAGAIN.
510+ * It is good to wait a bit for the
511+ * error to clear. */
508512 /* The timeout is 20*(2^(retries+1)),
509513 * it increases exponentially, starting
510514 * at 40 msec. After 5 tries, 1240 msec
@@ -517,18 +521,15 @@ comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
517521 Sleep ((SEND_BLOCKED_WAIT_TIMEOUT /10 )<<(retries + 1 ));
518522 pret = 0 ;
519523#endif
520- if (pret < 0 &&
524+ if (pret < 0
521525#ifndef USE_WINSOCK
522- errno != EAGAIN && errno != EINTR &&
526+ && errno != EAGAIN && errno != EINTR &&
523527# ifdef EWOULDBLOCK
524528 errno != EWOULDBLOCK &&
525529# endif
526- errno != ENOBUFS
530+ errno != ENOMEM && errno != ENOBUFS
527531#else
528- WSAGetLastError () != WSAEINPROGRESS &&
529- WSAGetLastError () != WSAEINTR &&
530- WSAGetLastError () != WSAENOBUFS &&
531- WSAGetLastError () != WSAEWOULDBLOCK
532+ /* Sleep does not error */
532533#endif
533534 ) {
534535 log_err ("poll udp out timer failed: %s" ,
@@ -770,9 +771,9 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
770771 int pret ;
771772 memset (& p , 0 , sizeof (p ));
772773 p .fd = c -> fd ;
773- p .events = POLLOUT | POLLERR
774+ p .events = POLLOUT
774775#ifndef USE_WINSOCK
775- | POLLHUP
776+ | POLLERR | POLLHUP
776777#endif
777778 ;
778779# ifndef USE_WINSOCK
@@ -797,7 +798,7 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
797798# ifdef EWOULDBLOCK
798799 errno != EWOULDBLOCK &&
799800# endif
800- errno != ENOBUFS
801+ errno != ENOMEM && errno != ENOBUFS
801802#else
802803 WSAGetLastError () != WSAEINPROGRESS &&
803804 WSAGetLastError () != WSAEINTR &&
@@ -810,15 +811,19 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
810811 return 0 ;
811812 } else if ((pret < 0 &&
812813#ifndef USE_WINSOCK
813- errno == ENOBUFS
814+ ( errno == ENOBUFS /* Maybe some systems */
815+ || errno == ENOMEM /* Linux */
816+ || errno == EAGAIN ) /* Macos, solaris, openbsd */
814817#else
815818 WSAGetLastError () == WSAENOBUFS
816819#endif
817820 ) || (send_nobufs && retries > 0 )) {
818- /* ENOBUFS, and poll returned without
821+ /* ENOBUFS/ENOMEM/EAGAIN, and poll
822+ * returned without
819823 * a timeout. Or the retried send call
820- * returned ENOBUFS. It is good to
821- * wait a bit for the error to clear. */
824+ * returned ENOBUFS/ENOMEM/EAGAIN.
825+ * It is good to wait a bit for the
826+ * error to clear. */
822827 /* The timeout is 20*(2^(retries+1)),
823828 * it increases exponentially, starting
824829 * at 40 msec. After 5 tries, 1240 msec
@@ -831,18 +836,15 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
831836 Sleep ((SEND_BLOCKED_WAIT_TIMEOUT /10 )<<(retries + 1 ));
832837 pret = 0 ;
833838#endif
834- if (pret < 0 &&
839+ if (pret < 0
835840#ifndef USE_WINSOCK
836- errno != EAGAIN && errno != EINTR &&
841+ && errno != EAGAIN && errno != EINTR &&
837842# ifdef EWOULDBLOCK
838843 errno != EWOULDBLOCK &&
839844# endif
840- errno != ENOBUFS
841- #else
842- WSAGetLastError () != WSAEINPROGRESS &&
843- WSAGetLastError () != WSAEINTR &&
844- WSAGetLastError () != WSAENOBUFS &&
845- WSAGetLastError () != WSAEWOULDBLOCK
845+ errno != ENOMEM && errno != ENOBUFS
846+ #else /* USE_WINSOCK */
847+ /* Sleep does not error */
846848#endif
847849 ) {
848850 log_err ("poll udp out timer failed: %s" ,
0 commit comments