Problem with servant deletion.

szyk100 szyk100 at o2.pl
Mon Mar 28 20:35:32 BST 2016


Hello
I try to write simple chat program using Corba (Omniorb implementation). I have problem with server side servant deletion (client side servant is now deleted as expected).

I have 2 main servants: Room (server side) and User (client side). Communication between them ensures RoomController (server side servant). That servant cause the problem. 

Lets follow it's life cycle:

1. Creation RoomController:
TCzat::RoomController_ptr RoomImp::joinUser(::TCzat::User_ptr aUser)
{
    // add user to internal list
    mUsers.append(::TCzat::User::_duplicate(aUser));

    // call all users to add user to they list
    for(int i = 0; i < mUsers.length(); ++i)
        mUsers[i]->addUser(aUser);

    TCzat::Room_var lRoom = _this();
    RoomControllerImp* lController = new RoomControllerImp(lRoom, mPoa);
    PortableServer::ObjectId_var lControllerID = mPoa->activate_object(lController);

    TCzat::RoomController_ptr lControllerPtr = lController->_this();
    return lControllerPtr;
}


Returned pointer is stored in WinMainC class (client main window).


2. Usage of RoomController:
void WinMainC::returnPressed()
{
    if(!CORBA::is_nil(mRoomController)) mRoomController->message(mUser->mName.toStdWString().c_str(), mRoom->name(), ui->mMessage->text().toStdWString().c_str());
    ui->mMessage->setText("");
}


3. Deletion of RoomController:

void WinMainC::disconnectFromServer()
{
    if(!CORBA::is_nil(mRoomController))
    {
        if(mUser)
        {
            TCzat::User_var lUser = mUser->_this();
            mRoomController->removeUser(lUser);
        }
        mRoomController->destroy();
//        CORBA::release(mRoomController);
        mRoomController = TCzat::RoomController::_nil();
    }

    if(mUser)
    {
        mUser->destroy();
        mUser = 0;
    }
}

Where RoomControllerImp::destroy() is as follow:

void RoomControllerImp::destroy()
{
    PortableServer::ObjectId_var lId = mPoa->servant_to_id(this);
    mPoa->deactivate_object(lId);
}

Above should cause call ~RoomConroller() but it doesn't! It is important because in ~RoomConroller() I delete other objects:
    CORBA::release(mRoom);
    CORBA::release(mPoa);
With out that calling I get server error when I try connect next time.

I attach sources of my chat program (client and server) in hope you can compile and run it and investigate why it does not delete RoomController.

with best wishes
Szyk Cech

 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tchat.zip
Type: application/zip
Size: 33599 bytes
Desc: not available
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20160328/30df2537/attachment-0001.zip>


More information about the omniORB-list mailing list