Rev 241: don't zero beyond packet header unnecessarily in
http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Thu May 3 03:44:28 GMT 2007
------------------------------------------------------------
revno: 241
revision-id: tridge at samba.org-20070503034427-cafju1wds7214w62
parent: tridge at samba.org-20070503021603-p9q4auw135pzf905
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Thu 2007-05-03 13:44:27 +1000
message:
don't zero beyond packet header unnecessarily
modified:
common/ctdb_daemon.c ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1
=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c 2007-05-02 19:51:46 +0000
+++ b/common/ctdb_daemon.c 2007-05-03 03:44:27 +0000
@@ -727,7 +727,9 @@
{
int size;
struct ctdb_req_header *hdr;
- size = ((length+1)+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
+
+ length = MAX(length, slength);
+ size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
hdr = (struct ctdb_req_header *)talloc_size(mem_ctx, size);
if (hdr == NULL) {
@@ -736,9 +738,9 @@
return NULL;
}
talloc_set_name_const(hdr, type);
- memset(hdr, 0, size);
+ memset(hdr, 0, slength);
+ hdr->length = length;
hdr->operation = operation;
- hdr->length = size;
hdr->ctdb_magic = CTDB_MAGIC;
hdr->ctdb_version = CTDB_VERSION;
hdr->srcnode = ctdb->vnn;
@@ -761,7 +763,10 @@
{
int size;
struct ctdb_req_header *hdr;
- size = ((length+1)+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
+
+ length = MAX(length, slength);
+ size = (length+(CTDB_DS_ALIGNMENT-1)) & ~(CTDB_DS_ALIGNMENT-1);
+
hdr = (struct ctdb_req_header *)ctdb->methods->allocate_pkt(mem_ctx, size);
if (hdr == NULL) {
DEBUG(0,("Unable to allocate transport packet for operation %u of length %u\n",
@@ -769,9 +774,9 @@
return NULL;
}
talloc_set_name_const(hdr, type);
- memset(hdr, 0, size);
+ memset(hdr, 0, slength);
+ hdr->length = length;
hdr->operation = operation;
- hdr->length = size;
hdr->ctdb_magic = CTDB_MAGIC;
hdr->ctdb_version = CTDB_VERSION;
hdr->generation = ctdb->vnn_map->generation;
More information about the samba-cvs
mailing list