Mercurial > hgrepos > FreeBSD > ports > net > turnserver
annotate files/patch-src_apps_relay_hiredis__libevent2.c @ 33:e5d83559f2b5
Recreate patches.
Major refactoring because paths have changed and the style of some source
files has changed.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 17 Mar 2025 11:17:31 +0100 |
| parents | files/patch-src_apps_common_hiredis__libevent2.c@4e4af36a675a |
| children |
| rev | line source |
|---|---|
| 33 | 1 --- src/apps/relay/hiredis_libevent2.c.orig 2024-12-11 18:13:38 UTC |
| 2 +++ src/apps/relay/hiredis_libevent2.c | |
| 3 @@ -52,6 +52,7 @@ struct redisLibeventEvents { | |
| 4 int port; | |
| 5 char *user; | |
| 6 char *pwd; | |
| 7 + char *usocket; | |
| 8 int db; | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 }; |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
10 |
| 33 | 11 @@ -213,8 +214,10 @@ void send_message_to_redis(redis_context_handle rch, c |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
12 |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
13 ///////////////////////// Attach ///////////////////////////////// |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 |
| 33 | 15 -redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *user, char *pwd, int db) { |
| 16 +redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *usocket, char *user, char *pwd, int db) { | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 |
| 33 | 18 + redisAsyncContext *ac = NULL; |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 + char sockpath[256] = "\0"; |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
20 char ip[256]; |
| 33 | 21 if (ip0 && ip0[0]) { |
| 22 STRCPY(ip, ip0); | |
| 23 @@ -227,7 +230,11 @@ redis_context_handle redisLibeventAttach(struct event_ | |
| 24 port = port0; | |
| 25 } | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 |
| 33 | 27 - redisAsyncContext *ac = redisAsyncConnect(ip, port); |
| 28 + if(usocket && usocket[0]) { | |
| 29 + ac = redisAsyncConnectUnix(sockpath); | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
30 + } else { |
| 33 | 31 + ac = redisAsyncConnect(ip, port); |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 + } |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 if (!ac) { |
| 33 | 34 fprintf(stderr, "Error: redisAsyncConnect returned NULL\n"); |
| 35 return NULL; | |
| 36 @@ -253,6 +260,9 @@ redis_context_handle redisLibeventAttach(struct event_ | |
| 37 if (pwd) { | |
| 38 e->pwd = strdup(pwd); | |
| 39 } | |
| 40 + if (usocket) { | |
| 41 + e->usocket = strdup(usocket); | |
| 42 + } | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 e->db = db; |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
44 |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 /* Register functions to start/stop listening for events */ |
| 33 | 46 @@ -270,6 +280,16 @@ redis_context_handle redisLibeventAttach(struct event_ |
| 47 e->wev = event_new(e->base, e->context->c.fd, EV_WRITE, redisLibeventWriteEvent, e); | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
48 |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
49 if (e->rev == NULL || e->wev == NULL) { |
| 33 | 50 + if (e->rev) { |
| 51 + event_free(e->rev); | |
| 52 + } | |
| 53 + if (e->wev) { | |
| 54 + event_free(e->wev); | |
| 55 + } | |
| 56 + free(e->ip); | |
| 57 + free(e->usocket); | |
| 58 + free(e->user); | |
| 59 + free(e->pwd); | |
| 60 free(e); | |
| 61 return NULL; | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
62 } |
| 33 | 63 @@ -329,7 +349,11 @@ static void redis_reconnect(struct redisLibeventEvents |
| 64 e->context = NULL; | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
65 } |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
66 |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
67 - ac = redisAsyncConnect(e->ip, e->port); |
|
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
68 + if(e->usocket) { |
| 33 | 69 + ac = redisAsyncConnectUnix(e->usocket); |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
70 + } else { |
| 33 | 71 + ac = redisAsyncConnect(e->ip, e->port); |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
72 + } |
| 33 | 73 if (!ac) { |
| 74 return; | |
|
4
9a1ee735f28f
Patch to allow redis connections by a Unix socket.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
75 } |
