none
Race condition in CSExeCOMServer sample RRS feed

  • General discussion

  • I've been asked to extend an existing in-process OLE server (built in .Net) to support out-of-process.

    I've looked around, and started from CSExeCOMServer from All-in-one code samples. After studying the source code, I started to implement it: at first, everything seemed to work, but deeper testing showed an error: if you quickly create and release new instances of the components, I can easily get an error from the client ("RPC server is unavailable"): after some tracing, is seems that the server is still accepting requests after one thread has already posted the WM_QUIT message; in fact I can see one more instance created after the call to NativeMethod.PostThreadMessage within ExeCOMServer.Unlock.

    I've noticed there are no calls to CoAddRefServerProcessCoReleaseServerProcess, which should track, if I remember correctly, a per-process count; and when CoReleaseServerProcess reaches 0, COM itself should prevent the server from accepting new requests via a call to CoSuspendClassObjects

    Is this the way to go?

    I've tried to add these calls to ExeCOMServer.LockExeCOMServer.Unlock, but, while the resurt value from CoReleaseServerProcess reflects the actual instance count, it seems no call to CoSuspendClassObjects ever occurs.

    Is anyone else experiencing a similar problem?


    • Edited by rioka1 Wednesday, January 16, 2013 2:47 PM
    Wednesday, January 16, 2013 2:46 PM

All replies

  • Hi Rioka,

    No, I didn't.

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Friday, January 18, 2013 1:55 AM