ISC_LIST_APPEND(httpdmgr->running, httpd, link);
UNLOCK(&httpdmgr->lock);
- isc_nmhandle_attach(handle, &httpd->readhandle);
+ isc_nmhandle_attach(httpd->handle, &httpd->readhandle);
isc_nm_read(handle, httpd_request, httpdmgr);
}
httpd = isc_nmhandle_getdata(handle);
REQUIRE(httpd->state == RECV);
+ REQUIRE(httpd->handle == handle);
if (eresult != ISC_R_SUCCESS) {
goto cleanup_readhandle;
/* don't unref, keep reading */
return;
}
+
/*
- * We have been called from httpd_senddone
- * and we need to resume reading. Detach
- * readhandle before resuming.
+ * We must have been called from httpd_senddone (as
+ * ISC_R_NOTFOUND is not returned from netmgr) and we
+ * need to resume reading.
*/
- isc_nmhandle_detach(&httpd->readhandle);
- isc_nm_resumeread(handle);
+ isc_nm_resumeread(httpd->readhandle);
return;
}
goto cleanup_readhandle;
*/
isc_buffer_usedregion(httpd->sendbuffer, &r);
- isc_nm_pauseread(handle);
+ isc_nm_pauseread(httpd->handle);
httpd->state = SEND;
- isc_nmhandle_attach(handle, &httpd->sendhandle);
- isc_nm_send(handle, &r, httpd_senddone, httpd);
+ isc_nmhandle_attach(httpd->handle, &httpd->sendhandle);
+ isc_nm_send(httpd->sendhandle, &r, httpd_senddone, httpd);
+ return;
cleanup_readhandle:
isc_nmhandle_detach(&httpd->readhandle);
REQUIRE(VALID_HTTPD(httpd));
REQUIRE(httpd->state == SEND);
+ REQUIRE(httpd->handle == handle);
isc_buffer_free(&httpd->sendbuffer);
isc_nmhandle_detach(&httpd->sendhandle);
if (result != ISC_R_SUCCESS) {
- return;
+ goto cleanup_readhandle;
+ }
+
+ if ((httpd->flags & HTTPD_CLOSE) != 0) {
+ goto cleanup_readhandle;
}
httpd->state = RECV;
+ httpd->sendhandle = NULL;
+
if (httpd->recvlen != 0) {
/*
* Outstanding requests still exist, start processing
* them.
*/
- isc_nmhandle_attach(handle, &httpd->readhandle);
- httpd_request(handle, ISC_R_SUCCESS, NULL, httpd->mgr);
+ httpd_request(httpd->handle, ISC_R_SUCCESS, NULL, httpd->mgr);
} else if (!httpd->truncated) {
- isc_nm_resumeread(handle);
+ isc_nm_resumeread(httpd->readhandle);
+ } else {
+ /* Truncated request, don't resume */
+ goto cleanup_readhandle;
}
+
+ return;
+
+cleanup_readhandle:
+ isc_nmhandle_detach(&httpd->readhandle);
}
isc_result_t