diff options
author | Jeremy Allison <jra@samba.org> | 1998-09-18 17:50:18 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-09-18 17:50:18 +0000 |
commit | 184db9266efcbcea13169f99002b32208dc2ec9b (patch) | |
tree | aa12011b6b4d3600130ec6032213f84aa4ca072e /source3/smbd/oplock.c | |
parent | 717f538e2efdce231f6b9255be998cc4495337df (diff) | |
download | samba-184db9266efcbcea13169f99002b32208dc2ec9b.tar.gz samba-184db9266efcbcea13169f99002b32208dc2ec9b.tar.bz2 samba-184db9266efcbcea13169f99002b32208dc2ec9b.zip |
configure configure.in include/config.h.in include/includes.h
Fixed bugs in readline autoconf.
param/loadparm.c smbd/open.c smbd/oplock.c: Started on kernel oplock
code - checking forced by above issue. Should not be used
currently.
Jeremy.
(This used to be commit f939efac9e6c45331b17e3d3aa6bc2235e886c1a)
Diffstat (limited to 'source3/smbd/oplock.c')
-rw-r--r-- | source3/smbd/oplock.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 348e29dbe2..962043380d 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -26,7 +26,11 @@ extern int DEBUGLEVEL; /* Oplock ipc UDP socket. */ int oplock_sock = -1; uint16 oplock_port = 0; +#if defined(HAVE_KERNEL_OPLOCKS) +static int oplock_pipes[2]; +#endif /* HAVE_KERNEL_OPLOCKS */ +int oplock /* Current number of oplocks we have outstanding. */ int32 global_oplocks_open = 0; BOOL global_oplock_break = False; @@ -678,3 +682,60 @@ BOOL attempt_close_oplocked_file(files_struct *fsp) return False; } +void check_kernel_oplocks(BOOL *have_oplocks) +{ + static BOOL done; + int fd; + int pfd[2]; + pstring tmpname; + + /* + * We only do this check once on startup. + */ + + if(done) + return; + + done = True; + *have_oplocks = False + +#if defined(HAVE_KERNEL_OPLOCKS) + slprintf( tmpname, sizeof(tmpname)-1, "/tmp/ot.%d.XXXXXX", getpid()); + mktemp(tmpname); + + if(pipe(pfd) != 0) { + DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n", + strerror(errno) )); + return; + } + + if((fd = open(tmpname, O_RDWR)) < 0) { + DEBUG(0,("check_kernel_oplocks: Unable to open temp test file %s. Error was %s\n", + tmpname, strerror(errno) )); + unlink( tmpname ); + close(pfd[0]); + close(pfd[1]); + return; + } + + unlink( tmpname ); + + if(fcntl(fd, F_OPLKREG, pfd[1]) == -1) { + DEBUG(0,("check_kernel_oplocks: Kernel oplocks are not available on this machine. \ +Disabling kernel oplock supprt.\n" )); + close(pfd[0]); + close(pfd[1]); + close(fd); + return; + } + + fcntl(fd, F_OPLKACK, OP_REVOKE); + close(pfd[0]); + close(pfd[1]); + close(fd); + + DEBUG(3,("check_kernel_oplocks: Kernel oplocks enabled.\n")); + + *have_oplocks = True; +#endif /* HAVE_KERNEL_OPLOCKS */ +} |