Mercurial > hgrepos > FreeBSD > ports > net > turnserver
comparison files/patch-src_apps_common_hiredis__libevent2.c @ 18:4a6383e57d12
Compile with coturn 4.5.1.3 (GitHub): some security patches are already included now -- "socket" Redis option is included again
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 02 Sep 2020 22:38:36 +0200 |
| parents | 9a1ee735f28f |
| children | 735b41782ed7 |
comparison
equal
deleted
inserted
replaced
| 17:af52962aeb56 | 18:4a6383e57d12 |
|---|---|
| 1 --- src/apps/common/hiredis_libevent2.c.orig 2019-03-02 21:06:19 UTC | 1 --- src/apps/common/hiredis_libevent2.c.orig |
| 2 +++ src/apps/common/hiredis_libevent2.c | 2 +++ src/apps/common/hiredis_libevent2.c |
| 3 @@ -55,6 +55,7 @@ struct redisLibeventEvents | 3 @@ -55,6 +55,7 @@ |
| 4 char *ip; | 4 char *ip; |
| 5 int port; | 5 int port; |
| 6 char *pwd; | 6 char *pwd; |
| 7 + char *usocket; | 7 + char *usocket; |
| 8 int db; | 8 int db; |
| 9 }; | 9 }; |
| 10 | 10 |
| 11 @@ -223,12 +224,13 @@ void send_message_to_redis(redis_context_handle rch, c | 11 @@ -223,12 +224,13 @@ |
| 12 | 12 |
| 13 ///////////////////////// Attach ///////////////////////////////// | 13 ///////////////////////// Attach ///////////////////////////////// |
| 14 | 14 |
| 15 -redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db) | 15 -redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db) |
| 16 +redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, char *usocket, int db) | 16 +redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, char *usocket, int db) |
| 21 | 21 |
| 22 + char sockpath[256] = "\0"; | 22 + char sockpath[256] = "\0"; |
| 23 char ip[256]; | 23 char ip[256]; |
| 24 if(ip0 && ip0[0]) | 24 if(ip0 && ip0[0]) |
| 25 STRCPY(ip,ip0); | 25 STRCPY(ip,ip0); |
| 26 @@ -239,7 +241,14 @@ redis_context_handle redisLibeventAttach(struct event_ | 26 @@ -239,7 +241,14 @@ |
| 27 if(port0>0) | 27 if(port0>0) |
| 28 port=port0; | 28 port=port0; |
| 29 | 29 |
| 30 - ac = redisAsyncConnect(ip, port); | 30 - ac = redisAsyncConnect(ip, port); |
| 31 + if(usocket) | 31 + if(usocket) |
| 37 + ac = redisAsyncConnect(ip, port); | 37 + ac = redisAsyncConnect(ip, port); |
| 38 + } | 38 + } |
| 39 if (!ac) { | 39 if (!ac) { |
| 40 fprintf(stderr,"Error: %s:%s\n", ac->errstr, ac->c.errstr); | 40 fprintf(stderr,"Error: %s:%s\n", ac->errstr, ac->c.errstr); |
| 41 return NULL; | 41 return NULL; |
| 42 @@ -256,6 +265,11 @@ redis_context_handle redisLibeventAttach(struct event_ | 42 @@ -256,6 +265,11 @@ |
| 43 e->port = port; | 43 e->port = port; |
| 44 if(pwd) | 44 if(pwd) |
| 45 e->pwd = turn_strdup(pwd); | 45 e->pwd = strdup(pwd); |
| 46 + if (usocket) { | 46 + if(usocket) { |
| 47 + e->usocket = turn_strdup(usocket); | 47 + e->usocket = strdup(usocket); |
| 48 + } else { | 48 + } else { |
| 49 + e->usocket = NULL; | 49 + e->usocket = NULL; |
| 50 + } | 50 + } |
| 51 e->db = db; | 51 e->db = db; |
| 52 | 52 |
| 53 /* Register functions to start/stop listening for events */ | 53 /* Register functions to start/stop listening for events */ |
| 54 @@ -277,6 +291,7 @@ redis_context_handle redisLibeventAttach(struct event_ | 54 @@ -277,6 +291,12 @@ |
| 55 e); | 55 e); |
| 56 | 56 |
| 57 if (e->rev == NULL || e->wev == NULL) { | 57 if (e->rev == NULL || e->wev == NULL) { |
| 58 + /* XXX FIXME TBD: free e->ip, e->pwd, e->usocket */ | 58 + if(e->rev) |
| 59 turn_free(e, sizeof(struct redisLibeventEvents)); | 59 + event_free(e->rev); |
| 60 + if(e->wev) | |
| 61 + event_free(e->wev); | |
| 62 + free(e->ip); | |
| 63 + free(e->pwd); | |
| 64 free(e); | |
| 60 return NULL; | 65 return NULL; |
| 61 } | 66 } |
| 62 @@ -327,7 +342,11 @@ static void redis_reconnect(struct redisLibeventEvents | 67 @@ -327,7 +347,11 @@ |
| 63 e->context = NULL; | 68 e->context = NULL; |
| 64 } | 69 } |
| 65 | 70 |
| 66 - ac = redisAsyncConnect(e->ip, e->port); | 71 - ac = redisAsyncConnect(e->ip, e->port); |
| 67 + if(e->usocket) { | 72 + if(e->usocket) { |
