1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-28 10:36:38 +02:00

For JSON-RPC with UNIX Domain sockets, split on \n (newline).

This so multiple parallel requests can be handled properly.

JSON-RPC over websockets is unchanged, as every JSON-RPC
requests goes into its own websocket frame there (easy).
This commit is contained in:
Bram Matthys
2023-04-01 12:24:47 +02:00
parent 89f75bd6e7
commit 275cb97cfc
2 changed files with 19 additions and 4 deletions
+6
View File
@@ -51,6 +51,12 @@ in progress and not a stable version.
* The [blacklist-module](https://www.unrealircd.org/docs/Blacklist-module_directive)
directive now accepts wildcards, eg `blacklist-module rpc/*;`
### Developers and protocol:
* JSON-RPC supports
[UNIX domain sockets](https://www.unrealircd.org/docs/JSON-RPC:Technical_documentation#UNIX_domain_socket)
for making RPC calls. If those are used, we now split on `\n` (newline)
so multiple parallel requests can be handled properly.
UnrealIRCd 6.0.7
-----------------
+13 -4
View File
@@ -498,13 +498,22 @@ int rpc_packet_in_websocket(Client *client, char *readbuf, int length)
int rpc_packet_in_unix_socket(Client *client, const char *readbuf, int *length)
{
char buf[READBUFSIZE];
if (!RPC_PORT(client) || !(client->local->listener->socket_type == SOCKET_TYPE_UNIX) || (*length <= 0))
return 1; /* Not for us */
// FIXME: this assumes a single request in 'readbuf' while in fact:
// - it could only contain partial JSON, eg no ending } yet
// - there could be multiple requests
rpc_call_text(client, readbuf, *length);
dbuf_put(&client->local->recvQ, readbuf, *length);
while (DBufLength(&client->local->recvQ))
{
int len = dbuf_getmsg(&client->local->recvQ, buf);
if (len <= 0)
break;
rpc_call_text(client, buf, len);
if (IsDead(client))
break;
}
return 0;
}