diff --git a/src/protocol/curl/ftp.c b/src/protocol/curl/ftp.c index 0e7e4bfbd..7c8493c8b 100644 --- a/src/protocol/curl/ftp.c +++ b/src/protocol/curl/ftp.c @@ -37,6 +37,7 @@ #include "config/options.h" #include "intl/libintl.h" #include "main/select.h" +#include "main/main.h" #include "main/module.h" #include "network/connection.h" #include "network/progress.h" @@ -383,8 +384,11 @@ done_ftpes(struct connection *conn) if (!ftp || !ftp->easy) { return; } - curl_multi_remove_handle(g.multi, ftp->easy); - curl_easy_cleanup(ftp->easy); + + if (!program.terminate) { + curl_multi_remove_handle(g.multi, ftp->easy); + curl_easy_cleanup(ftp->easy); + } } static void diff --git a/src/protocol/curl/http.c b/src/protocol/curl/http.c index 90fe729a3..84a1c840d 100644 --- a/src/protocol/curl/http.c +++ b/src/protocol/curl/http.c @@ -40,6 +40,7 @@ #include "config/options.h" #include "intl/libintl.h" #include "main/select.h" +#include "main/main.h" #include "main/module.h" #include "network/connection.h" #include "network/progress.h" @@ -116,8 +117,10 @@ done_http_curl(struct connection *conn) if (!http || !http->easy) { return; } - curl_multi_remove_handle(g.multi, http->easy); - curl_easy_cleanup(http->easy); + if (!program.terminate) { + curl_multi_remove_handle(g.multi, http->easy); + curl_easy_cleanup(http->easy); + } done_string(&http->headers); done_string(&http->post_headers); mem_free_if(http->post_buffer);