Edit report at https://bugs.php.net/bug.php?id=63709&edit=1

 ID:                 63709
 User updated by:    eric dot saintetienne at gmail dot com
 Reported by:        eric dot saintetienne at gmail dot com
 Summary:            flock() doesn't trigger mandatory locks on linux
 Status:             Analyzed
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Linux
 PHP Version:        5.3.19
 Block user comment: N
 Private report:     N

 New Comment:

You're right, Python is smart and the trick is simple: fnctl module functions 
are coded such that they detect the type of the object they're given as 
argument. If it's an integer they assume it is a file descriptor otherwise they 
call its fileno() method to retrieve the file descriptor integer.

So it's a matter of adding your own fileno() method to the PHP standard file 
object and making the dio_* routines calling it, when not provided with an 
integer.

Does that makes sense to you?

It's a suggestion, at the end of the day it's your decision of how to handle 
this issue, even though it seems to, I'm actually not pushing to get direct io 
integrated at any cost (I don't have any stake) but I just feel it's the way to 
go.


Previous Comments:
------------------------------------------------------------------------
[2012-12-07 09:08:01] ahar...@php.net

That's true, but they're still somewhat interchangeable in Python — higher 
level file objects returned by open() work with fcntl methods. That wouldn't be 
the case if we bundled dio without further work.

------------------------------------------------------------------------
[2012-12-07 08:55:27] eric dot saintetienne at gmail dot com

You're right, dio is a plain inteface to the underlying C function hence 
exposing 
real file descriptors (integers).

That's also what Python does: it exposes two different types of file objects: 
standard file objects via the builtin open() and file descriptors via os.open()

Is that is feasible with php?

------------------------------------------------------------------------
[2012-12-07 08:48:41] ahar...@php.net

My worry there is that dio resources are (as I recall, anyway) completely 
distinct from normal file resources, so you couldn't fopen() a file and then 
dio_fcntl() it: it's all or nothing.

------------------------------------------------------------------------
[2012-12-07 08:42:12] eric dot saintetienne at gmail dot com

A fifth option is to pull the "Direct IO" extension into the mainline.
http://pecl.php.net/package/dio

This extension already expose fcntl() as well as a few other low-level
POSIX routines, and have some amount of testing as it's in its fourth
version already (though it's said to be in beta state)

------------------------------------------------------------------------
[2012-12-07 03:24:16] larue...@php.net

I like 3 :)

change the behavior of flock will intruduce a  visible bc break

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=63709


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63709&edit=1

Reply via email to