Skip to content
Snippets Groups Projects
Commit 09f98728 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Get rid of the fcntl() usage in sopen()

You can't lock a file on a Samba share via both fcntl() and flock() (the
interact/collide).

This code was in a !BSD block which means they guy that wrote/committed
it wasn't using it either.
parent 77c31de6
No related branches found
No related tags found
No related merge requests found
Pipeline #7113 passed
......@@ -192,9 +192,6 @@ int sopen(const char *fn, int sh_access, int share, ...)
int pmode=0;
#endif
int flock_op=LOCK_NB; /* non-blocking */
#if !defined(BSD)
struct flock alock = {0};
#endif
va_list ap;
if(sh_access&O_CREAT) {
......@@ -209,24 +206,7 @@ int sopen(const char *fn, int sh_access, int share, ...)
if (share == SH_DENYNO || share == SH_COMPAT) /* no lock needed */
return fd;
#if !defined(BSD)
int cmd = F_SETLK;
#ifdef F_OFD_SETLK
cmd = F_OFD_SETLK;
#endif
/* use fcntl (doesn't work correctly with threads) */
alock.l_type = share;
alock.l_whence = L_SET;
alock.l_start = 0;
alock.l_len = 0; /* lock to EOF */
if(fcntl(fd, cmd, &alock)==-1 && errno != EINVAL) { /* EINVAL means the file does not support locking */
close(fd);
return -1;
}
#endif
#if !defined(__QNX__) && !defined(__solaris__)
#if !defined(__solaris__)
/* use flock (doesn't work over NFS) */
if(share==SH_DENYRW)
flock_op|=LOCK_EX;
......@@ -239,7 +219,6 @@ int sopen(const char *fn, int sh_access, int share, ...)
return(-1);
}
#endif
return fd;
}
#endif /* !QNX */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment