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