diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-08-17 15:04:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:41 -0500 |
commit | d0301937ede878a378677faa64ee2c06fec73681 (patch) | |
tree | fea41c1ca1c9091cec135992b5f060a4f446927b /source3/passdb | |
parent | 8b39f5ef37be33f8b9fb70eae11ae521545edea3 (diff) | |
download | samba-d0301937ede878a378677faa64ee2c06fec73681.tar.gz samba-d0301937ede878a378677faa64ee2c06fec73681.tar.bz2 samba-d0301937ede878a378677faa64ee2c06fec73681.zip |
r17592: Remove some unused functions pointed out by John E. Malmberg, make
do_file_lock static to pdb_smbpasswd.c, the only user of it.
Volker
(This used to be commit 543f77a45f0a75ede48b0f2c674a0abdd386fed5)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_smbpasswd.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index c3f190ff30..d4652ca044 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -64,6 +64,52 @@ struct smbpasswd_privates enum pwf_access_type { PWF_READ, PWF_UPDATE, PWF_CREATE }; +static SIG_ATOMIC_T gotalarm; + +/*************************************************************** + Signal function to tell us we timed out. +****************************************************************/ + +static void gotalarm_sig(void) +{ + gotalarm = 1; +} + +/*************************************************************** + Lock or unlock a fd for a known lock type. Abandon after waitsecs + seconds. +****************************************************************/ + +static BOOL do_file_lock(int fd, int waitsecs, int type) +{ + SMB_STRUCT_FLOCK lock; + int ret; + void (*oldsig_handler)(int); + + gotalarm = 0; + oldsig_handler = CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + + lock.l_type = type; + lock.l_whence = SEEK_SET; + lock.l_start = 0; + lock.l_len = 1; + lock.l_pid = 0; + + alarm(waitsecs); + /* Note we must *NOT* use sys_fcntl here ! JRA */ + ret = fcntl(fd, SMB_F_SETLKW, &lock); + alarm(0); + CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler); + + if (gotalarm) { + DEBUG(0, ("do_file_lock: failed to %s file.\n", + type == F_UNLCK ? "unlock" : "lock")); + return False; + } + + return (ret == 0); +} + /*************************************************************** Lock an fd. Abandon after waitsecs seconds. ****************************************************************/ |