Well, flush my buffers!

Well, flush my buffers!

Post by Bill Mosele » Fri, 18 Feb 2000 04:00:00



I have a mod_perl script that opens a log file once per child process --
that is, the file remains open from request to request for the life of
the child.  The file is opened to flush after each write ( $| = 1 in
perl).

When a child wants to write it flock's LOCK_EX, does a one line print,
and then flock LOCK_UN.  (Perl also flushes on flock LOCK_EX and
LOCK_UN).

Every night I archive the log file.  I have another program that opens
the same file, grabs a LOCK_EX, waits two seconds, then copies the file.

As a check, I then check that the original log file and the copy are the
same size (I'm still holding the LOCK_EX).

For two months this has been working fine, but last night the program
reported that the original was larger than the copy -- so it seems as if
the file was written to after I had a LOCK_EX.  The mod_perl application
is the ONLY program writing to this file, and the locking does work
properly.

Is it possible that Solaris is buffering the writes to disk longer than
the two seconds I wait after grabbing the LOCK_EX?

The only think I can think of is that the mod_perl application wrote a
line, and then did a flock LOCK_UN, and then my archive program grabbed
the LOCK_EX, waited two seconds, I copied the file, then Solaris flushed
to the log file.  Is this possible?

--

pls note the one line sig, not counting this one.

 
 
 

Well, flush my buffers!

Post by Bill Mosele » Fri, 18 Feb 2000 04:00:00


I have a mod_perl script that opens a log file once per child process --
that is, the file remains open from request to request for the life of
the child.  The file is opened to flush after each write ( $| = 1 in
perl).

When a child wants to write it flock's LOCK_EX, does a one line print,
and then flock LOCK_UN.  (Perl also flushes on flock LOCK_EX and
LOCK_UN).

Every night I archive the log file.  I have another program that opens
the same file, grabs a LOCK_EX, waits two seconds, then copies the file.

As a check, I then check that the original log file and the copy are the
same size (I'm still holding the LOCK_EX).

For two months this has been working fine, but last night the program
reported that the original was larger than the copy -- so it seems as if
the file was written to after I had a LOCK_EX.  The mod_perl application
is the ONLY program writing to this file, and the locking does work
properly.

Is it possible that Solaris is buffering the writes to disk longer than
the two seconds I wait after grabbing the LOCK_EX?

The only think I can think of is that the mod_perl application wrote a
line, and then did a flock LOCK_UN, and then my archive program grabbed
the LOCK_EX, waited two seconds, I copied the file, then Solaris flushed
to the log file.  Is this possible?

--

pls note the one line sig, not counting this one.

 
 
 

Well, flush my buffers!

Post by Bill Mosele » Fri, 18 Feb 2000 04:00:00


I have a mod_perl script that opens a log file once per child process --
that is, the file remains open from request to request for the life of
the child.  The file is opened to flush after each write ( $| = 1 in
perl).

When a child wants to write it flock's LOCK_EX, does a one line print,
and then flock LOCK_UN.  (Perl also flushes on flock LOCK_EX and
LOCK_UN).

Every night I archive the log file.  I have another program that opens
the same file, grabs a LOCK_EX, waits two seconds, then copies the file.

As a check, I then check that the original log file and the copy are the
same size (I'm still holding the LOCK_EX).

For two months this has been working fine, but last night the program
reported that the original was larger than the copy -- so it seems as if
the file was written to after I had a LOCK_EX.  The mod_perl application
is the ONLY program writing to this file, and the locking does work
properly.

Is it possible that Solaris is buffering the writes to disk longer than
the two seconds I wait after grabbing the LOCK_EX?

The only think I can think of is that the mod_perl application wrote a
line, and then did a flock LOCK_UN, and then my archive program grabbed
the LOCK_EX, waited two seconds, I copied the file, then Solaris flushed
to the log file.  Is this possible?

--

pls note the one line sig, not counting this one.

 
 
 

1. doing buffered RPC via clnt_call: how to do a buffer flush?

Hi,

   at the university I am trying to write a fast client/server application
using RPC (tcp mode).
For this I am trying to force RPC to buffer RPC calls which do not need a return
value locally at the client. This should greatly increase the speed of
my application as I do not have to wait for the servers response at every call.

I have figured out to use the buffered clnt_call
   (see RPCs clnt_tcp.c:
      * TCP based RPC supports 'batched calls'.
      * A sequence of calls may be batched-up in a send buffer.  The rpc call
      * return immediately to the client even though the call was not necessaril
      * sent.  The batching occurs if the results' xdr routine is NULL (0) AND
      * the rpc timeout value is zero (see clnt.h, rpc).
    )
This buffers the RPC locally at the client, but seem not send the RPC call
to the server regulary.

My question:

  How do I force RPC to send the buffer contents from the client to the server?
  (how do I flush the buffer).

Any hint is appreciated.


Many thanks.

-- Birgit

2. strange kernel log messages ....

3. Help Mandrake sound Via driver

4. Linux Mall (SUCKS) --how long to wait on orders?

5. HP JetDirect: Flushing buffer on printer

6. i740 chipset

7. How do I flush buffers from a script?

8. Automatically flushing STDOUT buffer?

9. Forcing a flush of stdout buffer

10. No way to flush rx buffer in serial driver?

11. How to flush UDP socket buffer?