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

Avoid sending double CRLF keep alive on TCP socket shutdown #172

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gov/nist/javax/sip/parser/NioPipelineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ private boolean readMessageSipHeaderLines(InputStream inputStream, boolean isPre
crlfReceived = false;

try {
sipMessageListener.sendSingleCLRF();
sipMessageListener.sendSingleCRLF();
} catch (Exception e) {
logger.logError("A problem occured while trying to send a single CLRF in response to a double CLRF", e);
logger.logError("A problem occured while trying to send a single CRLF in response to a double CRLF", e);
}
} else {
crlfReceived = true;
Expand Down
4 changes: 2 additions & 2 deletions src/gov/nist/javax/sip/parser/PipelinedMsgParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,9 @@ public void run() {
isPreviousLineCRLF = false;

try {
sipMessageListener.sendSingleCLRF();
sipMessageListener.sendSingleCRLF();
} catch (Exception e) {
logger.logError("A problem occured while trying to send a single CLRF in response to a double CLRF", e);
logger.logError("A problem occured while trying to send a single CRLF in response to a double CRLF", e);
}
continue;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/gov/nist/javax/sip/parser/SIPMessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface SIPMessageListener extends ParseExceptionListener {
*/
public void processMessage(SIPMessage msg) throws Exception;

public void sendSingleCLRF() throws Exception;
public void sendSingleCRLF() throws Exception;
Copy link
Contributor

Choose a reason for hiding this comment

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

even though this seems like a clear typo, i'm concerned this would break backwords compatibility... 🤔

Maybe a default implementation here for the new one invoking the old one would help us get the best of both worlds...

@jaimecasero thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

this interface is not part of JAIN-SIP spec, and is not a boundary with the App. Is an internal API to allow IO layer to contact Parsing layer. If we change this interface, we will need to cover all the neccesary changes tin IO and parsing layer (XPipelineParsers,ConnOrientedMsgChannel,TCPMsgChannel,TLSMsgChannel...).

not sure is worth the change, but we could do it if the PR is comprehensive and tests results are ok

Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggests to handle in different PRs, as the original concern about double CRLF on TCP closing seems valid. We could potentially merge this asap, and then think about the typo...

}
/*
* $Log: not supported by cvs2svn $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,9 @@ public InetAddress getPeerPacketSourceAddress() {

/*
* (non-Javadoc)
* @see gov.nist.javax.sip.parser.SIPMessageListener#sendSingleCLRF()
* @see gov.nist.javax.sip.parser.SIPMessageListener#sendSingleCRLF()
*/
public void sendSingleCLRF() throws Exception {
public void sendSingleCRLF() throws Exception {
lastKeepAliveReceivedTime = System.currentTimeMillis();

if(mySock != null && !mySock.isClosed()) {
Expand Down