Update PR

* Update PR
This commit is contained in:
abraunegg 2025-12-27 07:33:57 +11:00
commit ee1f75dd3b
3 changed files with 18 additions and 9 deletions

View file

@ -622,6 +622,10 @@ class CurlEngine {
object.destroy(http); // Destroy, however we cant set to null
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("Stopped HTTP instance shutdown and destroyed: " ~ to!string(internalThreadId), ["debug"]);}
}
// Perform Garbage Collection
GC.collect();
// Return free memory to the OS
GC.minimize();
}
// Disable SSL certificate peer verification for libcurl operations.
@ -766,6 +770,10 @@ void releaseAllCurlInstances() {
curlEnginePool.length = 0; // More explicit than curlEnginePool = [];
}
}
// Perform Garbage Collection on the destroyed curl engines
GC.collect();
// Return free memory to the OS
GC.minimize();
// Log that all curl engines have been released
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine releaseAllCurlInstances() completed", ["debug"]);}
}

View file

@ -44,7 +44,7 @@ final class CurlWebSocket {
private:
// libcurl constants defined locally
enum long CURL_GLOBAL_DEFAULT = 3;
enum long CURL_GLOBAL_DEFAULT = 3;
enum int CURLOPT_URL = 10002;
enum int CURLOPT_FOLLOWLOCATION = 52;
enum int CURLOPT_NOSIGNAL = 99;
@ -98,6 +98,7 @@ public:
curl = null;
}
websocketConnected = false;
object.destroy(curl);
logCurlWebsocketOutput("Cleaned-up an instance of a CurlWebSocket object accessing libcurl for HTTP operations");
}
@ -106,16 +107,16 @@ public:
}
void setTimeouts(int connectMs, int rwMs) {
this.connectTimeoutMs = connectMs;
this.ioTimeoutMs = rwMs;
connectTimeoutMs = connectMs;
ioTimeoutMs = rwMs;
}
void setUserAgent(string ua) {
if (!ua.empty) userAgent = ua;
}
void setHTTPSDebug(bool httpsDebug) {
this.httpsDebug = httpsDebug;
void setHTTPSDebug(bool httpsDebugInput) {
this.httpsDebug = httpsDebugInput;
}
int connect(string wsUrl) {
@ -137,9 +138,9 @@ public:
string connectUrl = (scheme == "wss" ? "https://" : "http://") ~ hostPort ~ pathQuery;
// Reset
// Reset 'curl' using curl_easy_reset
curl_easy_reset(curl);
// Configure curl options
// Configure required curl options
curl_easy_setopt(curl, cast(int)CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(curl, cast(int)CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, cast(int)CURLOPT_USERAGENT, userAgent.toStringz); // NUL-terminated

View file

@ -473,9 +473,9 @@ bool testInternetReachability(ApplicationConfig appConfig, bool displayLogging =
bool reachedService = false;
// Exit scope to ensure cleanup
// Exit scope to ensure cleanup http object
scope(exit) {
// Ensure everything is shutdown cleanly
// Shut http down http object
http.shutdown();
// Destroy http object
object.destroy(http);