Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JohnJackal opened this issue Oct 25, 2024 · 0 comments

Comments

@JohnJackal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant