Skip to content

Bugfix: openChannelAndBind() will return RESULT_OK while the opening operation actually fails #134

@JohnJackal

Description

@JohnJackal

The current code in the master branch.

u_result AsyncTransceiver::openChannelAndBind(IChannel* channel)
{
    if (!channel) return RESULT_INVALID_DATA;

    unbindAndClose();
	u_result ans = RESULT_OK;
	do 
	{
	    rp::hal::AutoLocker l(_opLocker);

            // try to open the channel ...
            Result<nullptr_t> ans = SL_RESULT_OK;

            if (!channel->open()) {
                ans= RESULT_OPERATION_FAIL;
                break;
            }


            // force a flush to clear any pending data
            channel->flush();

	    _dataEvt.set(false);

	    _isWorking = true;
            _workingFlag = 0;
            _bindedChannel = channel;


	    _decoderThread = CLASS_THREAD(AsyncTransceiver, _proc_decoderThread);
	    _rxThread = CLASS_THREAD(AsyncTransceiver, _proc_rxThread);

        


	} while (0);

	return ans;
}

You defined two ans in the function, which causes chaos. The one defiend in the inner scope should be deleted, so that the bug would be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions