[Dovecot] Re: Bug? 1.0.0-test28 NFS locking problems
Tim Southerwood
ts at doc.ic.ac.uk
Thu Jul 22 20:41:02 EEST 2004
On Thu, 22 Jul 2004 14:08:41 +0200
Matthias Andree <matthias.andree at gmx.de> wrote:
> Tim Southerwood <ts at doc.ic.ac.uk> writes:
>
> > 1) fcntl with F_SETLKW will not work against a Solaris 2.8 server as
> > proved with a small test program. Other forms of fcntl (ie F_SETLK)
> > are OK.
>
> Why not? Can you show the test program?
Don't know why yet - I assume it's unimplemented in the Solaris NFS
dialect?
Here's the test program, fcntltest.c
//*********************************************************
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
main(int argc, char* argv[])
{
if (argc != 2)
{
fprintf (stderr, "Usage: %s filetolock\n", argv[0]);
return(1);
}
int result;
int fd;
struct flock lock;
char *filetolock;
int locked=0;
filetolock = argv[1];
fd = open(filetolock, O_RDWR);
if (fd == -1)
{
fprintf(stderr, filetolock);
perror (" - error opening file");
return(2);
}
lock.l_type = F_RDLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
lock.l_start = 0; /* byte offset relative to l_whence */
lock.l_whence = SEEK_SET; /* SEEK_SET, SEEK_CUR, SEEK_END */
lock.l_len = 0; /* #bytes (0 means to EOF) */
result = fcntl(fd, F_SETLKW, &lock);
if (result == -1)
{
perror("Error locking file with F_SETLKW");
}
else
{
printf("Locked with F_SETLKW\n");
locked=1;
}
if (!locked)
{
result = fcntl(fd, F_SETLK, &lock);
if (result == -1)
{
perror("Error locking file with F_SETLK");
}
else
{
printf ("Locked with F_SETLK\n");
locked=1;
}
}
if (locked)
{
printf("Sleeping - try to lock same file from second
process\n"); sleep(30);
}
close(fd);
printf("File closed\n");
}
//*********************************************************
gcc -o fcntltest fcntltest.c
# The linux NFS server from linux client
#
ts at lenin > ./fcntltest /vol/csg/public/users/ts/wibble.blah
Locked with F_SETLKW
Sleeping - try to lock same file from second process
File closed
# The local filesystem
#
ts at lenin > ./fcntltest /tmp/p.ps
Locked with F_SETLKW
Sleeping - try to lock same file from second process
File closed
# The Solaris 2.8 server
#
ts at lenin > ./fcntltest /homes/ts/liquid-1.0.0.tar.gz
Error locking file with F_SETLKW: No locks available
Locked with F_SETLK
Sleeping - try to lock same file from second process
File closed
That seems to verify it in my setup.
Cheers
Tim
--
Tim J Southerwood
Senior Programmer
CSG, Dept of Computing, Imperial College, London
--
Mr Tim J Southerwood
Senior Programmer
CSG, Dept of Computing, Imperial College, London
Email personal: ts at dionic.net work: ts at doc.ic.ac.uk
Tel home: +44 (0)1892 824850 mobile: +44 (0)7739-902439 work: +44 (0)20-759-48392
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20040722/4ded26e6/attachment-0001.bin>
More information about the dovecot
mailing list