X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=Documentation%2Ftechnical%2Fapi-lockfile.txt;h=dd894043ae8b04269b3aa2108f96cb935217181d;hb=5d1e34158a3023af48541bf1731d202849929a12;hp=5b1553e52c83a1e8e8a913b8303a0bfab10ec377;hpb=0c0478cac87991bd555e81715e9332d11eecd881;p=git.git diff --git a/Documentation/technical/api-lockfile.txt b/Documentation/technical/api-lockfile.txt index 5b1553e52..dd894043a 100644 --- a/Documentation/technical/api-lockfile.txt +++ b/Documentation/technical/api-lockfile.txt @@ -37,7 +37,8 @@ commit_lock_file:: Take a pointer to the `struct lock_file` initialized with an earlier call to `hold_lock_file_for_update()`, close the file descriptor and rename the lockfile to its - final destination. + final destination. Returns 0 upon success, a negative + value on failure to close(2) or rename(2). rollback_lock_file:: @@ -45,6 +46,12 @@ rollback_lock_file:: with an earlier call to `hold_lock_file_for_update()`, close the file descriptor and remove the lockfile. +close_lock_file:: + Take a pointer to the `struct lock_file` initialized + with an earlier call to `hold_lock_file_for_update()`, + and close the file descriptor. Returns 0 upon success, + a negative value on failure to close(2). + Because the structure is used in an `atexit(3)` handler, its storage has to stay throughout the life of the program. It cannot be an auto variable allocated on the stack. @@ -54,8 +61,10 @@ done writing to the file descriptor. If you do not call either and simply `exit(3)` from the program, an `atexit(3)` handler will close and remove the lockfile. -You should not close the file descriptor you obtained from -`hold_lock_file_for_update` function yourself. The `struct +If you need to close the file descriptor you obtained from +`hold_lock_file_for_update` function yourself, do so by calling +`close_lock_file()`. You should never call `close(2)` yourself! +Otherwise the `struct lock_file` structure still remembers that the file descriptor needs to be closed, and a later call to `commit_lock_file()` or `rollback_lock_file()` will result in duplicate calls to