mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Don't hold the mutex for more than 20 seconds.
Jeremy.
(This used to be commit 1b9f1a368f
)
This commit is contained in:
parent
42cfc17700
commit
64d20453d9
@ -87,11 +87,13 @@ static NTSTATUS connect_to_domain_password_server(struct cli_state **cli,
|
||||
/* we use a mutex to prevent two connections at once - when a NT PDC gets
|
||||
two connections where one hasn't completed a negprot yet it will send a
|
||||
TCP reset to the first connection (tridge) */
|
||||
if (!message_named_mutex(server)) {
|
||||
DEBUG(1,("domain mutex failed for %s\n", server));
|
||||
if (!message_named_mutex(server, 20)) {
|
||||
DEBUG(1,("connect_to_domain_password_server: domain mutex failed for %s\n", server));
|
||||
return NT_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
DEBUG(10,("connect_to_domain_password_server: got mutex for %s\n", server));
|
||||
|
||||
/* Attempt connection */
|
||||
result = cli_full_connection(cli, global_myname, server,
|
||||
&dest_ip, 0, "IPC$", "IPC", "", "", "", 0);
|
||||
|
@ -464,6 +464,17 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type,
|
||||
return True;
|
||||
}
|
||||
|
||||
static VOLATILE sig_atomic_t gotalarm;
|
||||
|
||||
/***************************************************************
|
||||
Signal function to tell us we timed out.
|
||||
****************************************************************/
|
||||
|
||||
static void gotalarm_sig(void)
|
||||
{
|
||||
gotalarm = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the messaging tdb based on a string - this is used as a primitive
|
||||
* form of mutex between smbd instances.
|
||||
@ -471,16 +482,33 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type,
|
||||
* @param name A string identifying the name of the mutex.
|
||||
*/
|
||||
|
||||
BOOL message_named_mutex(const char *name)
|
||||
BOOL message_named_mutex(char *name, unsigned int timeout)
|
||||
{
|
||||
TDB_DATA key;
|
||||
int ret;
|
||||
|
||||
if (!message_init()) return False;
|
||||
if (!message_init())
|
||||
return False;
|
||||
|
||||
key.dptr = name;
|
||||
key.dsize = strlen(name)+1;
|
||||
|
||||
return (tdb_chainlock(tdb, key) == 0);
|
||||
if (timeout) {
|
||||
gotalarm = 0;
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
alarm(timeout);
|
||||
}
|
||||
|
||||
ret = tdb_chainlock(tdb, key);
|
||||
|
||||
if (timeout) {
|
||||
alarm(0);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
|
||||
if (gotalarm)
|
||||
return False;
|
||||
}
|
||||
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -489,7 +517,7 @@ BOOL message_named_mutex(const char *name)
|
||||
* @param name A string identifying the name of the mutex.
|
||||
*/
|
||||
|
||||
void message_named_mutex_release(const char *name)
|
||||
void message_named_mutex_release(char *name)
|
||||
{
|
||||
TDB_DATA key;
|
||||
|
||||
|
@ -53,7 +53,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
|
||||
alarm(waitsecs);
|
||||
ret = fcntl(fd, SMB_F_SETLKW, &lock);
|
||||
alarm(0);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
|
||||
|
||||
if (gotalarm) {
|
||||
DEBUG(0, ("do_file_lock: failed to %s file.\n",
|
||||
|
Loading…
Reference in New Issue
Block a user