mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
Paranoia changes to ensure that anything touched by a signal handler
and the main code is declared as VOLATILE SIG_ATOMIC_T. Jeremy.
This commit is contained in:
parent
2d35d0cf1d
commit
b737c784e3
@ -30,7 +30,7 @@
|
||||
*/
|
||||
static int initialised;
|
||||
static int select_pipe[2];
|
||||
static unsigned pipe_written, pipe_read;
|
||||
static VOLATILE SIG_ATOMIC_T pipe_written, pipe_read;
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
|
@ -25,9 +25,9 @@
|
||||
#if HAVE_KERNEL_CHANGE_NOTIFY
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
static int fd_pending;
|
||||
static unsigned signals_received;
|
||||
static unsigned signals_processed;
|
||||
static VOLATILE SIG_ATOMIC_T fd_pending;
|
||||
static VOLATILE SIG_ATOMIC_T signals_received;
|
||||
static VOLATILE SIG_ATOMIC_T signals_processed;
|
||||
|
||||
#ifndef DN_ACCESS
|
||||
#define DN_ACCESS 0x00000001 /* File accessed in directory */
|
||||
@ -66,7 +66,7 @@ the signal handler for change notify
|
||||
static void signal_handler(int signal, siginfo_t *info, void *unused)
|
||||
{
|
||||
BlockSignals(True, signal);
|
||||
fd_pending = info->si_fd;
|
||||
fd_pending = (SIG_ATOMIC_T)info->si_fd;
|
||||
signals_received++;
|
||||
sys_select_signal();
|
||||
}
|
||||
@ -80,12 +80,13 @@ static BOOL kernel_check_notify(connection_struct *conn, uint16 vuid, char *path
|
||||
{
|
||||
struct change_data *data = (struct change_data *)datap;
|
||||
|
||||
if (data->directory_handle != fd_pending) return False;
|
||||
if (data->directory_handle != (int)fd_pending) return False;
|
||||
|
||||
DEBUG(3,("kernel change notify on %s fd=%d\n", path, fd_pending));
|
||||
DEBUG(3,("kernel change notify on %s fd=%d\n", path, (int)fd_pending));
|
||||
|
||||
close(fd_pending);
|
||||
data->directory_handle = fd_pending = -1;
|
||||
close((int)fd_pending);
|
||||
fd_pending = (SIG_ATOMIC_T)-1;
|
||||
data->directory_handle = -1;
|
||||
signals_processed++;
|
||||
BlockSignals(False, RT_SIGNAL_NOTIFY);
|
||||
return True;
|
||||
@ -99,8 +100,8 @@ static void kernel_remove_notify(void *datap)
|
||||
struct change_data *data = (struct change_data *)datap;
|
||||
int fd = data->directory_handle;
|
||||
if (fd != -1) {
|
||||
if (fd == fd_pending) {
|
||||
fd_pending = -1;
|
||||
if (fd == (int)fd_pending) {
|
||||
fd_pending = (SIG_ATOMIC_T)-1;
|
||||
signals_processed++;
|
||||
BlockSignals(False, RT_SIGNAL_NOTIFY);
|
||||
}
|
||||
|
@ -27,9 +27,9 @@
|
||||
|
||||
extern int DEBUGLEVEL;
|
||||
|
||||
static unsigned signals_received;
|
||||
static unsigned signals_processed;
|
||||
static int fd_pending; /* the fd of the current pending signal */
|
||||
static VOLATILE SIG_ATOMIC_T signals_received;
|
||||
static VOLATILE SIG_ATOMIC_T signals_processed;
|
||||
static VOLATILE SIG_ATOMIC_T fd_pending; /* the fd of the current pending signal */
|
||||
|
||||
#ifndef F_SETLEASE
|
||||
#define F_SETLEASE 1024
|
||||
@ -57,7 +57,7 @@ handle a LEASE signal, incrementing the signals_received and blocking the signal
|
||||
static void signal_handler(int signal, siginfo_t *info, void *unused)
|
||||
{
|
||||
BlockSignals(True, signal);
|
||||
fd_pending = info->si_fd;
|
||||
fd_pending = (SIG_ATOMIC_T)info->si_fd;
|
||||
signals_received++;
|
||||
sys_select_signal();
|
||||
}
|
||||
@ -133,8 +133,8 @@ static BOOL linux_oplock_receive_message(fd_set *fds, char *buffer, int buffer_l
|
||||
|
||||
if (signals_received == signals_processed) return False;
|
||||
|
||||
if (sys_fstat(fd_pending,&sbuf) == -1) {
|
||||
DEBUG(0,("Invalid file descriptor %d in kernel oplock break!\n", fd_pending));
|
||||
if (sys_fstat((int)fd_pending,&sbuf) == -1) {
|
||||
DEBUG(0,("Invalid file descriptor %d in kernel oplock break!\n", (int)fd_pending));
|
||||
ret = False;
|
||||
goto out;
|
||||
}
|
||||
@ -162,7 +162,7 @@ dev = %x, inode = %.0f\n", (unsigned int)dev, (double)inode ));
|
||||
|
||||
out:
|
||||
/* now we can receive more signals */
|
||||
fd_pending = -1;
|
||||
fd_pending = (SIG_ATOMIC_T)-1;
|
||||
signals_processed++;
|
||||
BlockSignals(False, RT_SIGNAL_LEASE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user