Re: STA cannot prevent multiple client calls accessing at the same time??
From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 02/15/05
- Next message: Alexander Nickolov: "Re: Multiple Sinks"
- Previous message: Igor Tandetnik: "Re: How to manually merge proxy/stub code in ATL COM dll?"
- In reply to: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Next in thread: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Reply: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Feb 2005 11:01:45 -0800
Your call stack clearly shows that C yields. Check what statement
yields. Once that sinks in, you can use your choice of boolean
flags appropriate for your code. Another approach would be
to flag the deletion request and do nothing further if you are
called reentrantly (using another flag set at the beginning of A
and cleared at its end). You can check the deletion flag at
each iteration within C and abort it when set, then carry out
the deletion at the end of A. Just another idea. With some
experience with reentrancy you should be able to generate
these yourself...
-- ===================================== Alexander Nickolov Microsoft MVP [VC], MCSD email: agnickolov@mvps.org MVP VC FAQ: http://www.mvps.org/vcfaq ===================================== "Angela Yan" <yanyan9@hotmail.com> wrote in message news:O05cUnwEFHA.3276@TK2MSFTNGP10.phx.gbl... > Hi, > > The possible solution, is it the 5th Feb reply? I've used > "GetCurrentThreadID()" to print out the Thread ID while A() or B() is > being called. And they turn out to be the same. For the time stamp, it has > been confirmed that A() is called first, then followed by B() when A() has > not finished its execution. > > For 4th Feb reply, the C method does not yield. It is just a simple loop > to compare the link list elements. And I can't check for NULL condition of > the linkList, because after I 'delete' the LinkList in B(), all the > contents in the link list will be 0xcdcdcdcd or 0xdddddddd. Currently I > can even repro the whole thing such that B( ) comes in before C( ) gets > call. > > > Call Stack: > > C()in > B()out > B()in > A()in > > So I assume it has nothing to do with the linklist. In this case the > program will not crash but still the calling sequence is not a desired > behaviour. > > Looking forward to your reply. > > Thanks. > Angela > > > "Alexander Nickolov" <agnickolov@mvps.org> wrote in message > news:%230w1wbsEFHA.3200@TK2MSFTNGP10.phx.gbl... >> If you refer to my very first reply, that's exactly what I told >> you - you have reentrancy. I even gave you a possible solution >> in one of the later replies. You haven't done anything about it >> yet I assume. >> >> -- >> ===================================== >> Alexander Nickolov >> Microsoft MVP [VC], MCSD >> email: agnickolov@mvps.org >> MVP VC FAQ: http://www.mvps.org/vcfaq >> ===================================== >> >> "Angela Yan" <yanyan9@hotmail.com> wrote in message >> news:O%23PGfGnEFHA.3536@TK2MSFTNGP15.phx.gbl... >>> Hi, >>> >>> Sorry for replying so late. Just came back from holiday... :p >>> >>> I've tried using "GetCurrentThreadId" in A( ) and B( ). They return the >>> same value. But I am very sure that A( ) will not call B( ). In fact, in >>> the whole dll, there is no B( ) call is made. B( ) is only called by the >>> client. And I don't use windows message loop in the dll, only the Client >>> uses it. Neither any thread message call is in the dll. >>> >>> About the call stack, I can see A( ) is being called, then some Cleint >>> calls, then B( ) is called. >>> >>> B( ) >>> client call1 >>> client call2 >>> client call3 >>> client call4 >>> client call5 >>> .. >>> .. >>> .. >>> C( ) >>> A( ) >>> client call100 >>> client call101 >>> client call102 >>> .. >>> .. >>> .. >>> >>> Please help. >>> >>> Thank you and >>> >>> Happy Chinese new year!!! ^_^ >>> >>> Angela >>> >>> >>> "Rossen Tzonev" <rossenbg@hotmail.com> wrote in message >>> news:opslo421ol8xxq1h@rossenbg-homepc... >>>> >>>> I will add to Alexander suggestions. This is also possible: >>>> >>>> 1. "GetCurrentThreadId" returns the same value when "A" and "B" are >>>> ed - variant 1. Then I can bet you are calling "B" somewhere during >>>> the call to "A". Because your LOG shows that you are in "A", but "B" >>>> is being called >>>> >>>> 2. "GetCurrentThreadId" returns the same value when "A" and "B" are >>>> ed - variant 2. If somewhere durring "A" execution you are calling >>>> something like "AtlWaitWithMessageLoop" or any code which gets current >>>> thread message in the message queue and dispatches it, then it is >>>> possible that "B" is called during "A" execution. That's because of >>>> COM rules for STA. STA has message loop and all COM calls to any >>>> methods in objects created in STA are done via COM private messages to >>>> the thread. >>>> >>>> 3. "A" and "B" are called from different threads. Then your problem is >>>> obvious. But this means that your code for creating the COM object is >>>> located not where it should be. >>>> >>>> Can you try to put breakpoint at the beginning and at the end of "A" >>>> and "B" and examine the call stack. If "B" is currently called and "A" >>>> is in the call stack then you have case (1). If "B" is called via the >>>> thread message loop code and after it there is a call to "A" in the >>>> stack then you have (2). >>>> >>>> >>>> On Fri, 4 Feb 2005 09:43:20 -0800, Alexander Nickolov >>>> <agnickolov@mvps.org> wrote: >>>> >>>>> Why don't you log the thread ID and time stamp in your traces >>>>> to be sure what's going on? If your client is misbehaving, there's >>>>> nothing for you to fix... >>>>> >>>> >>>> >>>> >>>> -- >>>> Rossen Tzonev >>>> Sofia, Bulgaria >>> >>> >> >> > >
- Next message: Alexander Nickolov: "Re: Multiple Sinks"
- Previous message: Igor Tandetnik: "Re: How to manually merge proxy/stub code in ATL COM dll?"
- In reply to: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Next in thread: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Reply: Angela Yan: "Re: STA cannot prevent multiple client calls accessing at the same time??"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|