mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
Don't crash if isc_uv_export returns an error in accept_connection.
isc_uv_export can return an error - e.g. EMFILE (from dup), handle this nicely.
This commit is contained in:
committed by
Evan Hunt
parent
afca2e3b21
commit
ae9a6befa8
@@ -16,6 +16,7 @@
|
|||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/condition.h>
|
#include <isc/condition.h>
|
||||||
|
#include <isc/errno.h>
|
||||||
#include <isc/log.h>
|
#include <isc/log.h>
|
||||||
#include <isc/magic.h>
|
#include <isc/magic.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
@@ -933,7 +934,9 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc__nm_uverr2result(r);
|
||||||
uv_close((uv_handle_t *)uvstream, free_uvtcpt);
|
uv_close((uv_handle_t *)uvstream, free_uvtcpt);
|
||||||
isc_quota_detach("a);
|
if (quota != NULL) {
|
||||||
|
isc_quota_detach("a);
|
||||||
|
}
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,6 +945,17 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
event = isc__nm_get_ievent(ssock->mgr, netievent_tcpchildaccept);
|
event = isc__nm_get_ievent(ssock->mgr, netievent_tcpchildaccept);
|
||||||
|
|
||||||
/* Duplicate the server socket */
|
/* Duplicate the server socket */
|
||||||
|
r = isc_uv_export((uv_stream_t *)uvstream, &event->streaminfo);
|
||||||
|
if (r != 0) {
|
||||||
|
result = isc_errno_toresult(errno);
|
||||||
|
uv_close((uv_handle_t *)uvstream, free_uvtcpt);
|
||||||
|
if (quota != NULL) {
|
||||||
|
isc_quota_detach("a);
|
||||||
|
}
|
||||||
|
isc__nm_put_ievent(ssock->mgr, event);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
isc_nmsocket_t *csock = isc_mem_get(ssock->mgr->mctx,
|
isc_nmsocket_t *csock = isc_mem_get(ssock->mgr->mctx,
|
||||||
sizeof(isc_nmsocket_t));
|
sizeof(isc_nmsocket_t));
|
||||||
isc__nmsocket_init(csock, ssock->mgr, isc_nm_tcpsocket, ssock->iface);
|
isc__nmsocket_init(csock, ssock->mgr, isc_nm_tcpsocket, ssock->iface);
|
||||||
@@ -954,9 +968,6 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
event->sock = csock;
|
event->sock = csock;
|
||||||
event->quota = quota;
|
event->quota = quota;
|
||||||
|
|
||||||
r = isc_uv_export((uv_stream_t *)uvstream, &event->streaminfo);
|
|
||||||
RUNTIME_CHECK(r == 0);
|
|
||||||
|
|
||||||
uv_close((uv_handle_t *)uvstream, free_uvtcpt);
|
uv_close((uv_handle_t *)uvstream, free_uvtcpt);
|
||||||
|
|
||||||
if (w == isc_nm_tid()) {
|
if (w == isc_nm_tid()) {
|
||||||
|
Reference in New Issue
Block a user