mirror of
https://github.com/samba-team/samba.git
synced 2025-03-26 18:50:30 +03:00
Merge commit 'rusty/ports-from-1.0.112' into foo
(This used to be ctdb commit 13e58d92f5f1723e850a82ae030d0ca57e89b1ee)
This commit is contained in:
commit
2e8aac6689
@ -3827,9 +3827,15 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb)
|
||||
* to the daemon as a client process, this function can be used to change
|
||||
* the ctdb context from daemon into client mode
|
||||
*/
|
||||
int switch_from_server_to_client(struct ctdb_context *ctdb)
|
||||
int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
/* Add extra information so we can identify this in the logs */
|
||||
va_start(ap, fmt);
|
||||
debug_extra = talloc_append_string(NULL, talloc_vasprintf(NULL, fmt, ap), ":");
|
||||
va_end(ap);
|
||||
|
||||
/* shutdown the transport */
|
||||
if (ctdb->methods) {
|
||||
|
@ -164,7 +164,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
|
||||
}
|
||||
|
||||
if (child == 0) {
|
||||
if (switch_from_server_to_client(ctdb) != 0) {
|
||||
if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
|
||||
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
|
||||
_exit(1);
|
||||
}
|
||||
|
6
ctdb/config/events.d/11.natgw
Normal file → Executable file
6
ctdb/config/events.d/11.natgw
Normal file → Executable file
@ -69,6 +69,12 @@ case "$1" in
|
||||
# This is the first node, set it up as the NAT GW
|
||||
echo 1 >/proc/sys/net/ipv4/ip_forward
|
||||
iptables -A POSTROUTING -t nat -s $CTDB_NATGW_PRIVATE_NETWORK -d ! $CTDB_NATGW_PRIVATE_NETWORK -j MASQUERADE
|
||||
|
||||
# block all incoming connections to the natgw address
|
||||
CTDB_NATGW_PUBLIC_IP_HOST=`echo $CTDB_NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
|
||||
iptables -D INPUT -p tcp --syn -d $CTDB_NATGW_PUBLIC_IP_HOST -j REJECT 2>/dev/null
|
||||
iptables -I INPUT -p tcp --syn -d $CTDB_NATGW_PUBLIC_IP_HOST -j REJECT 2>/dev/null
|
||||
|
||||
ip addr add $CTDB_NATGW_PUBLIC_IP dev $CTDB_NATGW_PUBLIC_IFACE
|
||||
ip route add 0.0.0.0/0 via $CTDB_NATGW_DEFAULT_GATEWAY >/dev/null 2>/dev/null
|
||||
else
|
||||
|
@ -551,7 +551,8 @@ int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
|
||||
|
||||
int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
|
||||
|
||||
int switch_from_server_to_client(struct ctdb_context *ctdb);
|
||||
int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt,
|
||||
...);
|
||||
|
||||
int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
|
@ -42,13 +42,15 @@ static void _do_debug_v(const char *format, va_list ap)
|
||||
|
||||
strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
|
||||
|
||||
fprintf(stderr, "%s.%06u [%5u]: %s", tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s);
|
||||
fprintf(stderr, "%s.%06u [%s%5u]: %s", tbuf, (unsigned)t.tv_usec,
|
||||
debug_extra, (unsigned)getpid(), s);
|
||||
fflush(stderr);
|
||||
free(s);
|
||||
}
|
||||
|
||||
/* default logging function */
|
||||
void (*do_debug_v)(const char *, va_list ap) = _do_debug_v;
|
||||
const char *debug_extra = "";
|
||||
|
||||
void do_debug(const char *format, ...)
|
||||
{
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
void (*do_debug_v)(const char *, va_list ap);
|
||||
const char *debug_extra;
|
||||
void (*do_debug_add_v)(const char *, va_list ap);
|
||||
void log_ringbuffer(const char *format, ...);
|
||||
void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
|
||||
|
@ -202,6 +202,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
|
||||
/* in the child */
|
||||
close(fd[0]);
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "freeze_lock-%u:", priority);
|
||||
ret = ctdb_lock_all_databases(ctdb, priority);
|
||||
if (ret != 0) {
|
||||
_exit(0);
|
||||
|
@ -136,6 +136,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
|
||||
if (result->child == 0) {
|
||||
char c = 0;
|
||||
close(result->fd[0]);
|
||||
debug_extra = talloc_asprintf(NULL, "chainlock-%s:", ctdb_db->db_name);
|
||||
tdb_chainlock(ctdb_db->ltdb->tdb, key);
|
||||
write(result->fd[1], &c, 1);
|
||||
/* make sure we die when our parent dies */
|
||||
|
@ -116,6 +116,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "syslogd:");
|
||||
talloc_free(ctdb->ev);
|
||||
ctdb->ev = event_context_init(NULL);
|
||||
tevent_loop_allow_nesting(ctdb->ev);
|
||||
@ -217,15 +218,16 @@ static void ctdb_syslog_log(const char *format, va_list ap)
|
||||
break;
|
||||
}
|
||||
|
||||
len = offsetof(struct syslog_message, message) + strlen(s) + 1;
|
||||
len = offsetof(struct syslog_message, message) + strlen(debug_extra) + strlen(s) + 1;
|
||||
msg = malloc(len);
|
||||
if (msg == NULL) {
|
||||
free(s);
|
||||
return;
|
||||
}
|
||||
msg->level = level;
|
||||
msg->len = strlen(s);
|
||||
strcpy(msg->message, s);
|
||||
msg->len = strlen(debug_extra) + strlen(s);
|
||||
strcpy(msg->message, debug_extra);
|
||||
strcat(msg->message, s);
|
||||
|
||||
if (syslogd_is_started == 0) {
|
||||
syslog(msg->level, "%s", msg->message);
|
||||
@ -279,8 +281,9 @@ static void ctdb_logfile_log(const char *format, va_list ap)
|
||||
|
||||
strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
|
||||
|
||||
ret = asprintf(&s2, "%s.%06u [%5u]: %s",
|
||||
tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s);
|
||||
ret = asprintf(&s2, "%s.%06u [%s%5u]: %s",
|
||||
tbuf, (unsigned)t.tv_usec,
|
||||
debug_extra, (unsigned)getpid(), s);
|
||||
free(s);
|
||||
if (ret == -1) {
|
||||
const char *errstr = "asprintf failed\n";
|
||||
|
@ -91,6 +91,7 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
|
||||
if (child == 0) {
|
||||
int ret;
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "notification-%s:", event);
|
||||
ret = ctdb_run_notification_script_child(ctdb, event);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Notification script failed\n"));
|
||||
|
@ -543,6 +543,7 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
|
||||
char c = 0;
|
||||
|
||||
close(result->fd[0]);
|
||||
debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
|
||||
ret = ctdb_persistent_store(state);
|
||||
if (ret != 0) {
|
||||
DEBUG(DEBUG_ERR, (__location__ " Failed to write persistent data\n"));
|
||||
|
@ -725,6 +725,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
|
||||
char cc = 0;
|
||||
close(state->fd[0]);
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "set_recmode:");
|
||||
/* we should not be able to get the lock on the reclock file,
|
||||
as it should be held by the recovery master
|
||||
*/
|
||||
|
@ -2774,6 +2774,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
|
||||
close(state->fd[0]);
|
||||
state->fd[0] = -1;
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "recovery-lock:");
|
||||
if (pread(ctdb->recovery_lock_fd, &cc, 1, 0) == -1) {
|
||||
DEBUG(DEBUG_CRIT,("failed read from recovery_lock_fd - %s\n", strerror(errno)));
|
||||
cc = RECLOCK_FAILED;
|
||||
@ -3584,7 +3585,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
|
||||
|
||||
srandom(getpid() ^ time(NULL));
|
||||
|
||||
if (switch_from_server_to_client(ctdb) != 0) {
|
||||
if (switch_from_server_to_client(ctdb, "recoverd") != 0) {
|
||||
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n"));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -2283,7 +2283,8 @@ static void tickle_connection_traverse(void *param, void *data)
|
||||
|
||||
/* have tried too many times, just give up */
|
||||
if (con->count >= 5) {
|
||||
talloc_free(con);
|
||||
/* can't delete in traverse: reparent to delete_cons */
|
||||
talloc_steal(param, con);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2303,11 +2304,13 @@ static void ctdb_tickle_sentenced_connections(struct event_context *ev, struct t
|
||||
struct timeval t, void *private_data)
|
||||
{
|
||||
struct ctdb_kill_tcp *killtcp = talloc_get_type(private_data, struct ctdb_kill_tcp);
|
||||
|
||||
void *delete_cons = talloc_new(NULL);
|
||||
|
||||
/* loop over all connections sending tickle ACKs */
|
||||
trbt_traversearray32(killtcp->connections, KILLTCP_KEYLEN, tickle_connection_traverse, NULL);
|
||||
trbt_traversearray32(killtcp->connections, KILLTCP_KEYLEN, tickle_connection_traverse, delete_cons);
|
||||
|
||||
/* now we've finished traverse, it's safe to do deletion. */
|
||||
talloc_free(delete_cons);
|
||||
|
||||
/* If there are no more connections to kill we can remove the
|
||||
entire killtcp structure
|
||||
|
@ -171,6 +171,8 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
|
||||
if (h->child == 0) {
|
||||
/* start the traverse in the child */
|
||||
close(h->fd[0]);
|
||||
debug_extra = talloc_asprintf(NULL, "traverse_local-%s:",
|
||||
ctdb_db->db_name);
|
||||
tdb_traverse_read(ctdb_db->ltdb->tdb, ctdb_traverse_local_fn, h);
|
||||
_exit(0);
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
|
||||
|
||||
DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
|
||||
|
||||
if (switch_from_server_to_client(ctdb) != 0) {
|
||||
if (switch_from_server_to_client(ctdb, "vacuum-%s", ctdb_db->db_name) != 0) {
|
||||
DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch vacuum daemon into client mode. Shutting down.\n"));
|
||||
_exit(1);
|
||||
}
|
||||
|
@ -386,6 +386,9 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
|
||||
if (state->child == 0) {
|
||||
int rt;
|
||||
|
||||
debug_extra = talloc_asprintf(NULL, "eventscript-%s-%s:",
|
||||
current->name,
|
||||
ctdb_eventscript_call_names[state->call]);
|
||||
close(state->fd[0]);
|
||||
set_close_on_exec(state->fd[1]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user