mirror of
https://github.com/coturn/coturn.git
synced 2025-10-24 12:31:00 +02:00
memory cleaning
This commit is contained in:
parent
5177adb626
commit
04f354d563
@ -35,4 +35,4 @@ fi
|
|||||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
|
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
|
||||||
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
|
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
|
||||||
|
|
||||||
PATH="./bin/:../bin/:../../bin/:${PATH}" turnserver --server-name="blackdow.carleon.gov" -v --syslog -a -L 127.0.0.1 -L ::1 -E 127.0.0.1 -E ::1 --max-bps=3000000 -f -m 3 --min-port=32355 --max-port=65535 -r north.gov --redis-userdb="ip=127.0.0.1 dbname=2 password=turn connect_timeout=30" --redis-statsdb="ip=127.0.0.1 dbname=3 password=turn connect_timeout=30" --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --log-file=stdout --cipher-list=ALL:SSLv2 --oauth $@
|
PATH="./bin/:../bin/:../../bin/:${PATH}" turnserver --server-name="blackdow.carleon.gov" --syslog -a -L 127.0.0.1 -L ::1 -E 127.0.0.1 -E ::1 --max-bps=3000000 -f -m 3 --min-port=32355 --max-port=65535 -r north.gov --redis-userdb="ip=127.0.0.1 dbname=2 password=turn connect_timeout=30" --redis-statsdb="ip=127.0.0.1 dbname=3 password=turn connect_timeout=30" --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --log-file=stdout --cipher-list=ALL:SSLv2 --oauth $@
|
||||||
|
|||||||
@ -658,6 +658,7 @@ int get_canonic_origin(const char* o, char *co, int sz)
|
|||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
#if defined(TURN_MEMORY_DEBUG)
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -691,15 +692,22 @@ static void add_tm_ptr(void *ptr, const char *id) {
|
|||||||
if(!ptr)
|
if(!ptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
string sid(id);
|
||||||
|
|
||||||
|
str_to_ptrs_t::iterator iter;
|
||||||
|
|
||||||
pthread_mutex_lock(&tm);
|
pthread_mutex_lock(&tm);
|
||||||
|
|
||||||
string sid(id);
|
iter = str_to_ptrs.find(sid);
|
||||||
if(str_to_ptrs.find(sid) == str_to_ptrs.end()) {
|
|
||||||
|
if(iter == str_to_ptrs.end()) {
|
||||||
set<ptrtype> sp;
|
set<ptrtype> sp;
|
||||||
|
sp.insert(ptr);
|
||||||
str_to_ptrs[sid]=sp;
|
str_to_ptrs[sid]=sp;
|
||||||
|
} else {
|
||||||
|
iter->second.insert(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
str_to_ptrs[sid].insert(ptr);
|
|
||||||
ptr_to_str[ptr]=sid;
|
ptr_to_str[ptr]=sid;
|
||||||
|
|
||||||
pthread_mutex_unlock(&tm);
|
pthread_mutex_unlock(&tm);
|
||||||
@ -716,11 +724,25 @@ static void del_tm_ptr(void *ptr, const char *id) {
|
|||||||
pthread_mutex_lock(&tm);
|
pthread_mutex_lock(&tm);
|
||||||
|
|
||||||
ptr_to_str_t::iterator pts_iter = ptr_to_str.find(ptr);
|
ptr_to_str_t::iterator pts_iter = ptr_to_str.find(ptr);
|
||||||
if(pts_iter != ptr_to_str.end()) {
|
if(pts_iter == ptr_to_str.end()) {
|
||||||
|
|
||||||
|
printf("Tring to free unknown pointer (1): %s\n",id);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
string sid = pts_iter->second;
|
string sid = pts_iter->second;
|
||||||
ptr_to_str.erase(pts_iter);
|
ptr_to_str.erase(pts_iter);
|
||||||
if(str_to_ptrs.find(sid) != str_to_ptrs.end()) {
|
|
||||||
str_to_ptrs[sid].erase(ptr);
|
str_to_ptrs_t::iterator iter = str_to_ptrs.find(sid);
|
||||||
|
|
||||||
|
if(iter == str_to_ptrs.end()) {
|
||||||
|
|
||||||
|
printf("Tring to free unknown pointer (2): %s\n",id);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
iter->second.erase(ptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,7 +760,8 @@ void tm_print_func(void) {
|
|||||||
pthread_mutex_lock(&tm);
|
pthread_mutex_lock(&tm);
|
||||||
printf("=============================================\n");
|
printf("=============================================\n");
|
||||||
for(str_to_ptrs_t::const_iterator iter=str_to_ptrs.begin();iter != str_to_ptrs.end();++iter) {
|
for(str_to_ptrs_t::const_iterator iter=str_to_ptrs.begin();iter != str_to_ptrs.end();++iter) {
|
||||||
printf("%s: %s: %d\n",__FUNCTION__,iter->first.c_str(),(int)(iter->second.size()));
|
if(iter->second.size())
|
||||||
|
printf("%s: %s: %d\n",__FUNCTION__,iter->first.c_str(),(int)(iter->second.size()));
|
||||||
}
|
}
|
||||||
printf("=============================================\n");
|
printf("=============================================\n");
|
||||||
pthread_mutex_unlock(&tm);
|
pthread_mutex_unlock(&tm);
|
||||||
@ -763,7 +786,8 @@ void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* fil
|
|||||||
|
|
||||||
TM_START();
|
TM_START();
|
||||||
|
|
||||||
del_tm_ptr(ptr,id);
|
if(ptr)
|
||||||
|
del_tm_ptr(ptr,id);
|
||||||
|
|
||||||
ptr = realloc(ptr,new_sz);
|
ptr = realloc(ptr,new_sz);
|
||||||
|
|
||||||
@ -784,6 +808,16 @@ void turn_free_func(void *ptr, size_t sz, const char* file, int line) {
|
|||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void turn_free_simple(void *ptr);
|
||||||
|
void turn_free_simple(void *ptr) {
|
||||||
|
|
||||||
|
tm_init();
|
||||||
|
|
||||||
|
del_tm_ptr(ptr,__FUNCTION__);
|
||||||
|
|
||||||
|
free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
void *turn_calloc_func(size_t number, size_t size, const char* file, int line);
|
void *turn_calloc_func(size_t number, size_t size, const char* file, int line);
|
||||||
void *turn_calloc_func(size_t number, size_t size, const char* file, int line) {
|
void *turn_calloc_func(size_t number, size_t size, const char* file, int line) {
|
||||||
|
|
||||||
@ -808,6 +842,7 @@ char *turn_strdup_func(const char* s, const char* file, int line) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -72,7 +72,7 @@ static void MongoFree(MONGO * info) {
|
|||||||
if(info) {
|
if(info) {
|
||||||
if(info->uri) mongoc_uri_destroy(info->uri);
|
if(info->uri) mongoc_uri_destroy(info->uri);
|
||||||
if(info->client) mongoc_client_destroy(info->client);
|
if(info->client) mongoc_client_destroy(info->client);
|
||||||
turn_free(info, sizeof(MONGO));
|
turn_free(info, sizeof(MONGO));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +860,8 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
|
|||||||
BSON_APPEND_UTF8(&query, "realm", (const char *)realm);
|
BSON_APPEND_UTF8(&query, "realm", (const char *)realm);
|
||||||
bson_init(&doc);
|
bson_init(&doc);
|
||||||
|
|
||||||
char * _k = (char *)turn_malloc(9 + strlen(opt));
|
size_t klen = 9 + strlen(opt);
|
||||||
|
char * _k = (char *)turn_malloc(klen);
|
||||||
strcpy(_k, "options.");
|
strcpy(_k, "options.");
|
||||||
strcat(_k, opt);
|
strcat(_k, opt);
|
||||||
|
|
||||||
@ -873,7 +874,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
|
|||||||
BSON_APPEND_INT32(&child, _k, 1);
|
BSON_APPEND_INT32(&child, _k, 1);
|
||||||
bson_append_document_end(&doc, &child);
|
bson_append_document_end(&doc, &child);
|
||||||
}
|
}
|
||||||
free(_k);
|
turn_free(_k,klen);
|
||||||
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
@ -1010,113 +1011,129 @@ static int mongo_get_ip_list(const char *kind, ip_range_list_t * list) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mongo_reread_realms(secrets_list_t * realms_list) {
|
static void mongo_reread_realms(secrets_list_t * realms_list) {
|
||||||
|
|
||||||
UNUSED_ARG(realms_list);
|
UNUSED_ARG(realms_list);
|
||||||
|
|
||||||
mongoc_collection_t * collection = mongo_get_collection("realm");
|
mongoc_collection_t * collection = mongo_get_collection("realm");
|
||||||
|
|
||||||
if(!collection)
|
if (!collection)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bson_t query;
|
bson_t query;
|
||||||
bson_init(&query);
|
bson_init(&query);
|
||||||
|
|
||||||
bson_t fields;
|
bson_t fields;
|
||||||
bson_init(&fields);
|
bson_init(&fields);
|
||||||
BSON_APPEND_INT32(&fields, "realm", 1);
|
BSON_APPEND_INT32(&fields, "realm", 1);
|
||||||
BSON_APPEND_INT32(&fields, "origin", 1);
|
BSON_APPEND_INT32(&fields, "origin", 1);
|
||||||
BSON_APPEND_INT32(&fields, "options", 1);
|
BSON_APPEND_INT32(&fields, "options", 1);
|
||||||
|
|
||||||
mongoc_cursor_t * cursor;
|
|
||||||
cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 0, 0, &query, &fields, NULL);
|
|
||||||
|
|
||||||
if (!cursor) {
|
mongoc_cursor_t * cursor;
|
||||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error querying MongoDB collection 'realm'\n");
|
cursor = mongoc_collection_find(collection, MONGOC_QUERY_NONE, 0, 0, 0,
|
||||||
} else {
|
&query, &fields, NULL);
|
||||||
ur_string_map *o_to_realm_new = ur_string_map_create(free);
|
|
||||||
|
|
||||||
const bson_t * item;
|
if (!cursor) {
|
||||||
uint32_t length;
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
|
||||||
bson_iter_t iter;
|
"Error querying MongoDB collection 'realm'\n");
|
||||||
|
} else {
|
||||||
|
ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
|
||||||
|
|
||||||
while (mongoc_cursor_next(cursor, &item)) {
|
const bson_t * item;
|
||||||
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "realm") && BSON_ITER_HOLDS_UTF8(&iter)) {
|
uint32_t length;
|
||||||
char * _realm = strdup(bson_iter_utf8(&iter, &length));
|
bson_iter_t iter;
|
||||||
|
|
||||||
get_realm(_realm);
|
while (mongoc_cursor_next(cursor, &item)) {
|
||||||
|
|
||||||
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "origin") && BSON_ITER_HOLDS_ARRAY(&iter)) {
|
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "realm")
|
||||||
const uint8_t *docbuf = NULL;
|
&& BSON_ITER_HOLDS_UTF8(&iter)) {
|
||||||
uint32_t doclen = 0;
|
|
||||||
bson_t origin_array;
|
|
||||||
bson_iter_t origin_iter;
|
|
||||||
|
|
||||||
bson_iter_array(&iter, &doclen, &docbuf);
|
char * _realm = turn_strdup(bson_iter_utf8(&iter, &length));
|
||||||
bson_init_static(&origin_array, docbuf, doclen);
|
|
||||||
|
|
||||||
if (bson_iter_init(&origin_iter, &origin_array)) {
|
get_realm(_realm);
|
||||||
while(bson_iter_next(&origin_iter)) {
|
|
||||||
if (BSON_ITER_HOLDS_UTF8(&origin_iter)) {
|
|
||||||
char * _origin = strdup(bson_iter_utf8(&origin_iter, &length));
|
|
||||||
char *rval = strdup(_realm);
|
|
||||||
ur_string_map_value_type value = (ur_string_map_value_type)(rval);
|
|
||||||
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) _origin, value);
|
|
||||||
free(_origin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
realm_params_t* rp = get_realm(_realm);
|
|
||||||
lock_realms();
|
|
||||||
rp->options.perf_options.max_bps = turn_params.max_bps;
|
|
||||||
rp->options.perf_options.total_quota = turn_params.total_quota;
|
|
||||||
rp->options.perf_options.user_quota = turn_params.user_quota;
|
|
||||||
unlock_realms();
|
|
||||||
|
|
||||||
if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "options") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
|
if (bson_iter_init(&iter, item) && bson_iter_find(&iter,
|
||||||
const uint8_t *docbuf = NULL;
|
"origin") && BSON_ITER_HOLDS_ARRAY(&iter)) {
|
||||||
uint32_t doclen = 0;
|
const uint8_t *docbuf = NULL;
|
||||||
bson_t options;
|
uint32_t doclen = 0;
|
||||||
bson_iter_t options_iter;
|
bson_t origin_array;
|
||||||
|
bson_iter_t origin_iter;
|
||||||
|
|
||||||
bson_iter_document(&iter, &doclen, &docbuf);
|
bson_iter_array(&iter, &doclen, &docbuf);
|
||||||
bson_init_static(&options, docbuf, doclen);
|
bson_init_static(&origin_array, docbuf, doclen);
|
||||||
|
|
||||||
if (bson_iter_init(&options_iter, &options)) {
|
if (bson_iter_init(&origin_iter, &origin_array)) {
|
||||||
while(bson_iter_next(&options_iter)) {
|
while (bson_iter_next(&origin_iter)) {
|
||||||
const char * _k = bson_iter_key(&options_iter);
|
if (BSON_ITER_HOLDS_UTF8(&origin_iter)) {
|
||||||
int32_t _v = 0;
|
char* _origin = turn_strdup(bson_iter_utf8(&origin_iter, &length));
|
||||||
if (BSON_ITER_HOLDS_DOUBLE(&options_iter)) {
|
char *rval = turn_strdup(_realm);
|
||||||
_v = (int32_t)bson_iter_double(&options_iter);
|
ur_string_map_value_type value =
|
||||||
} else if (BSON_ITER_HOLDS_INT32(&options_iter)) {
|
(ur_string_map_value_type) (rval);
|
||||||
_v = bson_iter_int32(&options_iter);
|
ur_string_map_put(o_to_realm_new,
|
||||||
} else if (BSON_ITER_HOLDS_INT64(&options_iter)) {
|
(const ur_string_map_key_type) _origin,
|
||||||
_v = (int32_t)bson_iter_int64(&options_iter);
|
value);
|
||||||
}
|
turn_free(_origin,strlen(_origin)+1);
|
||||||
if (_v) {
|
}
|
||||||
if(!strcmp(_k,"max-bps"))
|
}
|
||||||
rp->options.perf_options.max_bps = (band_limit_t)_v;
|
}
|
||||||
else if(!strcmp(_k,"total-quota"))
|
}
|
||||||
rp->options.perf_options.total_quota = (vint)_v;
|
|
||||||
else if(!strcmp(_k,"user-quota"))
|
realm_params_t* rp = get_realm(_realm);
|
||||||
rp->options.perf_options.user_quota = (vint)_v;
|
lock_realms();
|
||||||
|
rp->options.perf_options.max_bps = turn_params.max_bps;
|
||||||
|
rp->options.perf_options.total_quota = turn_params.total_quota;
|
||||||
|
rp->options.perf_options.user_quota = turn_params.user_quota;
|
||||||
|
unlock_realms();
|
||||||
|
|
||||||
|
if (bson_iter_init(&iter, item) && bson_iter_find(&iter,
|
||||||
|
"options") && BSON_ITER_HOLDS_DOCUMENT(&iter)) {
|
||||||
|
const uint8_t *docbuf = NULL;
|
||||||
|
uint32_t doclen = 0;
|
||||||
|
bson_t options;
|
||||||
|
bson_iter_t options_iter;
|
||||||
|
|
||||||
|
bson_iter_document(&iter, &doclen, &docbuf);
|
||||||
|
bson_init_static(&options, docbuf, doclen);
|
||||||
|
|
||||||
|
if (bson_iter_init(&options_iter, &options)) {
|
||||||
|
while (bson_iter_next(&options_iter)) {
|
||||||
|
const char * _k = bson_iter_key(&options_iter);
|
||||||
|
int32_t _v = 0;
|
||||||
|
if (BSON_ITER_HOLDS_DOUBLE(&options_iter)) {
|
||||||
|
_v = (int32_t) bson_iter_double(&options_iter);
|
||||||
|
} else if (BSON_ITER_HOLDS_INT32(&options_iter)) {
|
||||||
|
_v = bson_iter_int32(&options_iter);
|
||||||
|
} else if (BSON_ITER_HOLDS_INT64(&options_iter)) {
|
||||||
|
_v = (int32_t) bson_iter_int64(&options_iter);
|
||||||
|
}
|
||||||
|
if (_v) {
|
||||||
|
if (!strcmp(_k, "max-bps"))
|
||||||
|
rp->options.perf_options.max_bps
|
||||||
|
= (band_limit_t) _v;
|
||||||
|
else if (!strcmp(_k, "total-quota"))
|
||||||
|
rp->options.perf_options.total_quota
|
||||||
|
= (vint) _v;
|
||||||
|
else if (!strcmp(_k, "user-quota"))
|
||||||
|
rp->options.perf_options.user_quota
|
||||||
|
= (vint) _v;
|
||||||
else {
|
else {
|
||||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Unknown realm option: %s\n", _k);
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
|
||||||
|
"Unknown realm option: %s\n", _k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(_realm);
|
turn_free(_realm,strlen(_realm)+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_o_to_realm(o_to_realm_new);
|
update_o_to_realm(o_to_realm_new);
|
||||||
mongoc_cursor_destroy(cursor);
|
mongoc_cursor_destroy(cursor);
|
||||||
}
|
}
|
||||||
mongoc_collection_destroy(collection);
|
mongoc_collection_destroy(collection);
|
||||||
bson_destroy(&query);
|
bson_destroy(&query);
|
||||||
bson_destroy(&fields);
|
bson_destroy(&fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -76,7 +76,7 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
|
|||||||
Myconninfo *co = (Myconninfo*)turn_malloc(sizeof(Myconninfo));
|
Myconninfo *co = (Myconninfo*)turn_malloc(sizeof(Myconninfo));
|
||||||
ns_bzero(co,sizeof(Myconninfo));
|
ns_bzero(co,sizeof(Myconninfo));
|
||||||
if(userdb) {
|
if(userdb) {
|
||||||
char *s0=strdup(userdb);
|
char *s0=turn_strdup(userdb);
|
||||||
char *s = s0;
|
char *s = s0;
|
||||||
|
|
||||||
while(s && *s) {
|
while(s && *s) {
|
||||||
@ -93,44 +93,44 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
|
|||||||
MyconninfoFree(co);
|
MyconninfoFree(co);
|
||||||
co = NULL;
|
co = NULL;
|
||||||
if(errmsg) {
|
if(errmsg) {
|
||||||
*errmsg = strdup(s);
|
*errmsg = turn_strdup(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*seq = 0;
|
*seq = 0;
|
||||||
if(!strcmp(s,"host"))
|
if(!strcmp(s,"host"))
|
||||||
co->host = strdup(seq+1);
|
co->host = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ip"))
|
else if(!strcmp(s,"ip"))
|
||||||
co->host = strdup(seq+1);
|
co->host = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"addr"))
|
else if(!strcmp(s,"addr"))
|
||||||
co->host = strdup(seq+1);
|
co->host = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ipaddr"))
|
else if(!strcmp(s,"ipaddr"))
|
||||||
co->host = strdup(seq+1);
|
co->host = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"hostaddr"))
|
else if(!strcmp(s,"hostaddr"))
|
||||||
co->host = strdup(seq+1);
|
co->host = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"dbname"))
|
else if(!strcmp(s,"dbname"))
|
||||||
co->dbname = strdup(seq+1);
|
co->dbname = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"db"))
|
else if(!strcmp(s,"db"))
|
||||||
co->dbname = strdup(seq+1);
|
co->dbname = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"database"))
|
else if(!strcmp(s,"database"))
|
||||||
co->dbname = strdup(seq+1);
|
co->dbname = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"user"))
|
else if(!strcmp(s,"user"))
|
||||||
co->user = strdup(seq+1);
|
co->user = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"uname"))
|
else if(!strcmp(s,"uname"))
|
||||||
co->user = strdup(seq+1);
|
co->user = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"name"))
|
else if(!strcmp(s,"name"))
|
||||||
co->user = strdup(seq+1);
|
co->user = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"username"))
|
else if(!strcmp(s,"username"))
|
||||||
co->user = strdup(seq+1);
|
co->user = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"password"))
|
else if(!strcmp(s,"password"))
|
||||||
co->password = strdup(seq+1);
|
co->password = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"pwd"))
|
else if(!strcmp(s,"pwd"))
|
||||||
co->password = strdup(seq+1);
|
co->password = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"passwd"))
|
else if(!strcmp(s,"passwd"))
|
||||||
co->password = strdup(seq+1);
|
co->password = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"secret"))
|
else if(!strcmp(s,"secret"))
|
||||||
co->password = strdup(seq+1);
|
co->password = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"port"))
|
else if(!strcmp(s,"port"))
|
||||||
co->port = (unsigned int)atoi(seq+1);
|
co->port = (unsigned int)atoi(seq+1);
|
||||||
else if(!strcmp(s,"p"))
|
else if(!strcmp(s,"p"))
|
||||||
@ -140,30 +140,30 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
|
|||||||
else if(!strcmp(s,"timeout"))
|
else if(!strcmp(s,"timeout"))
|
||||||
co->connect_timeout = (unsigned int)atoi(seq+1);
|
co->connect_timeout = (unsigned int)atoi(seq+1);
|
||||||
else if(!strcmp(s,"key"))
|
else if(!strcmp(s,"key"))
|
||||||
co->key = strdup(seq+1);
|
co->key = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ssl-key"))
|
else if(!strcmp(s,"ssl-key"))
|
||||||
co->key = strdup(seq+1);
|
co->key = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ca"))
|
else if(!strcmp(s,"ca"))
|
||||||
co->ca = strdup(seq+1);
|
co->ca = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ssl-ca"))
|
else if(!strcmp(s,"ssl-ca"))
|
||||||
co->ca = strdup(seq+1);
|
co->ca = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"capath"))
|
else if(!strcmp(s,"capath"))
|
||||||
co->capath = strdup(seq+1);
|
co->capath = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ssl-capath"))
|
else if(!strcmp(s,"ssl-capath"))
|
||||||
co->capath = strdup(seq+1);
|
co->capath = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"cert"))
|
else if(!strcmp(s,"cert"))
|
||||||
co->cert = strdup(seq+1);
|
co->cert = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ssl-cert"))
|
else if(!strcmp(s,"ssl-cert"))
|
||||||
co->cert = strdup(seq+1);
|
co->cert = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"cipher"))
|
else if(!strcmp(s,"cipher"))
|
||||||
co->cipher = strdup(seq+1);
|
co->cipher = turn_strdup(seq+1);
|
||||||
else if(!strcmp(s,"ssl-cipher"))
|
else if(!strcmp(s,"ssl-cipher"))
|
||||||
co->cipher = strdup(seq+1);
|
co->cipher = turn_strdup(seq+1);
|
||||||
else {
|
else {
|
||||||
MyconninfoFree(co);
|
MyconninfoFree(co);
|
||||||
co = NULL;
|
co = NULL;
|
||||||
if(errmsg) {
|
if(errmsg) {
|
||||||
*errmsg = strdup(s);
|
*errmsg = turn_strdup(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -176,13 +176,13 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
|
|||||||
|
|
||||||
if(co) {
|
if(co) {
|
||||||
if(!(co->dbname))
|
if(!(co->dbname))
|
||||||
co->dbname=strdup("0");
|
co->dbname=turn_strdup("0");
|
||||||
if(!(co->host))
|
if(!(co->host))
|
||||||
co->host=strdup("127.0.0.1");
|
co->host=turn_strdup("127.0.0.1");
|
||||||
if(!(co->user))
|
if(!(co->user))
|
||||||
co->user=strdup("");
|
co->user=turn_strdup("");
|
||||||
if(!(co->password))
|
if(!(co->password))
|
||||||
co->password=strdup("");
|
co->password=turn_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return co;
|
return co;
|
||||||
@ -939,7 +939,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
|
|||||||
MYSQL_RES *mres = mysql_store_result(myc);
|
MYSQL_RES *mres = mysql_store_result(myc);
|
||||||
if(mres && mysql_field_count(myc)==2) {
|
if(mres && mysql_field_count(myc)==2) {
|
||||||
|
|
||||||
ur_string_map *o_to_realm_new = ur_string_map_create(free);
|
ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
MYSQL_ROW row = mysql_fetch_row(mres);
|
MYSQL_ROW row = mysql_fetch_row(mres);
|
||||||
@ -953,7 +953,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
|
|||||||
char oval[513];
|
char oval[513];
|
||||||
ns_bcopy(row[0],oval,sz);
|
ns_bcopy(row[0],oval,sz);
|
||||||
oval[sz]=0;
|
oval[sz]=0;
|
||||||
char *rval=strdup(row[1]);
|
char *rval=turn_strdup(row[1]);
|
||||||
get_realm(rval);
|
get_realm(rval);
|
||||||
ur_string_map_value_type value = (ur_string_map_value_type)rval;
|
ur_string_map_value_type value = (ur_string_map_value_type)rval;
|
||||||
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
|
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
|
||||||
|
|||||||
@ -682,7 +682,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
|
|||||||
|
|
||||||
if(res && (PQresultStatus(res) == PGRES_TUPLES_OK)) {
|
if(res && (PQresultStatus(res) == PGRES_TUPLES_OK)) {
|
||||||
|
|
||||||
ur_string_map *o_to_realm_new = ur_string_map_create(free);
|
ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i=0;i<PQntuples(res);i++) {
|
for(i=0;i<PQntuples(res);i++) {
|
||||||
@ -691,7 +691,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
|
|||||||
char *rval = PQgetvalue(res,i,1);
|
char *rval = PQgetvalue(res,i,1);
|
||||||
if(rval) {
|
if(rval) {
|
||||||
get_realm(rval);
|
get_realm(rval);
|
||||||
ur_string_map_value_type value = strdup(rval);
|
ur_string_map_value_type value = turn_strdup(rval);
|
||||||
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
|
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
|||||||
Ryconninfo *co = (Ryconninfo*) turn_malloc(sizeof(Ryconninfo));
|
Ryconninfo *co = (Ryconninfo*) turn_malloc(sizeof(Ryconninfo));
|
||||||
ns_bzero(co,sizeof(Ryconninfo));
|
ns_bzero(co,sizeof(Ryconninfo));
|
||||||
if (userdb) {
|
if (userdb) {
|
||||||
char *s0 = strdup(userdb);
|
char *s0 = turn_strdup(userdb);
|
||||||
char *s = s0;
|
char *s = s0;
|
||||||
|
|
||||||
while (s && *s) {
|
while (s && *s) {
|
||||||
@ -87,28 +87,28 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
|||||||
RyconninfoFree(co);
|
RyconninfoFree(co);
|
||||||
co = NULL;
|
co = NULL;
|
||||||
if (errmsg) {
|
if (errmsg) {
|
||||||
*errmsg = strdup(s);
|
*errmsg = turn_strdup(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*seq = 0;
|
*seq = 0;
|
||||||
if (!strcmp(s, "host"))
|
if (!strcmp(s, "host"))
|
||||||
co->host = strdup(seq + 1);
|
co->host = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "ip"))
|
else if (!strcmp(s, "ip"))
|
||||||
co->host = strdup(seq + 1);
|
co->host = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "addr"))
|
else if (!strcmp(s, "addr"))
|
||||||
co->host = strdup(seq + 1);
|
co->host = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "ipaddr"))
|
else if (!strcmp(s, "ipaddr"))
|
||||||
co->host = strdup(seq + 1);
|
co->host = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "hostaddr"))
|
else if (!strcmp(s, "hostaddr"))
|
||||||
co->host = strdup(seq + 1);
|
co->host = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "dbname"))
|
else if (!strcmp(s, "dbname"))
|
||||||
co->dbname = strdup(seq + 1);
|
co->dbname = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "db"))
|
else if (!strcmp(s, "db"))
|
||||||
co->dbname = strdup(seq + 1);
|
co->dbname = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "database"))
|
else if (!strcmp(s, "database"))
|
||||||
co->dbname = strdup(seq + 1);
|
co->dbname = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "user"))
|
else if (!strcmp(s, "user"))
|
||||||
;
|
;
|
||||||
else if (!strcmp(s, "uname"))
|
else if (!strcmp(s, "uname"))
|
||||||
@ -118,13 +118,13 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
|||||||
else if (!strcmp(s, "username"))
|
else if (!strcmp(s, "username"))
|
||||||
;
|
;
|
||||||
else if (!strcmp(s, "password"))
|
else if (!strcmp(s, "password"))
|
||||||
co->password = strdup(seq + 1);
|
co->password = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "pwd"))
|
else if (!strcmp(s, "pwd"))
|
||||||
co->password = strdup(seq + 1);
|
co->password = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "passwd"))
|
else if (!strcmp(s, "passwd"))
|
||||||
co->password = strdup(seq + 1);
|
co->password = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "secret"))
|
else if (!strcmp(s, "secret"))
|
||||||
co->password = strdup(seq + 1);
|
co->password = turn_strdup(seq + 1);
|
||||||
else if (!strcmp(s, "port"))
|
else if (!strcmp(s, "port"))
|
||||||
co->port = (unsigned int) atoi(seq + 1);
|
co->port = (unsigned int) atoi(seq + 1);
|
||||||
else if (!strcmp(s, "p"))
|
else if (!strcmp(s, "p"))
|
||||||
@ -137,7 +137,7 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
|||||||
RyconninfoFree(co);
|
RyconninfoFree(co);
|
||||||
co = NULL;
|
co = NULL;
|
||||||
if (errmsg) {
|
if (errmsg) {
|
||||||
*errmsg = strdup(s);
|
*errmsg = turn_strdup(s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -150,11 +150,11 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
|
|||||||
|
|
||||||
if(co) {
|
if(co) {
|
||||||
if(!(co->dbname))
|
if(!(co->dbname))
|
||||||
co->dbname=strdup("0");
|
co->dbname=turn_strdup("0");
|
||||||
if(!(co->host))
|
if(!(co->host))
|
||||||
co->host=strdup("127.0.0.1");
|
co->host=turn_strdup("127.0.0.1");
|
||||||
if(!(co->password))
|
if(!(co->password))
|
||||||
co->password=strdup("");
|
co->password=turn_strdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
return co;
|
return co;
|
||||||
@ -1152,7 +1152,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
|
|||||||
redisReply *reply = (redisReply*) redisCommand(rc, "keys turn/origin/*");
|
redisReply *reply = (redisReply*) redisCommand(rc, "keys turn/origin/*");
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
|
||||||
ur_string_map *o_to_realm_new = ur_string_map_create(free);
|
ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
|
||||||
|
|
||||||
secrets_list_t keys;
|
secrets_list_t keys;
|
||||||
|
|
||||||
@ -1188,7 +1188,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
|
|||||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Unexpected type: %d\n", rget->type);
|
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Unexpected type: %d\n", rget->type);
|
||||||
} else {
|
} else {
|
||||||
get_realm(rget->str);
|
get_realm(rget->str);
|
||||||
ur_string_map_value_type value = strdup(rget->str);
|
ur_string_map_value_type value = turn_strdup(rget->str);
|
||||||
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) origin, value);
|
ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) origin, value);
|
||||||
}
|
}
|
||||||
turnFreeRedisReply(rget);
|
turnFreeRedisReply(rget);
|
||||||
|
|||||||
@ -1785,8 +1785,8 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ns_bzero(&turn_params.default_users_db,sizeof(default_users_db_t));
|
ns_bzero(&turn_params.default_users_db,sizeof(default_users_db_t));
|
||||||
turn_params.default_users_db.ram_db.static_accounts = ur_string_map_create(free);
|
turn_params.default_users_db.ram_db.static_accounts = ur_string_map_create(turn_free_simple);
|
||||||
turn_params.default_users_db.ram_db.dynamic_accounts = ur_string_map_create(free);
|
turn_params.default_users_db.ram_db.dynamic_accounts = ur_string_map_create(turn_free_simple);
|
||||||
|
|
||||||
if(strstr(argv[0],"turnadmin"))
|
if(strstr(argv[0],"turnadmin"))
|
||||||
return adminmain(argc,argv);
|
return adminmain(argc,argv);
|
||||||
|
|||||||
@ -576,7 +576,7 @@ ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_
|
|||||||
te->e = e;
|
te->e = e;
|
||||||
te->ev = ev;
|
te->ev = ev;
|
||||||
te->cb = cb;
|
te->cb = cb;
|
||||||
te->txt = strdup(txt);
|
te->txt = turn_strdup(txt);
|
||||||
|
|
||||||
if(!ms) {
|
if(!ms) {
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
@ -3620,11 +3620,11 @@ static void init_super_memory_region(super_memory_t *r)
|
|||||||
if(r) {
|
if(r) {
|
||||||
ns_bzero(r,sizeof(super_memory_t));
|
ns_bzero(r,sizeof(super_memory_t));
|
||||||
|
|
||||||
r->super_memory = (char**)malloc(sizeof(char*));
|
r->super_memory = (char**)turn_malloc(sizeof(char*));
|
||||||
r->super_memory[0] = (char*)malloc(TURN_SM_SIZE);
|
r->super_memory[0] = (char*)turn_malloc(TURN_SM_SIZE);
|
||||||
ns_bzero(r->super_memory[0],TURN_SM_SIZE);
|
ns_bzero(r->super_memory[0],TURN_SM_SIZE);
|
||||||
|
|
||||||
r->sm_allocated = (size_t*)malloc(sizeof(size_t*));
|
r->sm_allocated = (size_t*)turn_malloc(sizeof(size_t*));
|
||||||
r->sm_allocated[0] = 0;
|
r->sm_allocated[0] = 0;
|
||||||
|
|
||||||
r->sm_total_sz = TURN_SM_SIZE;
|
r->sm_total_sz = TURN_SM_SIZE;
|
||||||
@ -3644,7 +3644,7 @@ void init_super_memory(void)
|
|||||||
|
|
||||||
super_memory_t* new_super_memory_region(void)
|
super_memory_t* new_super_memory_region(void)
|
||||||
{
|
{
|
||||||
super_memory_t* r = (super_memory_t*)malloc(sizeof(super_memory_t));
|
super_memory_t* r = (super_memory_t*)turn_malloc(sizeof(super_memory_t));
|
||||||
init_super_memory_region(r);
|
init_super_memory_region(r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -3658,7 +3658,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
|||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
|
|
||||||
if(!r) {
|
if(!r) {
|
||||||
ret = malloc(size);
|
ret = turn_malloc(size);
|
||||||
ns_bzero(ret, size);
|
ns_bzero(ret, size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -3691,10 +3691,10 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
|||||||
|
|
||||||
if(!region) {
|
if(!region) {
|
||||||
r->sm_chunk += 1;
|
r->sm_chunk += 1;
|
||||||
r->super_memory = (char**)realloc(r->super_memory,(r->sm_chunk+1) * sizeof(char*));
|
r->super_memory = (char**)turn_realloc(r->super_memory,0,(r->sm_chunk+1) * sizeof(char*));
|
||||||
r->super_memory[r->sm_chunk] = (char*)malloc(TURN_SM_SIZE);
|
r->super_memory[r->sm_chunk] = (char*)turn_malloc(TURN_SM_SIZE);
|
||||||
ns_bzero(r->super_memory[r->sm_chunk],TURN_SM_SIZE);
|
ns_bzero(r->super_memory[r->sm_chunk],TURN_SM_SIZE);
|
||||||
r->sm_allocated = (size_t*)realloc(r->sm_allocated,(r->sm_chunk+1) * sizeof(size_t*));
|
r->sm_allocated = (size_t*)turn_realloc(r->sm_allocated,0,(r->sm_chunk+1) * sizeof(size_t*));
|
||||||
r->sm_allocated[r->sm_chunk] = 0;
|
r->sm_allocated[r->sm_chunk] = 0;
|
||||||
region = r->super_memory[r->sm_chunk];
|
region = r->super_memory[r->sm_chunk];
|
||||||
rsz = r->sm_allocated + r->sm_chunk;
|
rsz = r->sm_allocated + r->sm_chunk;
|
||||||
@ -3714,7 +3714,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
|
|||||||
pthread_mutex_unlock(&r->mutex_sm);
|
pthread_mutex_unlock(&r->mutex_sm);
|
||||||
|
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
ret = malloc(size);
|
ret = turn_malloc(size);
|
||||||
ns_bzero(ret, size);
|
ns_bzero(ret, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -465,7 +465,7 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
|
|||||||
csarg->user_names = (char**)turn_realloc(csarg->user_names,
|
csarg->user_names = (char**)turn_realloc(csarg->user_names,
|
||||||
(size_t)value * sizeof(char*),
|
(size_t)value * sizeof(char*),
|
||||||
csarg->users_number * sizeof(char*));
|
csarg->users_number * sizeof(char*));
|
||||||
csarg->user_names[(size_t)value] = strdup((char*)tsi->username);
|
csarg->user_names[(size_t)value] = turn_strdup((char*)tsi->username);
|
||||||
csarg->user_counters[(size_t)value] = 0;
|
csarg->user_counters[(size_t)value] = 0;
|
||||||
ur_string_map_put(csarg->users, (ur_string_map_key_type)(char*)tsi->username, value);
|
ur_string_map_put(csarg->users, (ur_string_map_key_type)(char*)tsi->username, value);
|
||||||
}
|
}
|
||||||
@ -939,7 +939,7 @@ static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int
|
|||||||
|
|
||||||
if(cs && buf0 && cs->ts && cs->bev) {
|
if(cs && buf0 && cs->ts && cs->bev) {
|
||||||
|
|
||||||
char *buf = (char*)malloc(len+1);
|
char *buf = (char*)turn_malloc(len+1);
|
||||||
ns_bcopy(buf0,buf,len);
|
ns_bcopy(buf0,buf,len);
|
||||||
buf[len]=0;
|
buf[len]=0;
|
||||||
|
|
||||||
@ -1078,7 +1078,7 @@ static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int
|
|||||||
type_cli_cursor(cs);
|
type_cli_cursor(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buf);
|
turn_free(buf,len+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -105,7 +105,7 @@ void create_default_realm()
|
|||||||
/* init everything: */
|
/* init everything: */
|
||||||
TURN_MUTEX_INIT_RECURSIVE(&o_to_realm_mutex);
|
TURN_MUTEX_INIT_RECURSIVE(&o_to_realm_mutex);
|
||||||
init_secrets_list(&realms_list);
|
init_secrets_list(&realms_list);
|
||||||
o_to_realm = ur_string_map_create(free);
|
o_to_realm = ur_string_map_create(turn_free_simple);
|
||||||
default_realm_params_ptr = &_default_realm_params;
|
default_realm_params_ptr = &_default_realm_params;
|
||||||
realms = ur_string_map_create(NULL);
|
realms = ur_string_map_create(NULL);
|
||||||
ur_string_map_lock(realms);
|
ur_string_map_lock(realms);
|
||||||
@ -169,7 +169,7 @@ int get_realm_options_by_origin(char *origin, realm_options_t* ro)
|
|||||||
ur_string_map_value_type value = 0;
|
ur_string_map_value_type value = 0;
|
||||||
TURN_MUTEX_LOCK(&o_to_realm_mutex);
|
TURN_MUTEX_LOCK(&o_to_realm_mutex);
|
||||||
if (ur_string_map_get(o_to_realm, (ur_string_map_key_type) origin, &value) && value) {
|
if (ur_string_map_get(o_to_realm, (ur_string_map_key_type) origin, &value) && value) {
|
||||||
char *realm = strdup((char*)value);
|
char *realm = turn_strdup((char*)value);
|
||||||
TURN_MUTEX_UNLOCK(&o_to_realm_mutex);
|
TURN_MUTEX_UNLOCK(&o_to_realm_mutex);
|
||||||
realm_params_t rp;
|
realm_params_t rp;
|
||||||
get_realm_data(realm, &rp);
|
get_realm_data(realm, &rp);
|
||||||
@ -292,7 +292,7 @@ void add_to_secrets_list(secrets_list_t *sl, const char* elem)
|
|||||||
{
|
{
|
||||||
if(sl && elem) {
|
if(sl && elem) {
|
||||||
sl->secrets = (char**)turn_realloc(sl->secrets,0,(sizeof(char*)*(sl->sz+1)));
|
sl->secrets = (char**)turn_realloc(sl->secrets,0,(sizeof(char*)*(sl->sz+1)));
|
||||||
sl->secrets[sl->sz] = strdup(elem);
|
sl->secrets[sl->sz] = turn_strdup(elem);
|
||||||
sl->sz += 1;
|
sl->sz += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ static char *get_real_username(char *usname)
|
|||||||
usname = col+1;
|
usname = col+1;
|
||||||
} else {
|
} else {
|
||||||
*col=0;
|
*col=0;
|
||||||
usname = strdup(usname);
|
usname = turn_strdup(usname);
|
||||||
*col=turn_params.rest_api_separator;
|
*col=turn_params.rest_api_separator;
|
||||||
return usname;
|
return usname;
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ static char *get_real_username(char *usname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return strdup(usname);
|
return turn_strdup(usname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -684,7 +684,7 @@ int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (user || oauth) {
|
if (user || oauth) {
|
||||||
u08bits *username = oauth ? (u08bits*)strdup("") : (u08bits*)get_real_username((char*)user);
|
u08bits *username = oauth ? (u08bits*)turn_strdup("") : (u08bits*)get_real_username((char*)user);
|
||||||
realm_params_t *rp = get_realm((char*)realm);
|
realm_params_t *rp = get_realm((char*)realm);
|
||||||
ur_string_map_lock(rp->status.alloc_counters);
|
ur_string_map_lock(rp->status.alloc_counters);
|
||||||
if (rp->options.perf_options.total_quota && (rp->status.total_current_allocs >= rp->options.perf_options.total_quota)) {
|
if (rp->options.perf_options.total_quota && (rp->status.total_current_allocs >= rp->options.perf_options.total_quota)) {
|
||||||
@ -716,7 +716,7 @@ int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm)
|
|||||||
void release_allocation_quota(u08bits *user, int oauth, u08bits *realm)
|
void release_allocation_quota(u08bits *user, int oauth, u08bits *realm)
|
||||||
{
|
{
|
||||||
if (user) {
|
if (user) {
|
||||||
u08bits *username = oauth ? (u08bits*)strdup("") : (u08bits*)get_real_username((char*)user);
|
u08bits *username = oauth ? (u08bits*)turn_strdup("") : (u08bits*)get_real_username((char*)user);
|
||||||
realm_params_t *rp = get_realm((char*)realm);
|
realm_params_t *rp = get_realm((char*)realm);
|
||||||
ur_string_map_lock(rp->status.alloc_counters);
|
ur_string_map_lock(rp->status.alloc_counters);
|
||||||
if(username[0]) {
|
if(username[0]) {
|
||||||
@ -1154,7 +1154,7 @@ int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08b
|
|||||||
|
|
||||||
add_and_cont:
|
add_and_cont:
|
||||||
content = (char**)turn_realloc(content, 0, sizeof(char*) * (++csz));
|
content = (char**)turn_realloc(content, 0, sizeof(char*) * (++csz));
|
||||||
content[csz - 1] = strdup(s0);
|
content[csz - 1] = turn_strdup(s0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
@ -1169,11 +1169,11 @@ int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08b
|
|||||||
snprintf(us+strlen(us),sizeof(us)-strlen(us),"%02x",(unsigned int)key[i]);
|
snprintf(us+strlen(us),sizeof(us)-strlen(us),"%02x",(unsigned int)key[i]);
|
||||||
}
|
}
|
||||||
content = (char**)turn_realloc(content,0,sizeof(char*)*(++csz));
|
content = (char**)turn_realloc(content,0,sizeof(char*)*(++csz));
|
||||||
content[csz-1]=strdup(us);
|
content[csz-1]=turn_strdup(us);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!full_path_to_userdb_file)
|
if(!full_path_to_userdb_file)
|
||||||
full_path_to_userdb_file=strdup(pud->userdb);
|
full_path_to_userdb_file=turn_strdup(pud->userdb);
|
||||||
|
|
||||||
size_t dirsz = strlen(full_path_to_userdb_file)+21;
|
size_t dirsz = strlen(full_path_to_userdb_file)+21;
|
||||||
char *dir = (char*)turn_malloc(dirsz+1);
|
char *dir = (char*)turn_malloc(dirsz+1);
|
||||||
@ -1434,7 +1434,7 @@ void update_white_and_black_lists(void)
|
|||||||
|
|
||||||
int add_ip_list_range(const char * range0, ip_range_list_t * list)
|
int add_ip_list_range(const char * range0, ip_range_list_t * list)
|
||||||
{
|
{
|
||||||
char *range = strdup(range0);
|
char *range = turn_strdup(range0);
|
||||||
|
|
||||||
char* separator = strchr(range, '-');
|
char* separator = strchr(range, '-');
|
||||||
|
|
||||||
|
|||||||
@ -313,7 +313,7 @@ int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_a
|
|||||||
port = default_port;
|
port = default_port;
|
||||||
ret = make_ioa_addr((u08bits*)sa,port,addr);
|
ret = make_ioa_addr((u08bits*)sa,port,addr);
|
||||||
}
|
}
|
||||||
turn_free(s,strlen(s)+1);
|
free(s);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,10 +493,10 @@ static size_t msz = 0;
|
|||||||
void ioa_addr_add_mapping(ioa_addr *apub, ioa_addr *apriv)
|
void ioa_addr_add_mapping(ioa_addr *apub, ioa_addr *apriv)
|
||||||
{
|
{
|
||||||
size_t new_size = msz + sizeof(ioa_addr*);
|
size_t new_size = msz + sizeof(ioa_addr*);
|
||||||
public_addrs = (ioa_addr**)turn_realloc(public_addrs, msz, new_size);
|
public_addrs = (ioa_addr**)realloc(public_addrs, new_size);
|
||||||
private_addrs = (ioa_addr**)turn_realloc(private_addrs, msz, new_size);
|
private_addrs = (ioa_addr**)realloc(private_addrs, new_size);
|
||||||
public_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
public_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
|
||||||
private_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
|
private_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
|
||||||
addr_cpy(public_addrs[mcount],apub);
|
addr_cpy(public_addrs[mcount],apub);
|
||||||
addr_cpy(private_addrs[mcount],apriv);
|
addr_cpy(private_addrs[mcount],apriv);
|
||||||
++mcount;
|
++mcount;
|
||||||
|
|||||||
@ -117,6 +117,7 @@ static inline u64bits _ioa_ntoh64(u64bits v)
|
|||||||
void *turn_malloc_func(size_t sz, const char* file, int line);
|
void *turn_malloc_func(size_t sz, const char* file, int line);
|
||||||
void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* file, int line);
|
void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* file, int line);
|
||||||
void turn_free_func(void *ptr, size_t sz, const char* file, int line);
|
void turn_free_func(void *ptr, size_t sz, const char* file, int line);
|
||||||
|
void turn_free_simple(void *ptr);
|
||||||
void *turn_calloc_func(size_t number, size_t size, const char* file, int line);
|
void *turn_calloc_func(size_t number, size_t size, const char* file, int line);
|
||||||
char *turn_strdup_func(const char* s, const char* file, int line);
|
char *turn_strdup_func(const char* s, const char* file, int line);
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ static inline u64bits _ioa_ntoh64(u64bits v)
|
|||||||
#define turn_realloc(ptr, old_sz, new_sz) realloc((ptr),(size_t)(new_sz))
|
#define turn_realloc(ptr, old_sz, new_sz) realloc((ptr),(size_t)(new_sz))
|
||||||
#define turn_calloc(number, sz) calloc((number),(size_t)(sz))
|
#define turn_calloc(number, sz) calloc((number),(size_t)(sz))
|
||||||
#define turn_strdup(s) strdup((s))
|
#define turn_strdup(s) strdup((s))
|
||||||
|
#define turn_free_simple free
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user