mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
merge from tridge
(This used to be ctdb commit b40bb042e5a29c61161421d7451368b11ad757e9)
This commit is contained in:
commit
7b1d652d40
@ -796,10 +796,13 @@ int ctdb_store_unlock(struct ctdb_record_handle *rec, TDB_DATA data)
|
||||
ret = ctdb_ltdb_fetch(rec->ctdb_db, rec->key, &header, NULL, NULL);
|
||||
if (ret) {
|
||||
ctdb_set_error(rec->ctdb_db->ctdb, "Fetch of locally held record failed");
|
||||
talloc_free(rec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ctdb_ltdb_store(rec->ctdb_db, rec->key, &header, data);
|
||||
|
||||
talloc_free(rec);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -656,6 +656,7 @@ int ctdb_client_store_unlock(struct ctdb_record_handle *rec, TDB_DATA data)
|
||||
state = ctdb_client_store_unlock_send(rec, rec, data);
|
||||
res = ctdb_client_store_unlock_recv(state, rec);
|
||||
|
||||
return res;
|
||||
talloc_free(rec);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "system/network.h"
|
||||
#include "system/filesys.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
#include "ctdb.h"
|
||||
#include "../include/ctdb.h"
|
||||
|
||||
/* structures for packet queueing - see common/ctdb_io.c */
|
||||
struct ctdb_partial {
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "system/network.h"
|
||||
#include "system/filesys.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
|
||||
#include "lib/util/dlinklist.h"
|
||||
|
||||
/*
|
||||
this dispatches the messages to the registered ctdb message handler
|
||||
@ -39,7 +39,7 @@ static int ctdb_dispatch_message(struct ctdb_context *ctdb, uint32_t srvid, TDB_
|
||||
/* XXX we need a must faster way of finding the matching srvid
|
||||
- maybe a tree? */
|
||||
for (ml=ctdb->message_list;ml;ml=ml->next) {
|
||||
if (ml->srvid == srvid) break;
|
||||
if (ml->srvid == srvid || ml->srvid == CTDB_SRVID_ALL) break;
|
||||
}
|
||||
if (ml == NULL) {
|
||||
printf("daemon vnn:%d no msg handler for srvid=%u\n", ctdb_get_vnn(ctdb), srvid);
|
||||
|
@ -20,9 +20,10 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "lib/events/events.h"
|
||||
#include "lib/tdb/include/tdb.h"
|
||||
#include "system/network.h"
|
||||
#include "system/filesys.h"
|
||||
#include "ctdb_private.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
|
||||
/*
|
||||
return error string for last error
|
||||
@ -42,15 +43,16 @@ void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...)
|
||||
talloc_free(ctdb->err_msg);
|
||||
va_start(ap, fmt);
|
||||
ctdb->err_msg = talloc_vasprintf(ctdb, fmt, ap);
|
||||
DEBUG(0,("ctdb error: %s\n", ctdb->err_msg));
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
a fatal internal error occurred - no hope for recovery
|
||||
*/
|
||||
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg)
|
||||
{
|
||||
DEBUG(0,("ctdb fatal error: %s\n", msg));
|
||||
fprintf(stderr, "ctdb fatal error: '%s'\n", msg);
|
||||
abort();
|
||||
}
|
||||
|
@ -43,12 +43,13 @@ static void block_signal(int signum)
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
struct ctdb_context *ctdb;
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
const char *nlist = NULL;
|
||||
const char *transport = "tcp";
|
||||
const char *myaddress = NULL;
|
||||
int self_connect=0;
|
||||
int daemon_mode=0;
|
||||
const char *db_list = "test.tdb";
|
||||
char *s, *tok;
|
||||
|
||||
struct poptOption popt_options[] = {
|
||||
POPT_AUTOHELP
|
||||
@ -57,6 +58,7 @@ int main(int argc, const char *argv[])
|
||||
{ "transport", 0, POPT_ARG_STRING, &transport, 0, "protocol transport", NULL },
|
||||
{ "self-connect", 0, POPT_ARG_NONE, &self_connect, 0, "enable self connect", "boolean" },
|
||||
{ "daemon", 0, POPT_ARG_NONE, &daemon_mode, 0, "spawn a ctdb daemon", "boolean" },
|
||||
{ "dblist", 0, POPT_ARG_STRING, &db_list, 0, "list of databases", NULL },
|
||||
POPT_TABLEEND
|
||||
};
|
||||
int opt;
|
||||
@ -127,11 +129,18 @@ int main(int argc, const char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* attach to a specific database */
|
||||
ctdb_db = ctdb_attach(ctdb, "test.tdb", TDB_DEFAULT, O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
if (!ctdb_db) {
|
||||
printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
|
||||
exit(1);
|
||||
/* attach to the list of databases */
|
||||
s = talloc_strdup(ctdb, db_list);
|
||||
for (tok=strtok(s, ", "); tok; tok=strtok(NULL, ", ")) {
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
ctdb_db = ctdb_attach(ctdb, tok, TDB_DEFAULT,
|
||||
O_RDWR|O_CREAT|O_TRUNC, 0666);
|
||||
if (!ctdb_db) {
|
||||
printf("ctdb_attach to '%s'failed - %s\n", tok,
|
||||
ctdb_errstr(ctdb));
|
||||
exit(1);
|
||||
}
|
||||
printf("Attached to database '%s'\n", tok);
|
||||
}
|
||||
|
||||
/* start the protocol running */
|
||||
|
@ -56,6 +56,11 @@ struct ctdb_call_info {
|
||||
#define CTDB_FLAG_CONNECT_WAIT (1<<2)
|
||||
|
||||
|
||||
/*
|
||||
a message handler ID meaning "give me all messages"
|
||||
*/
|
||||
#define CTDB_SRVID_ALL 0xFFFFFFFF
|
||||
|
||||
struct event_context;
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user