Results 1 to 2 of 2

Thread: Synchronous calls from AMI callback may lead to deadlock

  1. #1
    allro is offline Registered User
    Name: Alex Leiderman
    Organization: Cell2Bet
    Project: Management Server
    Join Date
    Jul 2008
    Posts
    10

    Synchronous calls from AMI callback may lead to deadlock

    Hi,

    Let's consider Client, Server1 and Server2 and following logical flow.

    1. Client calls asynchronously to function foo1 implemented by a servant deployed by Server1.
    2. Response/exception is received by Client's AMI_foo1 callback object.
    3. In ice_response/ice_exception implemented by AMI_foo1 we call synchronously to foo2 implemented by a servant deployed by Server2.

    Now, if Client runs this logic in a loop it may lead to a deadlock (deadlock's probability grows with a loop counter limit).
    Workaround:
    Client may call foo2 asynchronously (no deadlock for loop_counter_limit=50000 according to my tests).
    Please explain this behaviour.

    Environment:
    Ice version: 3.3.1
    System: Vista Premium 32bit
    Compiler: VS 2005
    Best Regards,
    --Alex

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,441
    Hi,

    Thread starvation is quite likely in the situation you've described. Keep in mind that a thread from the client thread pool reads the reply messages and dispatches AMI callbacks. If you make a nested synchronous invocation from within an AMI callback, there may not be any threads remaining in the client thread pool to read the reply for that synchronous invocation, thus causing a deadlock.

    Consequently, you must either increase the maximum size of your client thread pool to be sufficiently large enough to guarantee that such a deadlock never occurs, or avoid the use of nested synchronous invocations altogether. In general we recommend the latter approach.

    Hope that helps,
    Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Deadlock When server calls client via proxy
    By nlhaines in forum Help Center
    Replies: 2
    Last Post: 02-24-2011, 01:48 PM
  2. Replies: 1
    Last Post: 01-04-2010, 12:13 PM
  3. AMI calls and congestion
    By masti in forum Help Center
    Replies: 1
    Last Post: 03-16-2008, 09:26 PM
  4. Replies: 1
    Last Post: 07-30-2005, 07:12 AM
  5. Timeouts on AMI calls?
    By mathewm in forum Help Center
    Replies: 5
    Last Post: 09-11-2003, 10:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •