summaryrefslogtreecommitdiffstats
path: root/ctdb/common/ctdb_util.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-04-29 16:19:40 +0200
committerAndrew Tridgell <tridge@samba.org>2007-04-29 16:19:40 +0200
commite21f69107f423f24f5407adb9323fb0bc8aa3f64 (patch)
treef357af261e07dde8822d0d178f7906c7e1cc9b33 /ctdb/common/ctdb_util.c
parent10910f52eb1e62bf5393952f4c3a7380bf2dc548 (diff)
downloadsamba-e21f69107f423f24f5407adb9323fb0bc8aa3f64.tar.gz
samba-e21f69107f423f24f5407adb9323fb0bc8aa3f64.tar.xz
samba-e21f69107f423f24f5407adb9323fb0bc8aa3f64.zip
yay! finally fixed the bug that volker, ronnie and I have been chasing
for 2 days. The main bug was in smbd, but there was a secondary (and more subtle) bug in ctdb that the bug in smbd exposed. When we get send a dmaster reply, we have to correctly update the dmaster in the recipient even if the original requst has timed out, otherwise ctdbd can get into a loop fighting over who will handle a key. This patch also cleans up the packet allocation, and makes ctdbd become a real daemon. (This used to be ctdb commit 59405e59ef522b97d8e20e4b14310a217141ac7c)
Diffstat (limited to 'ctdb/common/ctdb_util.c')
-rw-r--r--ctdb/common/ctdb_util.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index f39e8b6682..e77dc8990d 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -129,6 +129,51 @@ void ctdb_latency(double *latency, struct timeval t)
}
}
+#if 0
+struct idr_fake {
+ uint32_t size;
+ void **ptrs;
+};
+
+static void idr_fake_init(struct ctdb_context *ctdb)
+{
+ if (ctdb->fidr) return;
+ ctdb->fidr = talloc(ctdb, struct idr_fake);
+ ctdb->fidr->size = 0x10000;
+ ctdb->fidr->ptrs = talloc_zero_array(ctdb->fidr, void *,
+ ctdb->fidr->size);
+}
+
+uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
+{
+ uint32_t i;
+ idr_fake_init(ctdb);
+ for (i=0;i<ctdb->fidr->size;i++) {
+ if (ctdb->fidr->ptrs[i] == NULL) {
+ ctdb->fidr->ptrs[i] = state;
+ return i;
+ }
+ }
+ return (uint32_t)-1;
+}
+
+void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location)
+{
+ idr_fake_init(ctdb);
+ if (ctdb->fidr->ptrs[reqid] == NULL) {
+ DEBUG(0,("bad fidr id %u\n", reqid));
+ }
+ return ctdb->fidr->ptrs[reqid];
+}
+
+
+void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid)
+{
+ idr_fake_init(ctdb);
+ ctdb->fidr->ptrs[reqid] = NULL;
+}
+
+#else
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)
{
uint32_t id;
@@ -161,3 +206,4 @@ void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid)
}
}
+#endif