1
0
mirror of https://github.com/lammertb/libhttp.git synced 2026-01-27 08:02:47 +03:00

Moved tls_dtor to own file

This commit is contained in:
Lammert Bies
2016-12-10 10:45:55 +01:00
parent 95f4817397
commit 516dcf8832
3 changed files with 52 additions and 16 deletions

View File

@@ -78,6 +78,7 @@ LIB_SOURCES = src/libhttp.c \
src/httplib_sslize.c \
src/httplib_start.c \
src/httplib_stop.c \
src/httplib_tls_dtor.c \
src/httplib_uninitialize_ssl.c \
src/httplib_version.c \
src/httplib_websocket_client_thread.c \

50
src/httplib_tls_dtor.c Normal file
View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2016 Lammert Bies
* Copyright (c) 2013-2016 the Civetweb developers
* Copyright (c) 2004-2013 Sergey Lyubka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "libhttp-private.h"
/*
* void XX_httplib_tls_dtor( void *key );
*
* The function XX_httplib_tls_dtor() is used sets the TLS key for the thread.
*/
void XX_httplib_tls_dtor( void *key ) {
struct mg_workerTLS *tls = (struct mg_workerTLS *)key;
/* key == pthread_getspecific(XX_httplib_sTlsKey); */
if (tls) {
if (tls->is_master == 2) {
tls->is_master = -3; /* Mark memory as dead */
XX_httplib_free(tls);
}
}
pthread_setspecific(XX_httplib_sTlsKey, NULL);
} /* XX_httplib_tls_dtor */

View File

@@ -8331,6 +8331,7 @@ int XX_httplib_check_acl( struct mg_context *ctx, uint32_t remote_ip ) {
#if !defined(_WIN32)
int XX_httplib_set_uid_option( struct mg_context *ctx ) {
struct passwd *pw;
@@ -8356,19 +8357,3 @@ int XX_httplib_set_uid_option( struct mg_context *ctx ) {
} /* XX_httplib_set_uid_option */
#endif /* !_WIN32 */
void XX_httplib_tls_dtor( void *key ) {
struct mg_workerTLS *tls = (struct mg_workerTLS *)key;
/* key == pthread_getspecific(XX_httplib_sTlsKey); */
if (tls) {
if (tls->is_master == 2) {
tls->is_master = -3; /* Mark memory as dead */
XX_httplib_free(tls);
}
}
pthread_setspecific(XX_httplib_sTlsKey, NULL);
} /* XX_httplib_tls_dtor */