Thread: fcntl(F_SETLK)

fcntl(F_SETLK)

From
eisentrp@csis.gvsu.edu
Date:
There's a broken configure test for fcntl(F_SETLK). (Hint: Of course it's
going to fail if you don't include the header file that defines
F_SETLK.) Apparently, it's been broken for quite a while so I'm afraid to
fix it, considering the problems with file locking.

Reading up on TODO.detail/flock, it seems this mechanism is made obsolete
by the pid file, so I'm inclined to remove it. At least those using Linux
and Solaris shouldn't feel a difference because the locking code wasn't
being used for said reasons. :)

-- 
Peter Eisentraut                  Sernanders vaeg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: fcntl(F_SETLK)

From
Bruce Momjian
Date:
> There's a broken configure test for fcntl(F_SETLK). (Hint: Of course it's
> going to fail if you don't include the header file that defines
> F_SETLK.) Apparently, it's been broken for quite a while so I'm afraid to
> fix it, considering the problems with file locking.
> 
> Reading up on TODO.detail/flock, it seems this mechanism is made obsolete
> by the pid file, so I'm inclined to remove it. At least those using Linux
> and Solaris shouldn't feel a difference because the locking code wasn't
> being used for said reasons. :)

I just applied a patch from an IA64 user that fixes that.  Seems Tom
Lane thinks protecting multiple postmasters on the same port is still an
issue.  Let's hash it out and get it done, maybe.

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: fcntl(F_SETLK)

From
Philip Warner
Date:
At 12:21 5/07/00 -0400, Bruce Momjian wrote:
>> There's a broken configure test for fcntl(F_SETLK). (Hint: Of course it's
>> going to fail if you don't include the header file that defines
>> F_SETLK.) Apparently, it's been broken for quite a while so I'm afraid to
>> fix it, considering the problems with file locking.
>> 
>> Reading up on TODO.detail/flock, it seems this mechanism is made obsolete
>> by the pid file, so I'm inclined to remove it. At least those using Linux
>> and Solaris shouldn't feel a difference because the locking code wasn't
>> being used for said reasons. :)
>
>I just applied a patch from an IA64 user that fixes that.  Seems Tom
>Lane thinks protecting multiple postmasters on the same port is still an
>issue.  Let's hash it out and get it done, maybe.

Building the current CVS sources for SuSE Linux 6.1 works, but when running
it I get crashes:

open("/var/lib/pgsql7.0.2d/data/postgresql.conf", O_RDONLY) = 3
fstat(3, {st_mode=0, st_size=0, ...})   = 0
brk(0x823e000)                          = 0x823e000
ioctl(3, TTY_MAGIC, 0xbffff4cc)         = -1 ENOTTY (Inappropriate ioctl
for device)
fstat(3, {st_mode=0, st_size=0, ...})   = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4000d000
read(3, "#\n# PostgreSQL configuration fi"..., 4096) = 592
read(3, "", 4096)                       = 0
read(3, "", 4096)                       = 0
ioctl(3, TTY_MAGIC, 0xbffff4a0)         = -1 ENOTTY (Inappropriate ioctl
for device)
close(3)                                = 0
munmap(0x4000d000, 4096)                = 0
socket(PF_UNIX, SOCK_STREAM, 0)         = 3
open("/tmp/.s.PGSQL.5432", O_WRONLY|O_NONBLOCK) = 4
fcntl(4, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}
<unfinished ...>
+++ killed by SIGSEGV +++

I *presume* this relates to your recent discussions re flock?

By causing the configure test to fail, the resulting code works...




----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/


Re: fcntl(F_SETLK)

From
Thomas Lockhart
Date:
> >> There's a broken configure test for fcntl(F_SETLK). (Hint: Of course it's
> >> going to fail if you don't include the header file that defines
> >> F_SETLK.) Apparently, it's been broken for quite a while so I'm afraid to
> >> fix it, considering the problems with file locking.
> >> Reading up on TODO.detail/flock, it seems this mechanism is made obsolete
> >> by the pid file, so I'm inclined to remove it. At least those using Linux
> >> and Solaris shouldn't feel a difference because the locking code wasn't
> >> being used for said reasons. :)
> I *presume* this relates to your recent discussions re flock?
> By causing the configure test to fail, the resulting code works...

Current CVS sources are hard-broken for Linux :((

On my laptop with a 2.2.14 kernel, postmaster exits with a segfault, and
gdb fails to keep ahold of the image when running:
 Program terminated with signal SIGSEGV, Segmentation fault. The program no longer exists.

which will make it difficult for me to debug.

The tree worked yesterday. Philip, what exactly did you do to "cause the
configure test to fail"? Can I just go in a muck with Makefile.global?

I'd like to get up and running so I can finish testing and submit some
patches!
                     - Thomas


Re: fcntl(F_SETLK)

From
Philip Warner
Date:
At 13:41 6/07/00 +0000, Thomas Lockhart wrote:
>
>The tree worked yesterday. Philip, what exactly did you do to "cause the
>configure test to fail"? Can I just go in a muck with Makefile.global?
>

I tried that, but it seemed not to work - rerunning configure seems to be
necessary. The solution I adopted is quite embarrasing, so if anyone wants
to give me a lesson in the best way to do this, feel free!

In 'configure' you will find a section:

echo $ac_n "checking for fcntl(F_SETLK)""... $ac_c" 1>&6
echo "configure:5598: checking for fcntl(F_SETLK)" >&5
cat > conftest.$ac_ext <<EOF
#line 5600 "configure"
#include "confdefs.h"
#include <tdio.h>
#include <fcntl.h>

I changed the last two lines to:

#include <pjwpjwstdio.h>
#include <pjwpjwfcntl.h>

(ie. two file names that I knew did not exist) - hence the test will fail.
It'd probably work if you just deleted them, but I like to leave
footprints, at least...


----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.C.N. 008 659 498)             |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 0500 83 82 82         |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/


Re: fcntl(F_SETLK)

From
Tom Lane
Date:
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> Current CVS sources are hard-broken for Linux :((

As a workaround, undef HAVE_FCNTL_SETLK in config.h before building.

I think what we'd better do is turn the does-it-compile configure test
for fcntl() into a full-blown does-it-execute test... ain't working
around OS bugs fun?
        regards, tom lane


Re: fcntl(F_SETLK)

From
Thomas Lockhart
Date:
> > Current CVS sources are hard-broken for Linux :((
> As a workaround, undef HAVE_FCNTL_SETLK in config.h before building.
> I think what we'd better do is turn the does-it-compile configure test
> for fcntl() into a full-blown does-it-execute test... ain't working
> around OS bugs fun?

Per your recent go-round, "that ain't a bug, that's a misunderstanding"
;)
                   - Thomas