Mercurial > hgrepos > FreeBSD > ports > net > turnserver
diff files/patch-src_apps_common_hiredis__libevent2.c @ 4:9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Also document the new "socket" keyword for redis connections
in the example configuration file.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 27 Mar 2020 15:07:57 +0100 |
| parents | |
| children | 4a6383e57d12 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/files/patch-src_apps_common_hiredis__libevent2.c Fri Mar 27 15:07:57 2020 +0100 @@ -0,0 +1,74 @@ +--- src/apps/common/hiredis_libevent2.c.orig 2019-03-02 21:06:19 UTC ++++ src/apps/common/hiredis_libevent2.c +@@ -55,6 +55,7 @@ struct redisLibeventEvents + char *ip; + int port; + char *pwd; ++ char *usocket; + int db; + }; + +@@ -223,12 +224,13 @@ void send_message_to_redis(redis_context_handle rch, c + + ///////////////////////// Attach ///////////////////////////////// + +-redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db) ++redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, char *usocket, int db) + { + + struct redisLibeventEvents *e = NULL; + redisAsyncContext *ac = NULL; + ++ char sockpath[256] = "\0"; + char ip[256]; + if(ip0 && ip0[0]) + STRCPY(ip,ip0); +@@ -239,7 +241,14 @@ redis_context_handle redisLibeventAttach(struct event_ + if(port0>0) + port=port0; + +- ac = redisAsyncConnect(ip, port); ++ if(usocket) ++ STRCPY(sockpath, usocket); ++ ++ if(usocket) { ++ ac = redisAsyncConnectUnix(sockpath); ++ } else { ++ ac = redisAsyncConnect(ip, port); ++ } + if (!ac) { + fprintf(stderr,"Error: %s:%s\n", ac->errstr, ac->c.errstr); + return NULL; +@@ -256,6 +265,11 @@ redis_context_handle redisLibeventAttach(struct event_ + e->port = port; + if(pwd) + e->pwd = turn_strdup(pwd); ++ if (usocket) { ++ e->usocket = turn_strdup(usocket); ++ } else { ++ e->usocket = NULL; ++ } + e->db = db; + + /* Register functions to start/stop listening for events */ +@@ -277,6 +291,7 @@ redis_context_handle redisLibeventAttach(struct event_ + e); + + if (e->rev == NULL || e->wev == NULL) { ++ /* XXX FIXME TBD: free e->ip, e->pwd, e->usocket */ + turn_free(e, sizeof(struct redisLibeventEvents)); + return NULL; + } +@@ -327,7 +342,11 @@ static void redis_reconnect(struct redisLibeventEvents + e->context = NULL; + } + +- ac = redisAsyncConnect(e->ip, e->port); ++ if(e->usocket) { ++ ac = redisAsyncConnectUnix(e->usocket); ++ } else { ++ ac = redisAsyncConnect(e->ip, e->port); ++ } + if(!ac) { + return; + }
