diff options
| author | yangwei <[email protected]> | 2022-05-25 18:37:24 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2022-05-25 18:37:24 +0800 |
| commit | da241e85e6310d2f924ab1bdb1c991354e6c62b9 (patch) | |
| tree | 9f7951d2d82f5f16930e916342bb99f92e200732 | |
| parent | 1141552b128d4675a1e1c094d45f7c3b7faa38bb (diff) | |
🐞 fix(FS_library_destroy): 修复更换httpserver后,server线程在destroy后未退出的bug
由于httpsever内部使用while(1)循环,destroy时主动调用pthread_cancel关闭线程
| -rw-r--r-- | src/fs2prometheus.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/fs2prometheus.cpp b/src/fs2prometheus.cpp index ae81206..bb64d9f 100644 --- a/src/fs2prometheus.cpp +++ b/src/fs2prometheus.cpp @@ -335,6 +335,7 @@ void *FS_library_promethues_listen(void *arg) if(_handle!=NULL) { _handle->server_handle=http_server_init(_handle->port, FS_library_promethues_output); + //pthread_testcancel(); http_server_listen(_handle->server_handle); } @@ -405,6 +406,7 @@ void FS_library_destroy(void) if(g_FS2_LIBRARY_handle.create_thread == 1) { g_FS2_LIBRARY_handle.create_thread = 0; + pthread_cancel(g_FS2_LIBRARY_handle.tid); pthread_join(g_FS2_LIBRARY_handle.tid, &ret); } if(g_FS2_LIBRARY_handle.url_path != NULL) |
