Change the various map functions to return bool instead of inconsistantly return 0, 1, or -1 (#1502)
This commit is contained in:
parent
6fc5cf31e9
commit
f3b73f60d0
@ -784,8 +784,7 @@ static void pgsql_reread_realms(secrets_list_t *realms_list) {
|
||||
if (rval) {
|
||||
get_realm(rval);
|
||||
ur_string_map_value_type value = strdup(rval);
|
||||
int ret = ur_string_map_put(o_to_realm_new, (ur_string_map_key_type)oval, value);
|
||||
if (ret == -1) {
|
||||
if (!ur_string_map_put(o_to_realm_new, (ur_string_map_key_type)oval, value)) {
|
||||
free(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1123,7 +1123,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e, ioa_socket_handle client_s, in
|
||||
set_accept_cb(*rtp_s, acb, acbarg);
|
||||
|
||||
if (rtcp_s && *rtcp_s && out_reservation_token && *out_reservation_token) {
|
||||
if (rtcp_map_put(e->map_rtcp, *out_reservation_token, *rtcp_s) < 0) {
|
||||
if (!rtcp_map_put(e->map_rtcp, *out_reservation_token, *rtcp_s)) {
|
||||
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: cannot update RTCP map\n", __FUNCTION__);
|
||||
IOA_CLOSE_SOCKET(*rtp_s);
|
||||
if (rtcp_s) {
|
||||
|
||||
@ -420,18 +420,18 @@ struct ps_arg {
|
||||
size_t users_number;
|
||||
};
|
||||
|
||||
static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
static bool print_session(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
if (key && value && arg) {
|
||||
struct ps_arg *csarg = (struct ps_arg *)arg;
|
||||
struct cli_session *cs = csarg->cs;
|
||||
struct turn_session_info *tsi = (struct turn_session_info *)value;
|
||||
|
||||
if (cs->realm[0] && strcmp(cs->realm, tsi->realm)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cs->origin[0] && strcmp(cs->origin, tsi->origin)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (csarg->users) {
|
||||
@ -440,22 +440,22 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
|
||||
if (pn[0]) {
|
||||
if (!strcmp(pn, "TLS") || !strcmp(pn, "tls") || !strcmp(pn, "Tls")) {
|
||||
if ((tsi->client_protocol != TLS_SOCKET) && (tsi->client_protocol != TLS_SCTP_SOCKET)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "DTLS") || !strcmp(pn, "dtls") || !strcmp(pn, "Dtls")) {
|
||||
if (tsi->client_protocol != DTLS_SOCKET) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "TCP") || !strcmp(pn, "tcp") || !strcmp(pn, "Tcp")) {
|
||||
if ((tsi->client_protocol != TCP_SOCKET) && (tsi->client_protocol != SCTP_SOCKET)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "UDP") || !strcmp(pn, "udp") || !strcmp(pn, "Udp")) {
|
||||
if (tsi->client_protocol != UDP_SOCKET) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,11 +474,11 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
|
||||
if (csarg->username[0]) {
|
||||
if (csarg->exact_match) {
|
||||
if (strcmp((char *)tsi->username, csarg->username)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!strstr((char *)tsi->username, csarg->username)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -563,7 +563,7 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
|
||||
|
||||
csarg->counter += 1;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void cancel_session(struct cli_session *cs, const char *ssid) {
|
||||
@ -2264,24 +2264,24 @@ struct https_ps_arg {
|
||||
turnsession_id cs;
|
||||
};
|
||||
|
||||
static int https_print_session(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
static bool https_print_session(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
if (key && value && arg) {
|
||||
struct https_ps_arg *csarg = (struct https_ps_arg *)arg;
|
||||
struct str_buffer *sb = csarg->sb;
|
||||
struct turn_session_info *tsi = (struct turn_session_info *)value;
|
||||
|
||||
if (current_eff_realm()[0] && strcmp(current_eff_realm(), tsi->realm)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (csarg->user_pattern[0]) {
|
||||
if (!strstr((char *)tsi->username, csarg->user_pattern)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (csarg->cs == tsi->id) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
@ -2289,22 +2289,22 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
|
||||
if (pn[0]) {
|
||||
if (!strcmp(pn, "TLS") || !strcmp(pn, "tls") || !strcmp(pn, "Tls")) {
|
||||
if ((tsi->client_protocol != TLS_SOCKET) && (tsi->client_protocol != TLS_SCTP_SOCKET)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "DTLS") || !strcmp(pn, "dtls") || !strcmp(pn, "Dtls")) {
|
||||
if (tsi->client_protocol != DTLS_SOCKET) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "TCP") || !strcmp(pn, "tcp") || !strcmp(pn, "Tcp")) {
|
||||
if ((tsi->client_protocol != TCP_SOCKET) && (tsi->client_protocol != SCTP_SOCKET)) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if (!strcmp(pn, "UDP") || !strcmp(pn, "udp") || !strcmp(pn, "Udp")) {
|
||||
if (tsi->client_protocol != UDP_SOCKET) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2417,7 +2417,7 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
|
||||
|
||||
csarg->counter += 1;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static size_t https_print_sessions(struct str_buffer *sb, const char *client_protocol, const char *user_pattern,
|
||||
|
||||
@ -170,7 +170,7 @@ turn_permission_info *allocation_get_permission(allocation *a, const ioa_addr *a
|
||||
|
||||
///////////////////////////// TURN_PERMISSION /////////////////////////////////
|
||||
|
||||
static int delete_channel_info_from_allocation_map(ur_map_key_type key, ur_map_value_type value);
|
||||
static bool delete_channel_info_from_allocation_map(ur_map_key_type key, ur_map_value_type value);
|
||||
|
||||
void turn_permission_clean(turn_permission_info *tinfo) {
|
||||
if (tinfo && tinfo->allocated) {
|
||||
@ -279,7 +279,7 @@ static void ch_info_clean(ch_info *c) {
|
||||
}
|
||||
}
|
||||
|
||||
static int delete_channel_info_from_allocation_map(ur_map_key_type key, ur_map_value_type value) {
|
||||
static bool delete_channel_info_from_allocation_map(ur_map_key_type key, ur_map_value_type value) {
|
||||
UNUSED_ARG(key);
|
||||
|
||||
if (value) {
|
||||
@ -292,7 +292,7 @@ static int delete_channel_info_from_allocation_map(ur_map_key_type key, ur_map_v
|
||||
ch_info_clean(chn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void turn_channel_delete(ch_info *chn) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,8 @@
|
||||
|
||||
#include "ns_turn_ioaddr.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -49,8 +51,8 @@ typedef uintptr_t ur_map_value_type;
|
||||
|
||||
typedef void (*ur_map_del_func)(ur_map_value_type);
|
||||
|
||||
typedef int (*foreachcb_type)(ur_map_key_type key, ur_map_value_type value);
|
||||
typedef int (*foreachcb_arg_type)(ur_map_key_type key, ur_map_value_type value, void *arg);
|
||||
typedef bool (*foreachcb_type)(ur_map_key_type key, ur_map_value_type value);
|
||||
typedef bool (*foreachcb_arg_type)(ur_map_key_type key, ur_map_value_type value, void *arg);
|
||||
|
||||
///////////// non-local map /////////////////////
|
||||
|
||||
@ -58,44 +60,63 @@ ur_map *ur_map_create(void);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* fakse - error
|
||||
*/
|
||||
|
||||
int ur_map_put(ur_map *map, ur_map_key_type key, ur_map_value_type value);
|
||||
bool ur_map_put(ur_map *map, ur_map_key_type key, ur_map_value_type value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
bool ur_map_get(const ur_map *map, ur_map_key_type key, ur_map_value_type *value);
|
||||
|
||||
int ur_map_get(const ur_map *map, ur_map_key_type key, ur_map_value_type *value);
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
bool ur_map_del(ur_map *map, ur_map_key_type key, ur_map_del_func delfunc);
|
||||
|
||||
int ur_map_del(ur_map *map, ur_map_key_type key, ur_map_del_func delfunc);
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
|
||||
int ur_map_exist(const ur_map *map, ur_map_key_type key);
|
||||
bool ur_map_exist(const ur_map *map, ur_map_key_type key);
|
||||
|
||||
void ur_map_free(ur_map **map);
|
||||
|
||||
size_t ur_map_size(const ur_map *map);
|
||||
|
||||
int ur_map_foreach(ur_map *map, foreachcb_type func);
|
||||
/**
|
||||
* @ret:
|
||||
* true - func is called and returns true
|
||||
* false - func is not called, or is called and returns false
|
||||
*/
|
||||
bool ur_map_foreach(ur_map *map, foreachcb_type func);
|
||||
|
||||
int ur_map_foreach_arg(const ur_map *map, foreachcb_arg_type func, void *arg);
|
||||
/**
|
||||
* @ret:
|
||||
* true - func is called and returns true
|
||||
* false - func is not called, or is called and returns false
|
||||
*/
|
||||
bool ur_map_foreach_arg(const ur_map *map, foreachcb_arg_type func, void *arg);
|
||||
|
||||
int ur_map_lock(const ur_map *map);
|
||||
int ur_map_unlock(const ur_map *map);
|
||||
/**
|
||||
* @ret:
|
||||
* true - success
|
||||
* false - failure
|
||||
*/
|
||||
bool ur_map_lock(const ur_map *map);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* true - success
|
||||
* false - failure
|
||||
*/
|
||||
bool ur_map_unlock(const ur_map *map);
|
||||
|
||||
///////////// "local" map /////////////////////
|
||||
|
||||
@ -118,41 +139,49 @@ void lm_map_init(lm_map *map);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* false - error
|
||||
*/
|
||||
|
||||
int lm_map_put(lm_map *map, ur_map_key_type key, ur_map_value_type value);
|
||||
bool lm_map_put(lm_map *map, ur_map_key_type key, ur_map_value_type value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
bool lm_map_get(const lm_map *map, ur_map_key_type key, ur_map_value_type *value);
|
||||
|
||||
int lm_map_get(const lm_map *map, ur_map_key_type key, ur_map_value_type *value);
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
bool lm_map_del(lm_map *map, ur_map_key_type key, ur_map_del_func delfunc);
|
||||
|
||||
int lm_map_del(lm_map *map, ur_map_key_type key, ur_map_del_func delfunc);
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
|
||||
int lm_map_exist(const lm_map *map, ur_map_key_type key);
|
||||
bool lm_map_exist(const lm_map *map, ur_map_key_type key);
|
||||
|
||||
void lm_map_clean(lm_map *map);
|
||||
|
||||
size_t lm_map_size(const lm_map *map);
|
||||
|
||||
int lm_map_foreach(lm_map *map, foreachcb_type func);
|
||||
/**
|
||||
* @ret:
|
||||
* true - func is called and returns true
|
||||
* false - func is not called, or is called and returns false
|
||||
*/
|
||||
bool lm_map_foreach(lm_map *map, foreachcb_type func);
|
||||
|
||||
int lm_map_foreach_arg(lm_map *map, foreachcb_arg_type func, void *arg);
|
||||
/**
|
||||
* @ret:
|
||||
* true - func is called and returns true
|
||||
* false - func is not called, or is called and returns false
|
||||
*/
|
||||
bool lm_map_foreach_arg(lm_map *map, foreachcb_arg_type func, void *arg);
|
||||
|
||||
//////////////// UR ADDR MAP //////////////////
|
||||
|
||||
@ -187,31 +216,26 @@ void ur_addr_map_clean(ur_addr_map *map);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* false - error
|
||||
* if the addr key exists, the value is updated.
|
||||
*/
|
||||
int ur_addr_map_put(ur_addr_map *map, ioa_addr *key, ur_addr_map_value_type value);
|
||||
bool ur_addr_map_put(ur_addr_map *map, ioa_addr *key, ur_addr_map_value_type value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
int ur_addr_map_get(const ur_addr_map *map, ioa_addr *key, ur_addr_map_value_type *value);
|
||||
bool ur_addr_map_get(const ur_addr_map *map, ioa_addr *key, ur_addr_map_value_type *value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
int ur_addr_map_del(ur_addr_map *map, ioa_addr *key, ur_addr_map_func func);
|
||||
bool ur_addr_map_del(ur_addr_map *map, ioa_addr *key, ur_addr_map_func func);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
*/
|
||||
void ur_addr_map_foreach(ur_addr_map *map, ur_addr_map_func func);
|
||||
|
||||
size_t ur_addr_map_num_elements(const ur_addr_map *map);
|
||||
@ -230,33 +254,44 @@ ur_string_map *ur_string_map_create(ur_string_map_func del_value_func);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* false - error
|
||||
* if the string key exists, and the value is different, return error.
|
||||
*/
|
||||
int ur_string_map_put(ur_string_map *map, const ur_string_map_key_type key, ur_string_map_value_type value);
|
||||
bool ur_string_map_put(ur_string_map *map, const ur_string_map_key_type key, ur_string_map_value_type value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
int ur_string_map_get(ur_string_map *map, const ur_string_map_key_type key, ur_string_map_value_type *value);
|
||||
bool ur_string_map_get(ur_string_map *map, const ur_string_map_key_type key, ur_string_map_value_type *value);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
int ur_string_map_del(ur_string_map *map, const ur_string_map_key_type key);
|
||||
bool ur_string_map_del(ur_string_map *map, const ur_string_map_key_type key);
|
||||
|
||||
void ur_string_map_clean(ur_string_map *map);
|
||||
void ur_string_map_free(ur_string_map **map);
|
||||
|
||||
size_t ur_string_map_size(const ur_string_map *map);
|
||||
|
||||
int ur_string_map_lock(const ur_string_map *map);
|
||||
int ur_string_map_unlock(const ur_string_map *map);
|
||||
/**
|
||||
* @ret:
|
||||
* true - success
|
||||
* false - failure
|
||||
*/
|
||||
bool ur_string_map_lock(const ur_string_map *map);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* true - success
|
||||
* false - failure
|
||||
*/
|
||||
bool ur_string_map_unlock(const ur_string_map *map);
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ typedef struct {
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
||||
static int rtcp_map_valid(const rtcp_map *map) { return (map && (map->magic == MAGIC_RTCP_MAP) && map->map); }
|
||||
static bool rtcp_map_valid(const rtcp_map *map) { return (map && (map->magic == MAGIC_RTCP_MAP) && map->map); }
|
||||
|
||||
typedef struct {
|
||||
rtcp_token_type tokens[MAX_TOKEN_DEL];
|
||||
@ -63,7 +63,7 @@ typedef struct {
|
||||
turn_time_t t;
|
||||
} timeout_check_arg_type;
|
||||
|
||||
static int timeout_check(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
static bool timeout_check(ur_map_key_type key, ur_map_value_type value, void *arg) {
|
||||
|
||||
if (value && arg) {
|
||||
|
||||
@ -76,7 +76,7 @@ static int timeout_check(ur_map_key_type key, ur_map_value_type value, void *arg
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void rtcp_alloc_free(ur_map_value_type value) {
|
||||
@ -94,37 +94,35 @@ static void rtcp_alloc_free_savefd(ur_map_value_type value) {
|
||||
}
|
||||
}
|
||||
|
||||
static int foreachcb_free(ur_map_key_type key, ur_map_value_type value) {
|
||||
static bool foreachcb_free(ur_map_key_type key, ur_map_value_type value) {
|
||||
UNUSED_ARG(key);
|
||||
if (value) {
|
||||
rtcp_alloc_free(value);
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
* true - success
|
||||
* false - not found
|
||||
*/
|
||||
static int rtcp_map_del(rtcp_map *map, rtcp_token_type token) {
|
||||
static bool rtcp_map_del(rtcp_map *map, rtcp_token_type token) {
|
||||
if (!rtcp_map_valid(map)) {
|
||||
return 0;
|
||||
} else {
|
||||
TURN_MUTEX_LOCK(&map->mutex);
|
||||
int ret = ur_map_del(map->map, token, rtcp_alloc_free);
|
||||
TURN_MUTEX_UNLOCK(&map->mutex);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
TURN_MUTEX_LOCK(&map->mutex);
|
||||
bool ret = ur_map_del(map->map, token, rtcp_alloc_free);
|
||||
TURN_MUTEX_UNLOCK(&map->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rtcp_map_del_savefd(rtcp_map *map, rtcp_token_type token) {
|
||||
static bool rtcp_map_del_savefd(rtcp_map *map, rtcp_token_type token) {
|
||||
if (!rtcp_map_valid(map)) {
|
||||
return 0;
|
||||
} else {
|
||||
int ret = ur_map_del(map->map, token, rtcp_alloc_free_savefd);
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
return ur_map_del(map->map, token, rtcp_alloc_free_savefd);
|
||||
}
|
||||
|
||||
static void rtcp_map_timeout_handler(ioa_engine_handle e, void *arg) {
|
||||
@ -149,14 +147,13 @@ static void rtcp_map_timeout_handler(ioa_engine_handle e, void *arg) {
|
||||
|
||||
TURN_MUTEX_UNLOCK(&map->mutex);
|
||||
|
||||
int i = 0;
|
||||
for (i = 0; i < tcat.tn; i++) {
|
||||
for (size_t i = 0; i < tcat.tn; i++) {
|
||||
rtcp_map_del(map, tcat.tokens[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int rtcp_map_init(rtcp_map *map, ioa_engine_handle e) {
|
||||
static bool rtcp_map_init(rtcp_map *map, ioa_engine_handle e) {
|
||||
if (map) {
|
||||
if (map->magic != MAGIC_RTCP_MAP) {
|
||||
map->magic = MAGIC_RTCP_MAP;
|
||||
@ -166,11 +163,11 @@ static int rtcp_map_init(rtcp_map *map, ioa_engine_handle e) {
|
||||
}
|
||||
TURN_MUTEX_INIT(&map->mutex);
|
||||
if (rtcp_map_valid(map)) {
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
rtcp_map *rtcp_map_create(ioa_engine_handle e) {
|
||||
@ -184,26 +181,26 @@ rtcp_map *rtcp_map_create(ioa_engine_handle e) {
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* false - error
|
||||
*/
|
||||
int rtcp_map_put(rtcp_map *map, rtcp_token_type token, ioa_socket_handle s) {
|
||||
bool rtcp_map_put(rtcp_map *map, rtcp_token_type token, ioa_socket_handle s) {
|
||||
if (!rtcp_map_valid(map)) {
|
||||
return -1;
|
||||
return false;
|
||||
} else {
|
||||
rtcp_alloc_type *value = (rtcp_alloc_type *)calloc(sizeof(rtcp_alloc_type), 1);
|
||||
if (!value) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
value->s = s;
|
||||
value->t = turn_time() + RTCP_TIMEOUT;
|
||||
value->token = token;
|
||||
TURN_MUTEX_LOCK(&map->mutex);
|
||||
int ret = ur_map_put(map->map, token, (ur_map_value_type)value);
|
||||
bool ret = ur_map_put(map->map, token, (ur_map_value_type)value);
|
||||
// TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"%s: 111.111: ret=%d, token=%llu\n",__FUNCTION__,ret,token);
|
||||
TURN_MUTEX_UNLOCK(&map->mutex);
|
||||
if (ret < 0) {
|
||||
if (!ret) {
|
||||
free(value);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@ -51,10 +51,10 @@ rtcp_map *rtcp_map_create(ioa_engine_handle e);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 0 - success
|
||||
* -1 - error
|
||||
* true - success
|
||||
* false - error
|
||||
*/
|
||||
int rtcp_map_put(rtcp_map *map, rtcp_token_type key, ioa_socket_handle s);
|
||||
bool rtcp_map_put(rtcp_map *map, rtcp_token_type key, ioa_socket_handle s);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
@ -63,11 +63,6 @@ int rtcp_map_put(rtcp_map *map, rtcp_token_type key, ioa_socket_handle s);
|
||||
*/
|
||||
ioa_socket_handle rtcp_map_get(rtcp_map *map, rtcp_token_type token);
|
||||
|
||||
/**
|
||||
* @ret:
|
||||
* 1 - success
|
||||
* 0 - not found
|
||||
*/
|
||||
void rtcp_map_free(rtcp_map **map);
|
||||
|
||||
size_t rtcp_map_size(const rtcp_map *map);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user