mirror of
https://github.com/Tha14/toxic.git
synced 2025-06-28 19:56:46 +02:00
Refactor message queue
We now attempt to send all queued messages per call to cqueue_try_send() instead of just the oldest message in the queue. This speeds things up substantially. Also fixed a very unlikely bug where the read receipt might wrap around to zero which we used as a reserved value for an unsent message
This commit is contained in:
@ -27,9 +27,9 @@ struct cqueue_msg {
|
||||
char message[MAX_STR_SIZE];
|
||||
size_t len;
|
||||
int line_id;
|
||||
uint8_t type;
|
||||
uint32_t receipt;
|
||||
time_t last_send_try;
|
||||
uint8_t type;
|
||||
int64_t receipt;
|
||||
struct cqueue_msg *next;
|
||||
struct cqueue_msg *prev;
|
||||
};
|
||||
@ -42,7 +42,10 @@ struct chat_queue {
|
||||
void cqueue_cleanup(struct chat_queue *q);
|
||||
void cqueue_add(struct chat_queue *q, const char *msg, size_t len, uint8_t type, int line_id);
|
||||
|
||||
/* Tries to send the oldest unsent message in queue. */
|
||||
/*
|
||||
* Tries to send all messages in the send queue in sequential order.
|
||||
* If a message fails to send the function will immediately return.
|
||||
*/
|
||||
void cqueue_try_send(ToxWindow *self, Tox *m);
|
||||
|
||||
/* removes message with matching receipt from queue, writes to log and updates line to show the message was received. */
|
||||
|
Reference in New Issue
Block a user