Skip to content

Commit

Permalink
Fix: close http client in rust_g to prevent memory leak issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Bizzonium authored and Dimach committed Jun 27, 2023
1 parent 8c64650 commit 12c263e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
#define rustg_http_request_blocking(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_blocking")(method, url, body, headers, options)
#define rustg_http_request_async(method, url, body, headers, options) RUSTG_CALL(RUST_G, "http_request_async")(method, url, body, headers, options)
#define rustg_http_check_request(req_id) RUSTG_CALL(RUST_G, "http_check_request")(req_id)
/proc/rustg_create_async_http_client() return RUSTG_CALL(RUST_G, "start_http_client")()
/proc/rustg_close_async_http_client() return RUSTG_CALL(RUST_G, "shutdown_http_client")()

#define RUSTG_JOB_NO_RESULTS_YET "NO RESULTS YET"
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
Expand Down
5 changes: 3 additions & 2 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ GLOBAL_VAR(restart_counter)
* - Dominion/Cyberboss
*
* Where to put init shit quick guide:
* If you need it to happen before the mc is created: world/Genesis.
* If you need it to happen last: world/New(),
* If you need it to happen before the mc is created: world/Genesis.
* If you need it to happen last: world/New(),
* Otherwise, in a subsystem preinit or init. Subsystems can set an init priority.
*/

Expand Down Expand Up @@ -327,6 +327,7 @@ GLOBAL_VAR(restart_counter)
#endif

/world/proc/auxcleanup()
rustg_close_async_http_client() // Close the HTTP client. If you dont do this, youll get phantom threads which can crash DD from memory access violations
AUXTOOLS_FULL_SHUTDOWN(AUXLUA)
var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL")
if (debug_server)
Expand Down

0 comments on commit 12c263e

Please sign in to comment.