int *waitp)
{
CURLcode result = CURLE_OK;
- int slot;
struct dohdata *dohp;
struct connectdata *conn = data->conn;
#ifdef USE_HTTPSRR
return NULL;
error:
- curl_slist_free_all(dohp->headers);
- data->req.doh->headers = NULL;
- for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
- (void)curl_multi_remove_handle(data->multi, dohp->probe[slot].easy);
- Curl_close(&dohp->probe[slot].easy);
- }
- Curl_safefree(data->req.doh);
+ Curl_doh_cleanup(data);
return NULL;
}
struct dohentry de;
int slot;
/* remove DoH handles from multi handle and close them */
- for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
- curl_multi_remove_handle(data->multi, dohp->probe[slot].easy);
- Curl_close(&dohp->probe[slot].easy);
- }
+ Curl_doh_close(data);
/* parse the responses, create the struct and return it! */
de_init(&de);
for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
return CURLE_OK;
}
+void Curl_doh_close(struct Curl_easy *data)
+{
+ struct dohdata *doh = data->req.doh;
+ if(doh) {
+ size_t slot;
+ for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
+ if(!doh->probe[slot].easy)
+ continue;
+ /* data->multi might already be reset at this time */
+ if(doh->probe[slot].easy->multi)
+ curl_multi_remove_handle(doh->probe[slot].easy->multi,
+ doh->probe[slot].easy);
+ Curl_close(&doh->probe[slot].easy);
+ }
+ }
+}
+
+void Curl_doh_cleanup(struct Curl_easy *data)
+{
+ struct dohdata *doh = data->req.doh;
+ if(doh) {
+ Curl_doh_close(data);
+ curl_slist_free_all(doh->headers);
+ data->req.doh->headers = NULL;
+ Curl_safefree(data->req.doh);
+ }
+}
+
#endif /* CURL_DISABLE_DOH */
Curl_bufq_reset(&req->sendbuf);
#ifndef CURL_DISABLE_DOH
- if(req->doh) {
- Curl_close(&req->doh->probe[0].easy);
- Curl_close(&req->doh->probe[1].easy);
- }
+ Curl_doh_close(data);
#endif
/* Can no longer memset() this struct as we need to keep some state */
req->size = -1;
Curl_client_cleanup(data);
#ifndef CURL_DISABLE_DOH
- if(req->doh) {
- Curl_close(&req->doh->probe[0].easy);
- Curl_close(&req->doh->probe[1].easy);
- Curl_dyn_free(&req->doh->probe[0].serverdoh);
- Curl_dyn_free(&req->doh->probe[1].serverdoh);
- curl_slist_free_all(req->doh->headers);
- Curl_safefree(req->doh);
- }
+ Curl_doh_cleanup(data);
#endif
}