summaryrefslogtreecommitdiff
path: root/source3/lib/util_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_file.c')
-rw-r--r--source3/lib/util_file.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index e80267f84b..611e0e40be 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -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;
@@ -51,9 +52,10 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
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 SIG_IGN);
+ CatchSignal(SIGALRM, SIGNAL_CAST oldsig_handler);
if (gotalarm) {
DEBUG(0, ("do_file_lock: failed to %s file.\n",
@@ -448,7 +450,8 @@ void *map_file(char *fname, size_t size)
#endif
if (!p) {
p = file_load(fname, &s2);
- if (!p || s2 != size) {
+ if (!p) return NULL;
+ if (s2 != size) {
DEBUG(1,("incorrect size for %s - got %d expected %d\n",
fname, s2, size));
if (p) free(p);