Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Refactor some of the win32 POSIX emulation#4192

Merged
carlosmn merged 15 commits intomasterlibgit2/libgit2:masterfrom
ethomson/win32_posixlibgit2/libgit2:ethomson/win32_posixCopy head branch name to clipboard
Apr 17, 2017
Merged

Refactor some of the win32 POSIX emulation#4192
carlosmn merged 15 commits intomasterlibgit2/libgit2:masterfrom
ethomson/win32_posixlibgit2/libgit2:ethomson/win32_posixCopy head branch name to clipboard

Conversation

@ethomson
Copy link
Member

@ethomson ethomson commented Apr 5, 2017

This pulls in #3790, which provides retries in more of the POSIX emulation functions to be more resilient in the face of files locked by the aggressive locking semantics in Win32, and #4073, which allows consumers to configure their own locking strategies so that consumers can "get out of the way" of their users a bit more instead of locking files unnecessarily.

I refactored these a bit: this now introduces a do_with_retries macro that will execute the given function up to 10 times, retrying if the error appears to be something like a locked file. Callers can provide a "cleanup" function - perhaps to set the file writable - that will be called between invocations of the main function. This allowed us to clean up some patterns of try / set writable / try again.

I introduced the GIT_RETRY constant here. This is internal only and should never be returned to callers.

These new retryable functions call the win32 functions directly instead of calling Windows' POSIX emulation functions, which allows us to use the win32 error codes which are more fine-grained. This allows us to retry only particular failures (ie, ERROR_SHARING_VIOLATION ) instead of a sharing violation and all the other failures that get mapped to a particular POSIX errno.

This also allows us to bring in the configurable share mode for CreateFile, in #4073.

Once p_utimes called a retryable version of p_open, I noticed quickly that it was retrying all the time. Our ODB freshening test was freshening an object in a repository that had been copied over from a test harness and - as a result - the objects were all writable. Thus p_utimes would succeed on Windows. But freshening a file that we wrote - and thus marked as read-only - would fail. Oops. So I made p_utimes deal with read-only files by setting them writable temporarily to update the time.

tylerc and others added 15 commits May 18, 2016 09:33
Introduce mapping from windows error codes to errno values.  This
allows us to replace our calls to the Windows posix emulation functions
with calls to the Win32 APIs for more fine-grained control over the
emulation.

These mappings match the Windows CRT's mappings for its posix emulation
as they were described to me.
Provide a macro that will allow us to run a function with posix-like
return values multiple times in a retry loop, with an optional cleanup
function called between invocations.
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Signed-off-by: Sven Strickroth <email@cs-ware.de>
This can prevent FILE_SHARED_VIOLATIONS when used in tools such as TortoiseGit TGitCache and FILE_SHARE_DELETE, because files can be opened w/o being locked any more.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
POSIX emulation retries should be configurable so that tests can disable
them.  In particular, maniacally threading tests may end up trying to
open locked files and need retries, which will slow continuous
integration tests significantly.
Instead of failing to set the timestamp of a read-only file (like any
object file), set it writable temporarily to update the timestamp.
The `remediation` function is run in the retry loop in order to attempt
to fix any problems that the prior run encountered.  There is nothing
"cleaned up".  Clarify the name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.