ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/README
(Generate patch)

Comparing IO-AIO/README (file contents):
Revision 1.28 by root, Sun Mar 30 06:31:49 2008 UTC vs.
Revision 1.29 by root, Wed Apr 16 16:45:30 2008 UTC

265 Asynchronously close a file and call the callback with the result 265 Asynchronously close a file and call the callback with the result
266 code. 266 code.
267 267
268 Unfortunately, you can't do this to perl. Perl *insists* very 268 Unfortunately, you can't do this to perl. Perl *insists* very
269 strongly on closing the file descriptor associated with the 269 strongly on closing the file descriptor associated with the
270 filehandle itself. Here is what aio_close will try: 270 filehandle itself.
271 271
272 1. dup()licate the fd 272 Therefore, "aio_close" will not close the filehandle - instead it
273 2. asynchronously close() the duplicated fd 273 will use dup2 to overwrite the file descriptor with the write-end of
274 3. dup()licate the fd once more 274 a pipe (the pipe fd will be created on demand and will be cached).
275 4. let perl close() the filehandle
276 5. asynchronously close the duplicated fd
277 275
278 The idea is that the first close() flushes stuff to disk that 276 Or in other words: the file descriptor will be closed, but it will
279 closing an fd will flush, so when perl closes the fd, nothing much 277 not be free for reuse until the perl filehandle is closed.
280 will need to be flushed. The second async. close() will then flush
281 stuff to disk that closing the last fd to the file will flush.
282
283 Just FYI, SuSv3 has this to say on close:
284
285 All outstanding record locks owned by the process on the file
286 associated with the file descriptor shall be removed.
287
288 If fildes refers to a socket, close() shall cause the socket to be
289 destroyed. ... close() shall block for up to the current linger
290 interval until all data is transmitted.
291 [this actually sounds like a specification bug, but who knows]
292
293 And at least Linux additionally actually flushes stuff on every
294 close, even when the file itself is still open.
295
296 Sounds enourmously inefficient and complicated? Yes... please show
297 me how to nuke perl's fd out of existence...
298 278
299 aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) 279 aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
300 aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) 280 aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval)
301 Reads or writes $length bytes from the specified $fh and $offset 281 Reads or writes $length bytes from the specified $fh and $offset
302 into the scalar given by $data and offset $dataoffset and calls the 282 into the scalar given by $data and offset $dataoffset and calls the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines