1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-01 15:17:46 +02:00

ensure messages in queue are always delivered in order

This commit is contained in:
Jfreegman 2014-12-03 22:10:21 -05:00
parent 5a175f374a
commit 5aad8764b1
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
2 changed files with 17 additions and 17 deletions

View File

@ -134,23 +134,23 @@ void cqueue_try_send(ToxWindow *self, Tox *m)
{
struct chat_queue *q = self->chatwin->cqueue;
struct cqueue_msg *msg = q->root;
if (!msg)
return;
uint64_t curtime = get_unix_time();
while (msg) {
if (msg->receipt != 0 && !timed_out(msg->last_send_try, curtime, CQUEUE_TRY_SEND_INTERVAL)) {
msg = msg->next;
continue;
}
uint32_t receipt = 0;
if (msg->type == OUT_MSG)
receipt = tox_send_message(m, self->num, (uint8_t *) msg->message, msg->len);
else
receipt = tox_send_action(m, self->num, (uint8_t *) msg->message, msg->len);
msg->last_send_try = curtime;
msg->receipt = receipt;
if (msg->receipt != 0 && !timed_out(msg->last_send_try, curtime, CQUEUE_TRY_SEND_INTERVAL))
return;
}
uint32_t receipt = 0;
if (msg->type == OUT_MSG)
receipt = tox_send_message(m, self->num, (uint8_t *) msg->message, msg->len);
else
receipt = tox_send_action(m, self->num, (uint8_t *) msg->message, msg->len);
msg->last_send_try = curtime;
msg->receipt = receipt;
return;
}

View File

@ -761,7 +761,7 @@ void *thread_cqueue(void *data)
}
pthread_mutex_unlock(&Winthread.lock);
usleep(7000);
usleep(4000);
}
}