REQUIRE(sock->type == isc_nm_tcpdnssocket);
if (sock->outer == NULL) {
- /* The socket is closed, just issue the callback */
- cb(handle, ISC_R_FAILURE, cbarg);
+ /* The socket is closed */
return (ISC_R_NOTCONNECTED);
}
/*
* Simulate a firewall blocking UDP packets bigger than
- * 'maxudp' bytes.
+ * 'maxudp' bytes, for testing purposes.
+ *
+ * The client would ordinarily have unreferenced the handle
+ * in the callback, but that won't happen in this case, so
+ * we need to do so here.
*/
if (maxudp != 0 && region->length > maxudp) {
isc_nmhandle_unref(handle);
} else if (sock->type == isc_nm_udplistener) {
psock = sock;
} else {
- isc_nmhandle_unref(handle);
return (ISC_R_UNEXPECTED);
}
if (!isc__nmsocket_active(sock)) {
- isc_nmhandle_unref(handle);
return (ISC_R_CANCELED);
}
r.base[1] = client->message->id & 0xff;
result = client_sendpkg(client, &buffer);
- if (result == ISC_R_SUCCESS)
+ if (result == ISC_R_SUCCESS) {
return;
+ }
done:
if (client->tcpbuf != NULL) {
}
ns_client_drop(client, result);
+ isc_nmhandle_unref(client->handle);
}
void
isc_nmhandle_ref(client->handle);
result = client_sendpkg(client, &tcpbuffer);
+ if (result != ISC_R_SUCCESS) {
+ /* We won't get a callback to clean it up */
+ isc_nmhandle_unref(client->handle);
+ }
switch (isc_sockaddr_pf(&client->peeraddr)) {
case AF_INET:
isc_nmhandle_ref(client->handle);
result = client_sendpkg(client, &buffer);
+ if (result != ISC_R_SUCCESS) {
+ /* We won't get a callback to clean it up */
+ isc_nmhandle_unref(client->handle);
+ }
switch (isc_sockaddr_pf(&client->peeraddr)) {
case AF_INET:
xfrout_fail(xfr, result, "send");
} else if (xfr->end_of_stream == false) {
sendstream(xfr);
- /* Return now so we don't unref the handle */
- return;
} else {
/* End of zone transfer stream. */
uint64_t msecs, persec;
(unsigned int) persec);
xfrout_ctx_destroy(&xfr);
+ /* We're done, unreference the handle */
+ isc_nmhandle_unref(handle);
}
-
- isc_nmhandle_unref(handle);
}
static void