From e4f94ceb13c18ee13cabbeba34f5a016fce3e37d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 21 Sep 2015 17:22:53 +1000 Subject: [PATCH] 4219. [bug] Set event->result to ISC_R_WOULDBLOCK on EWOULDBLOCK, EGAIN when these soft error are not retried for isc_socket_send*(). (cherry picked from commit a21c415687a855f84fbf10db91671b1341e8b990) --- CHANGES | 4 ++++ lib/isc/include/isc/result.h | 3 ++- lib/isc/result.c | 1 + lib/isc/unix/socket.c | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 02c5d61f0d..e31e8bda4b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4219. [bug] Set event->result to ISC_R_WOULDBLOCK on EWOULDBLOCK, + EGAIN when these soft error are not retried for + isc_socket_send*(). + 4218. [bug] Potential null pointer dereference on out of memory if mmap is not supported. [RT #40777] diff --git a/lib/isc/include/isc/result.h b/lib/isc/include/isc/result.h index ed1bc63e73..f6088d9e39 100644 --- a/lib/isc/include/isc/result.h +++ b/lib/isc/include/isc/result.h @@ -89,9 +89,10 @@ #define ISC_R_BADBASE32 60 /*%< bad base32 encoding */ #define ISC_R_UNSET 61 /*%< unset */ #define ISC_R_MULTIPLE 62 /*%< multiple */ +#define ISC_R_WOULDBLOCK 63 /*%< would block */ /*% Not a result code: the number of results. */ -#define ISC_R_NRESULTS 63 +#define ISC_R_NRESULTS 64 ISC_LANG_BEGINDECLS diff --git a/lib/isc/result.c b/lib/isc/result.c index 6cbd8b4722..27927e8f25 100644 --- a/lib/isc/result.c +++ b/lib/isc/result.c @@ -104,6 +104,7 @@ static const char *description[ISC_R_NRESULTS] = { "bad base32 encoding", /*%< 60 */ "unset", /*%< 61 */ "multiple", /*%< 62 */ + "would block", /*%< 63 */ }; #define ISC_RESULT_RESULTSET 2 diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index e78f12897a..6bbaa04cf9 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -2053,8 +2053,11 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) { if (send_errno == EINTR && ++attempts < NRETRIES) goto resend; - if (SOFT_ERROR(send_errno)) + if (SOFT_ERROR(send_errno)) { + if (errno == EWOULDBLOCK || errno == EAGAIN) + dev->result = ISC_R_WOULDBLOCK; return (DOIO_SOFT); + } #define SOFT_OR_HARD(_system, _isc) \ if (send_errno == _system) { \