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

sip_transport: tcp: Notify app if unable to keep decoding stream #3961

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pespin
Copy link
Contributor

@pespin pespin commented May 14, 2024

If pjsip_find_msg() starts failing because there's some missing header like Content-Length, log the issue and shutdown the transport to avoid staying in a broken state.

@CLAassistant
Copy link

CLAassistant commented May 14, 2024

CLA assistant check
All committers have signed the CLA.

@trengginas
Copy link
Member

Shouldn't calling the callback be enough? The user will be notified and shutdown the transport if needed.

@pespin
Copy link
Contributor Author

pespin commented May 17, 2024

@trengginas I'm fine with your proposal. TBH I care more about the "logging" side of things to start with, to at least report that the stream fails to parse and becomes broken. Before that, there was no message at all, everything happened silently.

I'll submit a new version dropping the transport shutdown.

"Shutting down transport %s",
rdata->tp_info.transport->obj_name));

pjsip_transport_shutdown(rdata->tp_info.transport);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trengginas I added the transport_shutdown in the new extended code path because I saw in the other code path it was already being done. So not sure if then this path was wrong then?
Let me know whether you want to merge as it, drop the pjsip_transport_shutdown() from the new path or from both paths.

@nanangizz
Copy link
Member

I also vote for callback approach, shutting down transport may not be preferred in some cases so IMO better leave it for app to decide.

If pjsip_find_msg() starts failing because there's some missing header
like Content-Length, log the issue and notify the app about the invalid
message. Ideally the app should shutdown the transport to avoid
staying in a broken state.
@pespin
Copy link
Contributor Author

pespin commented May 28, 2024

I just noticed I actually forgot to update the commit description. I did it now, so I think it's now ready to be merged.

@pespin pespin changed the title sip_transport: tcp: shutdown transport if unable to keep decoding stream sip_transport: tcp: Notify app if unable to keep decoding stream May 28, 2024
@nanangizz
Copy link
Member

Hmm.. honestly the flow resturcturing make me nervous about possibility of bug or major behavior change.

@pespin
Copy link
Contributor Author

pespin commented May 29, 2024

@nanangizz it's just a matter of looking at pjsip_find_msg() and seeing the error codes returned in each scenario, and act on them.

The whole "if (msg_status != PJ_SUCCESS) {" path is transformed in the first case so we get rid of a whole indentation level.

Then, the other msg_status are further discriminated. I'm keeping the old code path (the one returning PJSIP_EPARTIALMSG) the same. I'm simply extending the other error codes to handle them, since they were ignored in the past.

@nanangizz
Copy link
Member

@nanangizz it's just a matter of looking at pjsip_find_msg() and seeing the error codes returned in each scenario, and act on them.

Originally non-success cases are evaluated based on remaining_len instead of error codes. To me this is not "just a matter of ...", it definitely needs a very careful check to make sure no behavior change is introduced. Note that this code is part of the core of the lib and have been used and tested for a long time. This is what makes me nervous.

The whole "if (msg_status != PJ_SUCCESS) {" path is transformed in the first case so we get rid of a whole indentation level.

Indentation is not a very strong reason to modify the flow, the code is only few lines and not that hard to read. CMIIW the new proposed feature in this PR seems to be able to be inserted with much less risk and easier to review :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants