qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Stitcher <astitc...@redhat.com>
Subject A small code puzzler (for me)
Date Fri, 07 Sep 2007 14:27:50 GMT
Just looking at current framing::Buffer usage in the broker.

A quick question about RecoveryManagerImpl.cpp:110

RecoverableMessage::shared_ptr
RecoveryManagerImpl::recoverMessage(framing::Buffer& buffer)
{
-->
    buffer.record();
<--
    //peek at type:
    Message::shared_ptr message(new Message());
    message->decodeHeader(buffer);
    return RecoverableMessage::shared_ptr(new
RecoverableMessageImpl(message, stagingThreshold));    
}

the line is - buffer.record();

I can't see anywhere else in the class that buffer.restore() is called
so I'm wondering why buffer.record() is called.

The only other place that uses record/restore in the broker is
AMQFrame::decode() and here they are used as a matched pair and I can
understand what's going on.

bool AMQFrame::decode(Buffer& buffer)
{    
    if(buffer.available() < 7)
        return false;
    buffer.record();

    uint8_t type = buffer.getOctet();
    channel = buffer.getShort();
    uint32_t size =  buffer.getLong();

    if(buffer.available() < size+1){
        buffer.restore();
        return false;
    }
    decodeBody(buffer, size, type);
    uint8_t end = buffer.getOctet();
    if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not
found");
    return true;
}

Now as the only .restore() in the broker is here and it's proceeded by
an unconditional buffer.record(), the buffer.record() in
RecoveryManagerImpl can't ever be used (or did I miss something, or
perhaps it's the start of something unfinished?)

Andrew



Mime
View raw message