Archived

This forum has been archived. Please start a new discussion on GitHub.

Callbacks

Hi,

I'm trying to get callbacks working with Ice 3.3.0 and have a problem. According to the code snippit in the Biddirectional Connections section describing the server side you have the following
void addClient(const Ice::Identity& ident,
               const Ice::Current& curr)
{
    CallbackPrx client =
        CallbackPrx::uncheckedCast(curr.con‑>createProxy(ident));
    client‑>notify();
}

Now when I try and modify the bidir sample server to make the callback in the addClient() method, the server makes the callback but never returns. The client seems to be deadlocked
void
CallbackSenderI::addClient(const Identity& ident, const Current& current)
{
    IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);

    cout << "adding client `" << _communicator->identityToString(ident) << "'"<< endl;

    CallbackReceiverPrx client = CallbackReceiverPrx::uncheckedCast(current.con->createProxy(ident));
    _clients.insert(client);

	[B]client->callback( 999 );[/B]
}

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    You need to increase the size of the server thread pool in the server. By default the size of the server thread pool is 1, and that single thread is currently busy handling the addClient() call which does not return since you make an nested invocation back to the client from within that method. Therefore there is no other thread available to handle the response from the client, which means the callback() call never returns.

    Run the server as follows and try again:
    server --Ice.ThreadPool.Server.Size=2
    
    Alternately you could invoke on callback() as oneway so it does not need to wait for a response.
  • Thanks, that sorted it.