From: Andrew Tridgell Date: Wed, 4 Apr 2007 05:02:49 +0000 (+1000) Subject: merge back some changes from Samba4 X-Git-Tag: tevent-0.9.20~348^2~2963 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b686f9d289c6b13aa5c70f3a82ff295d13b21aec;p=thirdparty%2Fsamba.git merge back some changes from Samba4 (This used to be ctdb commit b946ff61c0e4b3269d3c7e01093d0a6d5215d6ee) --- diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 87550ff408d..189816229f0 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -25,7 +25,21 @@ #include "system/filesys.h" #include "../include/ctdb_private.h" #include "db_wrap.h" +#include "lib/util/dlinklist.h" +/* + find an attached ctdb_db handle given a name + */ +struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name) +{ + struct ctdb_db_context *tmp_db; + for (tmp_db=ctdb->db_list;tmp_db;tmp_db=tmp_db->next) { + if (strcmp(name, tmp_db->db_name) == 0) { + return tmp_db; + } + } + return NULL; +} /* attach to a specific database @@ -43,7 +57,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, ctdb_db->db_name = talloc_strdup(ctdb_db, name); CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name); - data.dptr = name; + data.dptr = discard_const(name); data.dsize = strlen(name); ctdb_db->db_id = ctdb_hash(&data); diff --git a/ctdb/include/ctdb.h b/ctdb/include/ctdb.h index 2859733044a..c5b6dbc7824 100644 --- a/ctdb/include/ctdb.h +++ b/ctdb/include/ctdb.h @@ -94,6 +94,11 @@ int ctdb_start(struct ctdb_context *ctdb); struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, int tdb_flags, int open_flags, mode_t mode); +/* + find an attached ctdb_db handle given a name + */ +struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name); + /* error string for last ctdb error */ diff --git a/ctdb/include/includes.h b/ctdb/include/includes.h index 199f416b20a..994c25452c8 100644 --- a/ctdb/include/includes.h +++ b/ctdb/include/includes.h @@ -20,6 +20,10 @@ typedef bool BOOL; #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) +#ifndef discard_const +#define discard_const(ptr) ((void *)((intptr_t)(ptr))) +#endif + struct timeval timeval_zero(void); bool timeval_is_zero(const struct timeval *tv); struct timeval timeval_current(void);