Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Mutex code cleanup and removal of unused types#14181

Merged
ViktorHofer merged 2 commits into
dotnet:masterfrom
ViktorHofer:MutexCodeCleanup
Oct 2, 2017
Merged

Mutex code cleanup and removal of unused types#14181
ViktorHofer merged 2 commits into
dotnet:masterfrom
ViktorHofer:MutexCodeCleanup

Conversation

@ViktorHofer
Copy link
Copy Markdown
Member

@jkotas should I also align Interop code and move it into shared?

@ViktorHofer
Copy link
Copy Markdown
Member Author

I just noticed that most of the cleanup was already done in corert.

else
}

internal class MutexTryCodeHelper
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would like, you can get rid of this too and just replace it with try/finally block

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 26, 2017

should I also align Interop code and move it into shared?
I just noticed that most of the cleanup was already done in corert.

Ideally, both of these should be done together. I would wait with this - the synchronization/threading is one of the harder areas to unify.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 26, 2017

LGTM otherwise

@ViktorHofer
Copy link
Copy Markdown
Member Author

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to be under Windows ifdef, but it is enabled for all platforms now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use the VerifyNameForCreate method?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you have deleted this in other case, but not this one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's safe to remove them everywhere now that I'm no longer using the RuntimeHelpers.CleanupCode method?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It think so. It is also in WaitHandle and a few FCalls - it can be removed there as well.

@ViktorHofer
Copy link
Copy Markdown
Member Author

@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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Should this rather be Interop.Errors.ERROR_FILENAME_EXCED_RANGE?

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 27, 2017

@dotnet-bot test Windows_NT x64 corefx_baseline
@dotnet-bot test Ubuntu x64 corefx_baseline

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 27, 2017

should we merge that for now

ok. (once the corefx legs are green)

@ViktorHofer
Copy link
Copy Markdown
Member Author

the output from the corefx legs is unfortunately unusable :(

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 27, 2017

The corefx legs are failing with: 'System.Runtime.Intrinsics.X86.Avx.Insert(System.Runtime.Intrinsics.Vector256, System.Single*, System.Byte)' does not exist in the implementation

@fiigii Was it intentional that you have deleted byte index from several Avx.Insert overloads in your change #14164? If not, could you please submit PR to fix it?

@fiigii
Copy link
Copy Markdown

fiigii commented Sep 27, 2017

@jkotas Sorry, my bad. It was incautiously deleted by regexp.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 27, 2017

@ViktorHofer #14231 should fix the corefx break. We should retry after it goes in.

@ViktorHofer
Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

@ViktorHofer
Copy link
Copy Markdown
Member Author

@dotnet-bot test Windows_NT x64 corefx_baseline
@dotnet-bot test Ubuntu x64 corefx_baseline

@ViktorHofer
Copy link
Copy Markdown
Member Author

Failing legs are unrelated to my changes... Some FileSystemWatcher tests are failing

@ViktorHofer
Copy link
Copy Markdown
Member Author

@dotnet-bot test Ubuntu x64 corefx_baseline
@dotnet-bot test Ubuntu x64 Formatting

@ViktorHofer
Copy link
Copy Markdown
Member Author

Maybe the errors are related. I need to check...

System.IO.Tests.FileSystemWatcherTests_netstandard17.EndInit_ResumesPausedEnableRaisingEvents
System.IO.Tests.FileSystemWatcherTests_netstandard17.EndInit_ResumesPausedEnableRaisingEvents(setBeforeBeginInit: True)
System.IO.Tests.FileSystemWatcherTests_netstandard17.EndInit_ResumesPausedEnableRaisingEvents(setBeforeBeginInit: False)
System.IO.Tests.File_Create_Tests.FileSystemWatcher_File_Create

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 28, 2017

The FileSystemWatcher failures are #14154

@ViktorHofer
Copy link
Copy Markdown
Member Author

@dotnet-bot test Ubuntu x64 corefx_baseline

@ViktorHofer
Copy link
Copy Markdown
Member Author

@dotnet-bot test Ubuntu x64 Checked Build and Test (Jit - CoreFx)

@ViktorHofer ViktorHofer merged commit 97e0093 into dotnet:master Oct 2, 2017
@ViktorHofer ViktorHofer deleted the MutexCodeCleanup branch October 2, 2017 19:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants