classification
Title: Add open_file_descriptor parameter to fcntl.lockf() (use the new F_OFD_SETLK flag)
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: corona10 Nosy List: Andrew.Lutomirski, corona10, h.venev, iforapsy, miss-islington, neologix, pitrou, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2014-09-08 20:18 by Andrew.Lutomirski, last changed 2019-11-10 15:51 by corona10.

Files
File name Uploaded Description Edit
0001-fcntl-support-F_OFD_.patch h.venev, 2016-03-07 17:55 review
0002-fcntl-Support-Linux-open-file-descriptor-locks.patch h.venev, 2016-03-08 15:43 review
Pull Requests
URL Status Linked Edit
PR 17010 merged corona10, 2019-10-31 06:50
PR 17084 merged miss-islington, 2019-11-07 20:32
PR 17085 merged miss-islington, 2019-11-07 20:32
PR 17099 open corona10, 2019-11-09 14:59
Messages (13)
msg226610 - (view) Author: Andrew Lutomirski (Andrew.Lutomirski) Date: 2014-09-08 20:18
Linux 3.15 and newer support a vastly superior API for file locking, in which locks are owned by open file descriptions instead of by processes.  This is how everyone seems to expect POSIX locks to work, but now they can finally work that way.

Please add some interface to these locks to fcntl.lockf.  One option would be to use them by default and to fall back to standard POSIX locks if they're not available.  I don't know whether this would break existing code.

See http://man7.org/linux/man-pages/man2/fcntl.2.html for details.
msg261295 - (view) Author: Hristo Venev (h.venev) * Date: 2016-03-07 11:08
I'd like to use fd locks from python too.
msg261310 - (view) Author: Hristo Venev (h.venev) * Date: 2016-03-07 17:55
This implements the open_file_descriptor argument and fixes a bug with converting to int when off_t is 64-bit but long is 32-bit.
msg261353 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-08 12:18
> This implements the open_file_descriptor argument and fixes a bug with converting to int when off_t is 64-bit but long is 32-bit.

Please extract the fix into a different patch.
msg261354 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-08 12:19
Strange, Rietveld (the tool linked with the [review] button) doesn't show the change on the Modules/fcntlmodule.c file.

By the way, I suggest to not include the Modules/clinic/fcntlmodule.c.h change in the patch.
msg261365 - (view) Author: Hristo Venev (h.venev) * Date: 2016-03-08 15:43
Here is the OFD patch, I'll open another issue for the overflow bug.
msg355512 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-10-28 04:29
On issue 38602, the constant related to open file descriptors will be added.
I will finalize this issue after issue 38602 is closed.
msg355522 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-10-28 10:59
> On issue 38602, the constant related to open file descriptors will be added. I will finalize this issue after issue 38602 is closed.

issue 38602 added constants, but this issue also modify lockf() to add open_file_descriptor parameter to choose between F_SETLK/F_SETLKW and F_OFD_SETLK/F_OFD_SETLKW.
msg356212 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-11-07 20:31
New changeset befa032d8869e0fab4732d910f3887642879d644 by Serhiy Storchaka (Dong-hee Na) in branch 'master':
bpo-22367: Add tests for fcntl.lockf(). (GH-17010)
https://github.com/python/cpython/commit/befa032d8869e0fab4732d910f3887642879d644
msg356295 - (view) Author: miss-islington (miss-islington) Date: 2019-11-09 11:12
New changeset 85e415108226cc5f3fdddd70196fc4c2a1d0f7f4 by Miss Islington (bot) in branch '3.8':
bpo-22367: Add tests for fcntl.lockf(). (GH-17010)
https://github.com/python/cpython/commit/85e415108226cc5f3fdddd70196fc4c2a1d0f7f4
msg356296 - (view) Author: miss-islington (miss-islington) Date: 2019-11-09 11:12
New changeset 917dbe350a762ed6d75b7d074f3fb87975ba717b by Miss Islington (bot) in branch '3.7':
bpo-22367: Add tests for fcntl.lockf(). (GH-17010)
https://github.com/python/cpython/commit/917dbe350a762ed6d75b7d074f3fb87975ba717b
msg356328 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-10 15:30
One question:
Is there any reason to choose the name is `open_file_descriptor` not `open_file_description`?
msg356329 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-10 15:51
According to https://www.gnu.org/software/libc/manual/html_node/Open-File-Description-Locks.html

It is important to distinguish between the open file description (an instance of an open file, usually created by a call to open) and an open file descriptor, which is a numeric value that refers to the open file description. The locks described here are associated with the open file description and not the open file descriptor
History
Date User Action Args
2019-11-10 15:51:55corona10setmessages: + msg356329
2019-11-10 15:30:20corona10setmessages: + msg356328
2019-11-09 14:59:21corona10setpull_requests: + pull_request16607
2019-11-09 11:12:39miss-islingtonsetmessages: + msg356296
2019-11-09 11:12:32miss-islingtonsetnosy: + miss-islington
messages: + msg356295
2019-11-07 20:32:35miss-islingtonsetpull_requests: + pull_request16595
2019-11-07 20:32:27miss-islingtonsetpull_requests: + pull_request16594
2019-11-07 20:31:45serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg356212
2019-10-31 06:50:50corona10setstage: needs patch -> patch review
pull_requests: + pull_request16534
2019-10-28 10:59:26vstinnersetmessages: + msg355522
2019-10-28 04:29:13corona10setassignee: corona10

messages: + msg355512
nosy: + corona10
2019-07-29 18:33:58nanjekyejoannahsetnosy: - nanjekyejoannah
2019-07-19 18:58:27nanjekyejoannahsetnosy: + nanjekyejoannah
2019-07-18 00:53:39iforapsysetnosy: + iforapsy
2016-03-08 15:43:40h.venevsetfiles: + 0002-fcntl-Support-Linux-open-file-descriptor-locks.patch

messages: + msg261365
versions: + Python 3.6
2016-03-08 12:20:42vstinnersetnosy: + pitrou
2016-03-08 12:20:23vstinnersettitle: Add F_OFD_SETLK, etc support to fcntl.lockf -> Add open_file_descriptor parameter to fcntl.lockf() (use the new F_OFD_SETLK flag)
2016-03-08 12:19:47vstinnersetmessages: + msg261354
title: Please add F_OFD_SETLK, etc support to fcntl.lockf -> Add F_OFD_SETLK, etc support to fcntl.lockf
2016-03-08 12:18:27vstinnersetmessages: + msg261353
2016-03-07 17:55:02h.venevsetfiles: + 0001-fcntl-support-F_OFD_.patch
keywords: + patch
messages: + msg261310
2016-03-07 13:25:09vstinnersetnosy: + vstinner
2016-03-07 11:08:12h.venevsetnosy: + h.venev
messages: + msg261295
2014-11-18 13:31:03pitrousetnosy: + neologix
2014-11-18 09:48:27serhiy.storchakasetstage: needs patch
versions: - Python 2.7
2014-09-08 20:18:49Andrew.Lutomirskicreate