mirror of
https://github.com/samba-team/samba.git
synced 2024-12-29 11:21:54 +03:00
Ensure we save any older SIGALRM signal handler.
Jeremy.
This commit is contained in:
parent
1712a7b34a
commit
aa0a6f5532
@ -475,6 +475,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout)
|
||||
{
|
||||
TDB_DATA key;
|
||||
int ret;
|
||||
void (*oldsig_handler)(int);
|
||||
|
||||
if (!message_init())
|
||||
return False;
|
||||
@ -484,7 +485,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout)
|
||||
|
||||
if (timeout) {
|
||||
gotalarm = 0;
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
alarm(timeout);
|
||||
}
|
||||
|
||||
@ -492,7 +493,7 @@ BOOL message_named_mutex(char *name, unsigned int timeout)
|
||||
|
||||
if (timeout) {
|
||||
alarm(0);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);
|
||||
if (gotalarm)
|
||||
return False;
|
||||
}
|
||||
|
@ -96,10 +96,11 @@ void BlockSignals(BOOL block,int signum)
|
||||
2) The signal should be blocked during handler execution.
|
||||
********************************************************************/
|
||||
|
||||
void CatchSignal(int signum,void (*handler)(int ))
|
||||
void (*CatchSignal(int signum,void (*handler)(int )))(int)
|
||||
{
|
||||
#ifdef HAVE_SIGACTION
|
||||
struct sigaction act;
|
||||
struct sigaction oldact;
|
||||
|
||||
ZERO_STRUCT(act);
|
||||
|
||||
@ -113,10 +114,11 @@ void CatchSignal(int signum,void (*handler)(int ))
|
||||
#endif
|
||||
sigemptyset(&act.sa_mask);
|
||||
sigaddset(&act.sa_mask,signum);
|
||||
sigaction(signum,&act,NULL);
|
||||
sigaction(signum,&act,&oldact);
|
||||
return oldact.sa_handler;
|
||||
#else /* !HAVE_SIGACTION */
|
||||
/* FIXME: need to handle sigvec and systems with broken signal() */
|
||||
signal(signum, handler);
|
||||
return signal(signum, handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,10 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
|
||||
{
|
||||
SMB_STRUCT_FLOCK lock;
|
||||
int ret;
|
||||
void (*oldsig_handler)(int);
|
||||
|
||||
gotalarm = 0;
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
|
||||
|
||||
lock.l_type = type;
|
||||
lock.l_whence = SEEK_SET;
|
||||
@ -54,7 +55,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
|
||||
/* Note we must *NOT* use sys_fcntl here ! JRA */
|
||||
ret = fcntl(fd, SMB_F_SETLKW, &lock);
|
||||
alarm(0);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
|
||||
CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);
|
||||
|
||||
if (gotalarm) {
|
||||
DEBUG(0, ("do_file_lock: failed to %s file.\n",
|
||||
|
Loading…
Reference in New Issue
Block a user