You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Stein <gs...@lyra.org> on 1999/11/15 15:56:27 UTC

help with fcntl...

Can anybody here think of why these calls to fcntl() are not blocking my
process?

thx,
-g

--
Greg Stein, http://www.lyra.org/

---------- Forwarded message ----------
Date: Mon, 15 Nov 1999 06:50:27 -0800 (PST)
From: Greg Stein <gs...@lyra.org>
To: dav-dev@lyra.org
Subject: [dav-dev] help with fcntl...

Hi all,

I suspected that a recent change was going to deadlock me, but figured I'd
run it anyhow as it seemed suspicious that I hadn't already deadlocked in
other cases... Well, it didn't deadlock on the fcntl() calls.

Rooting out the problem, it almost seems like my fcntl() calls aren't
setting a lock at all(!).

I'm running Linux kernel 2.2.12 and glibc 2.1.2. Running strace seems like
the kernel is getting the right stuff and not blocking my process (so it
would seem there isn't a problem with glibc).

I've attached my program. If I haven't done something really stupid, then
it should block on that do_lock(fd2) call.

This is the locking code that I added to SDBM a long while ago, and it
worked when I first snarfed it from mod_rewrite. Of course, that was a
kernel or two ago...

Does anybody have any ideas?

thx!
-g

--
Greg Stein, http://www.lyra.org/

Re: help with fcntl...

Posted by Manoj Kasichainula <ma...@io.com>.
Greg Stein wrote:
> I suspected that a recent change was going to deadlock me, but figured I'd
> run it anyhow as it seemed suspicious that I hadn't already deadlocked in
> other cases... Well, it didn't deadlock on the fcntl() calls.
> 
> Rooting out the problem, it almost seems like my fcntl() calls aren't
> setting a lock at all(!).

In this test program, you're trying to obtain the lock twice in the
same process. At least on Linux, you are allowed to do this and won't
deadlock. I don't know for sure that this is legal behavior, though,
but it will happen even if two different threads in the same process
go after the same file.

I tried added a sleep call before your test program's exit. When
running a 2nd copy of the program, it blocked until the first copy
exited, as would be expected.

-- 
Manoj Kasichainula - manojk at io dot com - http://www.io.com/~manojk/