Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition when connecting to DicomService quickly after start up #1398

Closed
CeeJayCee opened this issue Jun 14, 2022 · 1 comment · Fixed by #1399
Closed

Race condition when connecting to DicomService quickly after start up #1398

CeeJayCee opened this issue Jun 14, 2022 · 1 comment · Fixed by #1399
Labels

Comments

@CeeJayCee
Copy link
Contributor

Describe the bug

We have seen an exception being thrown when connecting to a DicomServer quickly after it is started.

In our case, we are starting a DicomServer that implements DicomService, IDicomServiceProvider, IDicomCStoreProvider and IDicomCEchoProvider.

Immediately after creation we use echoscu.exe to check the service is up. Frequently we get the following exception:

Exception listening for DICOM services, NullReferenceException {TargetSite=T CreateScp(FellowOakDicom.Network.INetworkStream), Message="Object reference not set to an instance of an object.", Data=[], InnerException=null, HelpLink=null, Source="fo-dicom.core", HResult=-2147467261, StackTrace="   at FellowOakDicom.Network.DicomServer`1.CreateScp(INetworkStream stream)\n   at FellowOakDicom.Network.DicomServer`1.ListenForConnectionsAsync()"}

Our debugging has shown this is caused by DicomService (line 247) trying to access ServiceScope.ServiceProvider. ServiceScope has not yet been set by DicomServerFactory::Create() before StartAsync() is called on the server.

To Reproduce
As above.

Expected behavior
An exception should not be thrown.

Screenshots or test DICOM files
If applicable, add screenshots or test DICOM files to help explain your problem.

Environment
Fellow Oak DICOM version: 5.0.3
OS: Docker container running mcr.microsoft.com/dotnet/aspnet:6.0-alpine
Platform: .NET 6.0

@CeeJayCee
Copy link
Contributor Author

I have proposed a fix in #1399

mrbean-bremen pushed a commit that referenced this issue Jun 22, 2022
* move assignment of ServiceScope to before call to StartAsync(), otherwise a client can connect between these calls and the connection will fail
* fixes #1398
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant