#include <isc/async.h>
#include <isc/atomic.h>
+#include <isc/log.h>
#include <isc/result.h>
#include <isc/thread.h>
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->tid == isc_tid());
+ sock->processing = false;
+
if (streamdns_closing(sock)) {
streamdns_failed_read_cb(sock, ISC_R_CANCELED, false);
goto detach;
isc_nmhandle_attach(handle, &sock->recv_handle);
}
+ /*
+ * Prevent scheduling the job or processing data if streamdns_read_cb
+ * has been already scheduled.
+ */
+ if (sock->processing) {
+ return;
+ }
+
/*
* In some cases there is little sense in making the operation
* asynchronous as we just want to start reading from the
*/
isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL });
+ sock->processing = true;
isc_job_run(sock->worker->loop, &sock->job, streamdns_read_cb, sock);
}