John-Chan / protobuf-remote

Automatically exported from code.google.com/p/protobuf-remote
0 stars 0 forks source link

RpcMessage message life time problem in SocketRpcChannel::Run() #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
with sample code:
 int SampleServiceProxy::GetSquare(  int p0  ) { 
        m_parameters.Clear(); 
        m_parameters.Add().SetInt (p0);
        PendingCall* call = m_client->Call(m_serviceName, "GetSquare", m_parameters); 
        call->Wait(); 
        // I've added sync code to PendingCall
        //void PendingCall::Wait() { m_sync.wait();}
        //void PendingCall::SetResult(const RpcMessage::Parameter* parameter) {
        //  ...
        //  m_sync.set();
        //}

        int result = call->GetResult()->GetInt(); 
        m_client->ReleaseCall(call); 
        return result; 
    }

What is the expected output? What do you see instead?
I've called proxy->GetSquare(10);
result value is Garbage Value, Not 100

What version of the product are you using? On what operating system?
    0.1.1

Please provide any additional information below.

I have debugged protobuf-remote.

void SocketRpcChannel::Run()
{

        while (isReceiveReady && !isTerminated)
        {
            ...
                    if (isReceiving)
                    {
                        RpcMessage message; 
                        // THIS VALUE HAS LOCAL SCOPE LIFE TIME.
                        // SO WHEN I CALL Parameter->GetResult()->GetInt(), somtimes message disappered
                        //
                        //Parameter::Parameter(const RpcMessage::Parameter& message)
                        //  : m_message(message) {}

                        bool isOk = message.ParseFromArray(&receiveBuffer[0], receiveSize);
                        assert(isOk);
                        m_controller->Receive(message);

                        isReceiving = false;
                        receiveSize = sizeof(int);
                        receivePos = 0;
                    }
        }
    }

Original issue reported on code.google.com by object...@gmail.com on 21 Apr 2011 at 2:13

GoogleCodeExporter commented 8 years ago

Original comment by niallr...@gmail.com on 25 Apr 2011 at 7:24

GoogleCodeExporter commented 8 years ago
Fixed the issue and added the missing synchronization too. Thanks!

Original comment by niallr...@gmail.com on 25 Apr 2011 at 9:34

GoogleCodeExporter commented 8 years ago
Fix is in protobuf-remote-cpp-0.1.2

Original comment by niallr...@gmail.com on 25 Apr 2011 at 9:34