"TCP receive buffer size must be smaller or equal than worker "
"receive buffer size");
+/*%
+ * Maximum outstanding DNS message that we process in a single TCP read.
+ */
+#define ISC_NETMGR_MAX_STREAM_CLIENTS_PER_CONN 23
+
/*%
* Regular TCP buffer size.
*/
ISC_LIST(isc_nmhandle_t) active_handles;
ISC_LIST(isc__nm_uvreq_t) active_uvreqs;
+ size_t active_handles_cur;
+ size_t active_handles_max;
+
/*%
* Used to pass a result back from listen or connect events.
*/
.inactive_handles = ISC_LIST_INITIALIZER,
.result = ISC_R_UNSET,
.active_handles = ISC_LIST_INITIALIZER,
+ .active_handles_max = ISC_NETMGR_MAX_STREAM_CLIENTS_PER_CONN,
.active_link = ISC_LINK_INITIALIZER,
.active = true,
};
}
ISC_LIST_APPEND(sock->active_handles, handle, active_link);
+ sock->active_handles_cur++;
switch (sock->type) {
case isc_nm_udpsocket:
}
ISC_LIST_UNLINK(sock->active_handles, handle, active_link);
+ INSIST(sock->active_handles_cur > 0);
+ sock->active_handles_cur--;
if (sock->closehandle_cb == NULL) {
nmhandle__destroy(handle);
static bool
streamdns_closing(isc_nmsocket_t *sock);
+static void
+streamdns_resume_processing(void *arg);
+
static void
streamdns_resumeread(isc_nmsocket_t *sock, isc_nmhandle_t *transphandle) {
if (!sock->streamdns.reading) {
stop = true;
}
+ if (sock->active_handles_max != 0 &&
+ (sock->active_handles_cur >= sock->active_handles_max))
+ {
+ stop = true;
+ }
+ INSIST(sock->active_handles_cur <= sock->active_handles_max);
+
isc__nmsocket_timer_stop(sock);
- if (!stop && last_datum) {
+ if (stop) {
+ streamdns_pauseread(sock, transphandle);
+ } else if (last_datum) {
/*
* We have processed all data, need to read more.
* The call also restarts the timer.
*/
streamdns_readmore(sock, transphandle);
- } else if (stop) {
+ } else {
+ /*
+ * Process more DNS messages in the next loop tick.
+ */
streamdns_pauseread(sock, transphandle);
+ isc_async_run(sock->worker->loop, streamdns_resume_processing,
+ sock);
}
- return (!stop);
+ return (false);
}
/*
return;
}
+ if (sock->active_handles_max != 0 &&
+ (sock->active_handles_cur >= sock->active_handles_max))
+ {
+ return;
+ }
+
streamdns_handle_incoming_data(sock, sock->outerhandle, NULL, 0);
}