mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
ctdb: move ctdb_io.c to use TLIST_*() macros
This will make large packet queues much more efficient (This used to be ctdb commit e3f198056230073135ea6354bbef30c5bb022f8f)
This commit is contained in:
parent
5fd88a1c42
commit
3eb9735be5
@ -45,13 +45,7 @@ struct ctdb_queue_pkt {
|
||||
struct ctdb_queue {
|
||||
struct ctdb_context *ctdb;
|
||||
struct ctdb_partial partial; /* partial input packet */
|
||||
struct ctdb_queue_pkt *out_queue;
|
||||
/* This field is used to track the last added item so we
|
||||
can append new items to the end cheaply.
|
||||
This relies of that items are always appended to the tail
|
||||
and that when reamoving items we only remove the head.
|
||||
*/
|
||||
struct ctdb_queue_pkt *out_queue_last_added;
|
||||
struct ctdb_queue_pkt *out_queue, *out_queue_tail;
|
||||
uint32_t out_queue_length;
|
||||
struct fd_event *fde;
|
||||
int fd;
|
||||
@ -200,7 +194,8 @@ static void queue_io_write(struct ctdb_queue *queue)
|
||||
if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
if (pkt->length != pkt->full_length) {
|
||||
/* partial packet sent - we have to drop it */
|
||||
DLIST_REMOVE(queue->out_queue, pkt);
|
||||
TLIST_REMOVE(queue->out_queue, queue->out_queue_tail,
|
||||
pkt);
|
||||
queue->out_queue_length--;
|
||||
talloc_free(pkt);
|
||||
}
|
||||
@ -219,7 +214,7 @@ static void queue_io_write(struct ctdb_queue *queue)
|
||||
return;
|
||||
}
|
||||
|
||||
DLIST_REMOVE(queue->out_queue, pkt);
|
||||
TLIST_REMOVE(queue->out_queue, queue->out_queue_tail, pkt);
|
||||
queue->out_queue_length--;
|
||||
talloc_free(pkt);
|
||||
}
|
||||
@ -300,18 +295,8 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
|
||||
EVENT_FD_WRITEABLE(queue->fde);
|
||||
}
|
||||
|
||||
/* This relies on that when adding items to the queue, we always add
|
||||
them to the tail and that when removing items we only remove
|
||||
the head of queue item.
|
||||
The last_added item thus allows non n^2 behaviour when appending to
|
||||
very long queues.
|
||||
*/
|
||||
if (queue->out_queue == NULL) {
|
||||
DLIST_ADD(queue->out_queue, pkt);
|
||||
} else {
|
||||
DLIST_ADD_END(queue->out_queue_last_added, pkt, struct ctdb_queue_pkt *);
|
||||
}
|
||||
queue->out_queue_last_added = pkt;
|
||||
TLIST_ADD_END(queue->out_queue, queue->out_queue_tail, pkt);
|
||||
|
||||
queue->out_queue_length++;
|
||||
|
||||
if (queue->ctdb->tunable.verbose_memory_names != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user