mcmssupereditor / mdcm

Automatically exported from code.google.com/p/mdcm
0 stars 0 forks source link

OnReceiveAssociateRequest delegate can get called before the DicomClientCreatedDelegate #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Seems to be a thread racing condition, the suggested solution below removes
all trouble for me and gives reliable, repeatable behavior.

To reproduce;
1. Use svn mDCM to write:

var server = new DcmServer<FooServer>();

server.DicomClientCreatedDelegate += new DicomClientCreatedDelegate((s, c,
st) => {

c.OnAssociationRequest = doSomethingHandler;
c.OnFooRequest = ...;

};

server.Start();

2. Use any DICOM tool to query the server.
3. In a few percent of the connects, DicomClientCreatedDelegate will not
have been called before DcmNetworkBase has read a DcmAssosiateRequest from
the socket.
Line 119 in DcmServer.cs;
handler.InitializeService(client);
will fork a thread to read from the socket.
Line 122 will call the delegate;
OnDicomClientCreated(this, handler, client.Type);

Expected behavior:
Given that DicomClientCreatedDelegate is recommended to use to set your
handlers (is it?), I would expect it to be called before
OnReceiveAssociateRequest (and others) are called.

Actual behaviour:
When testing, in roughly 5% of the cases DicomClientCreatedDelegate will
not have been called before OnReceiveAssociateRequest gets called.

Suggested solution:
Move calling DicomClientCreatedDelegate a few lines up, so it gets called
before handler.InitializeService(client) which kicks of the listener thread.

I'm using .NET 3.5 SP1 on Windows XP SP3.

Original issue reported on code.google.com by lennart....@vgregion.se on 21 Sep 2009 at 9:08

GoogleCodeExporter commented 9 years ago
SVN 64 reorders the flow so that the OnDicomClientCreated delegate is called 
before
InitializeService.  I'll leave this issue open until it is determined that 
there are
no adverse side effects.

Original comment by colby.di...@gmail.com on 25 Sep 2009 at 5:14

GoogleCodeExporter commented 9 years ago
I've been running SVN r67 in production for many months and I have no longer 
had any 
trouble with this issue.

Original comment by lennart....@vgregion.se on 1 Jun 2010 at 9:02