@ -422,7 +422,7 @@ static med_entry_t *medredis_reply_to_entry(redisReply *reply, const char* cid,
/**********************************************************************/
/**********************************************************************/
int medredis_init ( ) {
static int medredis_init _one ( void ) {
struct timeval tv ;
struct timeval tv ;
redisReply * reply ;
redisReply * reply ;
@ -472,7 +472,7 @@ int medredis_init() {
medredis_free_reply ( & reply ) ;
medredis_free_reply ( & reply ) ;
reply = redisCommand ( con - > ctx , " SCRIPT LOAD %s " , SREM_KEY_LUA ) ;
reply = redisCommand ( con - > ctx , " SCRIPT LOAD %s " , SREM_KEY_LUA ) ;
medredis_check_reply ( " S ELE CT" , reply , err ) ;
medredis_check_reply ( " S CRIP T LOAD " , reply , err ) ;
if ( reply - > type ! = REDIS_REPLY_STRING | | reply - > len > = sizeof ( medredis_srem_key_lua ) ) {
if ( reply - > type ! = REDIS_REPLY_STRING | | reply - > len > = sizeof ( medredis_srem_key_lua ) ) {
L_ERROR ( " Invalid reply from SCRIPT LOAD: %i/%lu \n " , reply - > type , ( unsigned long ) reply - > len ) ;
L_ERROR ( " Invalid reply from SCRIPT LOAD: %i/%lu \n " , reply - > type , ( unsigned long ) reply - > len ) ;
goto err ;
goto err ;
@ -497,6 +497,18 @@ err:
}
}
return - 1 ;
return - 1 ;
}
}
int medredis_init ( ) {
int i = 0 ;
static const int max_retries = 10 ;
while ( 1 ) {
if ( medredis_init_one ( ) = = 0 )
return 0 ;
if ( i + + > = max_retries )
return - 1 ;
L_ERROR ( " Redis connection init failed, retry attempt #%i/%i \n " , i , max_retries ) ;
usleep ( 200000 ) ;
}
}
/**********************************************************************/
/**********************************************************************/