Reduce usage of TURN_NO_HIREDIS macros (#1022)
`TURN_NO_HIREDIS` is defined when hiredis library is not present and any redis functionality must be disabled While all above is correct, it does not require ifdef-ing out all related code. For example, redis related fields in `turn_params` do not need to be compiled out. Same for certain function parameters. This PR reduces amount of places in code where `TURN_NO_HIREDIS` is used to make code simpler by moving as much usage of this define into dbd_redis.h/c files and compiling them unconditionally. - Always compile/link `dbd_redis.c` - Move many `TURN_NO_HIREDIS` decisions into `dbd_redis.c` - Delete empty function redis_async_init
This commit is contained in:
parent
9a9e9671f4
commit
6ff98239f4
@ -167,11 +167,6 @@ static void redisLibeventCleanup(void *privdata)
|
||||
|
||||
///////////////////////// Send-receive ///////////////////////////
|
||||
|
||||
void redis_async_init(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
int is_redis_asyncconn_good(redis_context_handle rch)
|
||||
{
|
||||
if(rch) {
|
||||
|
||||
@ -48,7 +48,6 @@ typedef void* redis_context_handle;
|
||||
|
||||
#if !defined(TURN_NO_HIREDIS)
|
||||
|
||||
void redis_async_init(void);
|
||||
|
||||
redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *pwd, int db);
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ set(HEADER_FILES
|
||||
userdb.h
|
||||
dbdrivers/dbdriver.h
|
||||
prom_server.h
|
||||
dbdrivers/dbd_redis.h
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
@ -39,6 +40,7 @@ set(SOURCE_FILES
|
||||
userdb.c
|
||||
dbdrivers/dbdriver.c
|
||||
prom_server.c
|
||||
dbdrivers/dbd_redis.c
|
||||
)
|
||||
|
||||
find_package(SQLite)
|
||||
|
||||
@ -1399,4 +1399,7 @@ const turn_dbdriver_t * get_redis_dbdriver(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
redis_context_handle get_redis_async_connection(struct event_base *base, redis_stats_db_t* connection_string, int delete_keys) {
|
||||
return NULL;
|
||||
}
|
||||
#endif /* !defined(TURN_NO_HIREDIS) */
|
||||
|
||||
@ -33,12 +33,14 @@
|
||||
#define __DBD_REDIS__
|
||||
|
||||
#include "dbdriver.h"
|
||||
#include "hiredis_libevent2.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const turn_dbdriver_t * get_redis_dbdriver(void);
|
||||
redis_context_handle get_redis_async_connection(struct event_base *base, redis_stats_db_t* connection_string, int delete_keys);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -99,11 +99,9 @@ const turn_dbdriver_t * get_dbdriver(void)
|
||||
_driver = get_mongo_dbdriver();
|
||||
break;
|
||||
#endif
|
||||
#if !defined(TURN_NO_HIREDIS)
|
||||
case TURN_USERDB_TYPE_REDIS:
|
||||
_driver = get_redis_dbdriver();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2778,10 +2778,6 @@ int main(int argc, char **argv)
|
||||
|
||||
init_super_memory();
|
||||
|
||||
#if !defined(TURN_NO_HIREDIS)
|
||||
redis_async_init();
|
||||
#endif
|
||||
|
||||
init_domain();
|
||||
create_default_realm();
|
||||
|
||||
|
||||
@ -109,9 +109,7 @@ enum _TURN_USERDB_TYPE {
|
||||
#if !defined(TURN_NO_MONGO)
|
||||
,TURN_USERDB_TYPE_MONGO
|
||||
#endif
|
||||
#if !defined(TURN_NO_HIREDIS)
|
||||
,TURN_USERDB_TYPE_REDIS
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum _TURN_USERDB_TYPE TURN_USERDB_TYPE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user