[SCM] CTDB repository - branch master updated - 1.0.99-24-g331c6e3
Ronnie Sahlberg
sahlberg at samba.org
Sun Oct 25 19:16:30 MDT 2009
The branch, master has been updated
via 331c6e3afd96d8b5e191153a631efdbdabb6ea33 (commit)
from e79c3bcead7bd4bfb74d0aec81908da71551c107 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 331c6e3afd96d8b5e191153a631efdbdabb6ea33
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Mon Oct 26 12:20:52 2009 +1100
Suggestion from Volker,
make ctdb_queue_length() cheaper by using a counter variable instead of counting the number of packets each time.
-----------------------------------------------------------------------
Summary of changes:
common/ctdb_io.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/common/ctdb_io.c b/common/ctdb_io.c
index ea7c17d..99180ce 100644
--- a/common/ctdb_io.c
+++ b/common/ctdb_io.c
@@ -46,6 +46,7 @@ struct ctdb_queue {
struct ctdb_context *ctdb;
struct ctdb_partial partial; /* partial input packet */
struct ctdb_queue_pkt *out_queue;
+ uint32_t out_queue_length;
struct fd_event *fde;
int fd;
size_t alignment;
@@ -57,12 +58,7 @@ struct ctdb_queue {
int ctdb_queue_length(struct ctdb_queue *queue)
{
- int i;
- struct ctdb_queue_pkt *pkt;
-
- for(i=0, pkt=queue->out_queue;pkt;i++,pkt=pkt->next);
-
- return i;
+ return queue->out_queue_length;
}
/*
@@ -188,6 +184,7 @@ static void queue_io_write(struct ctdb_queue *queue)
if (pkt->length != pkt->full_length) {
/* partial packet sent - we have to drop it */
DLIST_REMOVE(queue->out_queue, pkt);
+ queue->out_queue_length--;
talloc_free(pkt);
}
talloc_free(queue->fde);
@@ -206,6 +203,7 @@ static void queue_io_write(struct ctdb_queue *queue)
}
DLIST_REMOVE(queue->out_queue, pkt);
+ queue->out_queue_length--;
talloc_free(pkt);
}
@@ -286,6 +284,7 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
}
DLIST_ADD_END(queue->out_queue, pkt, struct ctdb_queue_pkt *);
+ queue->out_queue_length++;
if (queue->ctdb->tunable.verbose_memory_names != 0) {
struct ctdb_req_header *hdr = (struct ctdb_req_header *)pkt->data;
--
CTDB repository
More information about the samba-cvs
mailing list