[SCM] CTDB repository - branch master updated - ctdb-1.0.114-123-g07b3952
Ronnie Sahlberg
sahlberg at samba.org
Tue Jun 1 23:15:43 MDT 2010
The branch, master has been updated
via 07b395258ab08218e8eed3b4a52654925b85275c (commit)
from 573e4e2d2bd09dd9579150cce926de774a0b609c (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 07b395258ab08218e8eed3b4a52654925b85275c
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed Jun 2 15:13:32 2010 +1000
Add the offsetof macro to libctdb
change all calls to new_ctdb_request() to use the offset macro to calculate the correct size (instead of allocating one byte too many and hoping the alignment padding saves us.)
-----------------------------------------------------------------------
Summary of changes:
libctdb/ctdb.c | 4 ++--
libctdb/libctdb_private.h | 4 ++++
libctdb/messages.c | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libctdb/ctdb.c b/libctdb/ctdb.c
index e49e3d8..39f4bab 100644
--- a/libctdb/ctdb.c
+++ b/libctdb/ctdb.c
@@ -346,7 +346,7 @@ struct ctdb_request *new_ctdb_control_request(struct ctdb_connection *ctdb,
struct ctdb_request *req;
struct ctdb_req_control *pkt;
- req = new_ctdb_request(sizeof(*pkt) + extra, callback, cbdata);
+ req = new_ctdb_request(offsetof(struct ctdb_req_control, data) + extra, callback, cbdata);
if (!req)
return NULL;
@@ -632,7 +632,7 @@ ctdb_readrecordlock_send(struct ctdb_db *ctdb_db, TDB_DATA key,
lock->held = false;
/* Get ready in case we need to send a migrate request. */
- req = new_ctdb_request(sizeof(*req->hdr.call)
+ req = new_ctdb_request(offsetof(struct ctdb_req_call, data)
+ key.dsize, callback, cbdata);
if (!req) {
ctdb_release_lock(lock);
diff --git a/libctdb/libctdb_private.h b/libctdb/libctdb_private.h
index f016be0..ba5ee44 100644
--- a/libctdb/libctdb_private.h
+++ b/libctdb/libctdb_private.h
@@ -7,6 +7,10 @@
#include <ctdb.h>
#include <ctdb_protocol.h>
+#ifndef offsetof
+#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
+#endif
+
struct message_handler_info;
struct ctdb_reply_call;
diff --git a/libctdb/messages.c b/libctdb/messages.c
index 26f90aa..aa997bc 100644
--- a/libctdb/messages.c
+++ b/libctdb/messages.c
@@ -99,7 +99,7 @@ int ctdb_send_message(struct ctdb_connection *ctdb,
struct ctdb_req_message *pkt;
/* We just discard it once it's finished: no reply. */
- req = new_ctdb_request(sizeof(*pkt) + data.dsize,
+ req = new_ctdb_request(offsetof(struct ctdb_req_message, data) + data.dsize,
ctdb_cancel_callback, NULL);
if (!req) {
return -1;
--
CTDB repository
More information about the samba-cvs
mailing list