Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 16149 invoked by uid 500); 8 May 2003 17:53:17 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 16130 invoked from network); 8 May 2003 17:53:16 -0000 Errors-To: Message-Id: <5.2.0.9.2.20030508123631.032594e8@pop3.rowe-clan.net> X-Sender: wrowe%rowe-clan.net@pop3.rowe-clan.net X-Mailer: QUALCOMM Windows Eudora Version 5.2.0.9 Date: Thu, 08 May 2003 12:39:35 -0500 To: Dmitri Tikhonov From: "William A. Rowe, Jr." Subject: Re: flock() does not work in Apache2 module. Cc: apache-modules@covalent.net, dev@apr.apache.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N At 12:14 PM 5/8/2003, Dmitri Tikhonov wrote: >I've run into an interesting problem: my module needs to read >configuration from a file that is occasionally changed by another process. >I've created a test C program that reads configuration if it can obtain a >lock using flock(2) function: > > if (-1 == flock(fd, LOCK_SH|LOCK_NB)) { Why not apr_file_lock? If not - why would you be asking here {dev@apr}? >However, when I put the function into my module, flock() always gets the >lock, no matter what. Question: has anyone seen this before? is there >a side-effect of Apache environment that I'm not aware of? Ok, the answer (this applies to unix apr_file_lock too) ... unix flock is an advisory lock - it isn't enforced except between processes that choose to use it. So unless the other application that modifies that file chooses to use flock, you can't use flock to sync updates between two apps. >My set-up: Linux 2.4.21pre5, Apache 2.0.45, Perl 5.6.1, glibc 2.2.4.