Mutex code cleanup and removal of unused types#14181
Conversation
|
I just noticed that most of the cleanup was already done in corert. |
| else | ||
| } | ||
|
|
||
| internal class MutexTryCodeHelper |
There was a problem hiding this comment.
If you would like, you can get rid of this too and just replace it with try/finally block
Ideally, both of these should be done together. I would wait with this - the synchronization/threading is one of the harder areas to unify. |
|
LGTM otherwise |
|
PTAL. I aligned the code more to the corert version to simplify converging later. |
| throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); | ||
| } | ||
| #endif // PLATFORM_WINDOWS | ||
| VerifyNameForCreate(name); |
There was a problem hiding this comment.
This used to be under Windows ifdef, but it is enabled for all platforms now
There was a problem hiding this comment.
On corert it's throwing when a name is provided: https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Threading/Mutex.Unix.cs#L16
Should this be the same here? I'm not sure about this...
There was a problem hiding this comment.
Expected - CoreRT does not support named mutexes on Unix today.
|
|
||
| #if !PLATFORM_UNIX | ||
| if (System.IO.Path.MaxPath < name.Length) | ||
| if (Path.MaxPath < name.Length) |
There was a problem hiding this comment.
Should this use the VerifyNameForCreate method?
There was a problem hiding this comment.
The VerifyNameForCreate method also checks if name is not null which we don't need in this case but I guess it doesn't really matter performance-wise. I will reuse it here
| return OpenExistingWorker(name, (MutexRights)0, out result) == OpenExistingResult.Success; | ||
| createdNew = errorCode != Interop.Errors.ERROR_ALREADY_EXISTS; | ||
| SafeWaitHandle = mutexHandle; | ||
| hasThreadAffinity = true; |
There was a problem hiding this comment.
It looks like you have deleted this in other case, but not this one.
There was a problem hiding this comment.
Do you think it's safe to remove them everywhere now that I'm no longer using the RuntimeHelpers.CleanupCode method?
There was a problem hiding this comment.
It think so. It is also in WaitHandle and a few FCalls - it can be removed there as well.
8a9dc37 to
b07e251
Compare
b07e251 to
eff880d
Compare
|
@jkotas should we merge that for now and I will look into other classes like SafeHandle in a separate PR? |
| case OpenExistingResult.NameInvalid: | ||
| mutexHandle.SetHandleAsInvalid(); | ||
| #if PLATFORM_UNIX | ||
| if (errorCode == Win32Native.ERROR_FILENAME_EXCED_RANGE) |
There was a problem hiding this comment.
Nit: Should this rather be Interop.Errors.ERROR_FILENAME_EXCED_RANGE?
|
@dotnet-bot test Windows_NT x64 corefx_baseline |
ok. (once the corefx legs are green) |
|
the output from the corefx legs is unfortunately unusable :( |
|
The corefx legs are failing with: @fiigii Was it intentional that you have deleted |
|
@jkotas Sorry, my bad. It was incautiously deleted by regexp. |
|
@ViktorHofer #14231 should fix the corefx break. We should retry after it goes in. |
|
@dotnet-bot test this please |
|
@dotnet-bot test Windows_NT x64 corefx_baseline |
|
Failing legs are unrelated to my changes... Some FileSystemWatcher tests are failing |
|
@dotnet-bot test Ubuntu x64 corefx_baseline |
|
Maybe the errors are related. I need to check... |
|
The FileSystemWatcher failures are #14154 |
|
@dotnet-bot test Ubuntu x64 corefx_baseline |
|
@dotnet-bot test Ubuntu x64 Checked Build and Test (Jit - CoreFx) |
@jkotas should I also align Interop code and move it into shared?