1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00

Optimize multiline delivery to channels (use LineCache)

This wasn't done before, because optimizing stuff can always introduce
nice new issues. But is kinda necessary now since the previous way was
very inefficient. This now builds all the necessary buffers for multiline
clients and for non-multiline clients. And then iterates through both
types of clients, sending what they need. Instead of doing it the other
way around.

I had the dillema to either expose the linecache API and have everything
in multiline.c. Or, i do not expose linecache, and we do everything in
send.c. The downside of the latter is that if there is mistake then we
can't simply reload (or unload) the module to solve it. So, I have chosen
to expose the linecache API (sure, less clean) since that leaves us with
options if we screw up, plus it means everything related to multiline
sending is nicely in multiline.c, which is i guess just as good as an
argument as well ;)
This commit is contained in:
Bram Matthys
2026-04-03 08:50:58 +02:00
parent 36baf946a3
commit fa2f78fe94
4 changed files with 182 additions and 35 deletions
+5
View File
@@ -285,6 +285,11 @@ extern int send_queued(Client *);
extern void send_queued_cb(int fd, int revents, void *data);
extern void sendto_serv_butone_nickcmd(Client *one, MessageTag *mtags, Client *client, const char *umodes);
extern void sendto_message_one(Client *to, Client *from, const char *sender, const char *cmd, const char *nick, const char *msg);
extern LineCache *linecache_init(void);
extern void linecache_free(LineCache *cache);
extern void sendto_prefix_one_cached(LineCache *cache, int line_opts, Client *to, Client *from,
MessageTag *mtags,
FORMAT_STRING(const char *pattern), ...) __attribute__((format(printf,6,7)));
extern void sendto_channel(Channel *channel, Client *from, Client *skip,
char *member_modes, long clicap, int sendflags,
MessageTag *mtags,
+19
View File
@@ -147,6 +147,10 @@ typedef struct LocalMember LocalMember;
typedef struct OutgoingWebRequest OutgoingWebRequest;
typedef struct OutgoingWebResponse OutgoingWebResponse;
typedef enum LineCacheUserType { LCUT_NORMAL=0, LCUT_OPER=1, LCUT_REMOTE=2 } LineCacheUserType;
typedef struct LineCacheLine LineCacheLine;
typedef struct LineCache LineCache;
typedef enum OperClassEntryType { OPERCLASSENTRY_ALLOW=1, OPERCLASSENTRY_DENY=2} OperClassEntryType;
typedef enum OperPermission { OPER_ALLOW=1, OPER_DENY=0} OperPermission;
@@ -1609,6 +1613,21 @@ struct MessageTag {
char *value;
};
struct LineCacheLine
{
LineCacheLine *prev, *next;
LineCacheUserType user_type;
unsigned long caps;
int line_opts;
char *line;
int linelen;
};
struct LineCache
{
LineCacheLine *items;
};
/* conf preprocessor */
typedef enum PreprocessorItem {
PREPROCESSOR_ERROR = 0,