summaryrefslogtreecommitdiff
path: root/source3/smbd/notify_kernel.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-06-19 21:30:27 +0000
committerJeremy Allison <jra@samba.org>2000-06-19 21:30:27 +0000
commit5e06151e4d13f6c57559e73dcc88e03ec47c63a0 (patch)
tree3ca7711b4aa55032e632a3c3a2a70c6afdd4c54e /source3/smbd/notify_kernel.c
parentc89f1ae0cf5856c30172c11fb935ee68f15f8be7 (diff)
downloadsamba-5e06151e4d13f6c57559e73dcc88e03ec47c63a0.tar.gz
samba-5e06151e4d13f6c57559e73dcc88e03ec47c63a0.tar.bz2
samba-5e06151e4d13f6c57559e73dcc88e03ec47c63a0.zip
Paranoia changes to ensure that anything touched by a signal handler
and the main code is declared as VOLATILE SIG_ATOMIC_T. Jeremy. (This used to be commit b737c784e34b0e1af014cb828ef37d5b6d73c3e2)
Diffstat (limited to 'source3/smbd/notify_kernel.c')
-rw-r--r--source3/smbd/notify_kernel.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/source3/smbd/notify_kernel.c b/source3/smbd/notify_kernel.c
index a7d4591cc9..c517254048 100644
--- a/source3/smbd/notify_kernel.c
+++ b/source3/smbd/notify_kernel.c
@@ -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);
}