1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3: Pass the new server_id through reinit_after_fork

This commit is contained in:
Volker Lendecke 2010-07-04 16:28:13 +02:00
parent 5a3c64668a
commit 7f0e6df883
10 changed files with 47 additions and 22 deletions

View File

@ -1226,8 +1226,9 @@ ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos
int set_blocking(int fd, bool set); int set_blocking(int fd, bool set);
void smb_msleep(unsigned int t); void smb_msleep(unsigned int t);
NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
struct event_context *ev_ctx, struct event_context *ev_ctx,
bool parent_longlived); struct server_id id,
bool parent_longlived);
void *malloc_(size_t size); void *malloc_(size_t size);
void *memalign_array(size_t el_size, size_t align, unsigned int count); void *memalign_array(size_t el_size, size_t align, unsigned int count);
void *calloc_array(size_t size, size_t nmemb); void *calloc_array(size_t size, size_t nmemb);

View File

@ -873,6 +873,7 @@ void smb_msleep(unsigned int t)
NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx, NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
struct event_context *ev_ctx, struct event_context *ev_ctx,
struct server_id id,
bool parent_longlived) bool parent_longlived)
{ {
NTSTATUS status = NT_STATUS_OK; NTSTATUS status = NT_STATUS_OK;
@ -899,7 +900,7 @@ NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
* For clustering, we need to re-init our ctdbd connection after the * For clustering, we need to re-init our ctdbd connection after the
* fork * fork
*/ */
status = messaging_reinit(msg_ctx, procid_self()); status = messaging_reinit(msg_ctx, id);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("messaging_reinit() failed: %s\n", DEBUG(0,("messaging_reinit() failed: %s\n",
nt_errstr(status))); nt_errstr(status)));

View File

@ -137,6 +137,7 @@ void kill_async_dns_child(void)
void start_async_dns(void) void start_async_dns(void)
{ {
int fd1[2], fd2[2]; int fd1[2], fd2[2];
NTSTATUS status;
CatchChild(); CatchChild();
@ -164,8 +165,11 @@ void start_async_dns(void)
CatchSignal(SIGHUP, SIG_IGN); CatchSignal(SIGHUP, SIG_IGN);
CatchSignal(SIGTERM, sig_term); CatchSignal(SIGTERM, sig_term);
if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(), status = reinit_after_fork(nmbd_messaging_context(),
nmbd_event_context(), true))) { nmbd_event_context(),
procid_self(), true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
smb_panic("reinit_after_fork() failed"); smb_panic("reinit_after_fork() failed");
} }

View File

@ -779,6 +779,7 @@ static bool open_sockets(bool isdaemon, int port)
{ NULL } { NULL }
}; };
TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
NTSTATUS status;
load_case_tables(); load_case_tables();
@ -923,8 +924,11 @@ static bool open_sockets(bool isdaemon, int port)
pidfile_create("nmbd"); pidfile_create("nmbd");
if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(), status = reinit_after_fork(nmbd_messaging_context(),
nmbd_event_context(), false))) { nmbd_event_context(),
procid_self(), false);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
exit(1); exit(1);
} }

View File

@ -397,6 +397,7 @@ static bool cups_pcap_load_async(int *pfd)
{ {
int fds[2]; int fds[2];
pid_t pid; pid_t pid;
NTSTATUS status;
*pfd = -1; *pfd = -1;
@ -434,8 +435,10 @@ static bool cups_pcap_load_async(int *pfd)
close_all_print_db(); close_all_print_db();
if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(), status = reinit_after_fork(server_messaging_context(),
server_event_context(), true))) { server_event_context(), procid_self(),
true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n")); DEBUG(0,("cups_pcap_load_async: reinit_after_fork() failed\n"));
smb_panic("cups_pcap_load_async: reinit_after_fork() failed"); smb_panic("cups_pcap_load_async: reinit_after_fork() failed");
} }

View File

@ -1430,6 +1430,7 @@ void start_background_queue(void)
if(background_lpq_updater_pid == 0) { if(background_lpq_updater_pid == 0) {
struct tevent_fd *fde; struct tevent_fd *fde;
int ret; int ret;
NTSTATUS status;
/* Child. */ /* Child. */
DEBUG(5,("start_background_queue: background LPQ thread started\n")); DEBUG(5,("start_background_queue: background LPQ thread started\n"));
@ -1437,9 +1438,11 @@ void start_background_queue(void)
close(pause_pipe[0]); close(pause_pipe[0]);
pause_pipe[0] = -1; pause_pipe[0] = -1;
if (!NT_STATUS_IS_OK(reinit_after_fork(server_messaging_context(), status = reinit_after_fork(server_messaging_context(),
server_event_context(), server_event_context(),
true))) { procid_self(), true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
smb_panic("reinit_after_fork() failed"); smb_panic("reinit_after_fork() failed");
} }

View File

@ -2807,7 +2807,8 @@ static bool fork_echo_handler(struct smbd_server_connection *sconn)
close(listener_pipe[0]); close(listener_pipe[0]);
status = reinit_after_fork(smbd_messaging_context(), status = reinit_after_fork(smbd_messaging_context(),
smbd_event_context(), false); smbd_event_context(),
procid_self(), false);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("reinit_after_fork failed: %s\n", DEBUG(1, ("reinit_after_fork failed: %s\n",
nt_errstr(status))); nt_errstr(status)));

View File

@ -409,7 +409,8 @@ static void smbd_accept_connection(struct tevent_context *ev,
s = NULL; s = NULL;
status = reinit_after_fork(smbd_messaging_context(), status = reinit_after_fork(smbd_messaging_context(),
smbd_event_context(), true); smbd_event_context(), procid_self(),
true);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
if (NT_STATUS_EQUAL(status, if (NT_STATUS_EQUAL(status,
NT_STATUS_TOO_MANY_OPENED_FILES)) { NT_STATUS_TOO_MANY_OPENED_FILES)) {
@ -806,6 +807,7 @@ extern void build_options(bool screen);
}; };
struct smbd_parent_context *parent = NULL; struct smbd_parent_context *parent = NULL;
TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */ TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
NTSTATUS status;
smbd_init_globals(); smbd_init_globals();
@ -998,8 +1000,10 @@ extern void build_options(bool screen);
if (is_daemon) if (is_daemon)
pidfile_create("smbd"); pidfile_create("smbd");
if (!NT_STATUS_IS_OK(reinit_after_fork(smbd_messaging_context(), status = reinit_after_fork(smbd_messaging_context(),
smbd_event_context(), false))) { smbd_event_context(),
procid_self(), false);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
exit(1); exit(1);
} }

View File

@ -1122,6 +1122,7 @@ int main(int argc, char **argv, char **envp)
poptContext pc; poptContext pc;
int opt; int opt;
TALLOC_CTX *frame = talloc_stackframe(); TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
/* glibc (?) likes to print "User defined signal 1" and exit if a /* glibc (?) likes to print "User defined signal 1" and exit if a
SIGUSR[12] is received before a handler is installed */ SIGUSR[12] is received before a handler is installed */
@ -1278,9 +1279,10 @@ int main(int argc, char **argv, char **envp)
* winbindd-specific resources we must free yet. JRA. * winbindd-specific resources we must free yet. JRA.
*/ */
if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(), status = reinit_after_fork(winbind_messaging_context(),
winbind_event_context(), winbind_event_context(),
false))) { procid_self(), false);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
exit(1); exit(1);
} }

View File

@ -1106,10 +1106,12 @@ bool winbindd_reinit_after_fork(const char *logfilename)
{ {
struct winbindd_domain *domain; struct winbindd_domain *domain;
struct winbindd_child *cl; struct winbindd_child *cl;
NTSTATUS status;
if (!NT_STATUS_IS_OK(reinit_after_fork(winbind_messaging_context(), status = reinit_after_fork(winbind_messaging_context(),
winbind_event_context(), winbind_event_context(),
true))) { procid_self(), true);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n")); DEBUG(0,("reinit_after_fork() failed\n"));
return false; return false;
} }