Metaswitch/sprout — pull request #835 by bossmc (2014-10-28 16:19:31+00:00)
Title: Reviewer Mike - Don't tight-loop on ReqURI port number

We inject the message in SCSCFNonLocal into port 5058, so that gets passed into the Sproutlet-choosing method (https://github.com/Metaswitch/sprout/blob/20d1ed934828e34d804eafed42f15a8145b52b94/sprout/sproutletproxy.cpp#L476) and we choose a Sproutlet based on that port number. That's reasonable - the rule is basically "if you receive a message on the I-CSCF port, do I-CSCF processing on it; if you receive a message on the S-CSCF port, do S-CSCF processing on it; etc". So even if a message comes in where the SIP doesn't reference us in any way, we should still process it based on the port it came in on.

That means https://github.com/Metaswitch/sprout/blob/20d1ed934828e34d804eafed42f15a8145b52b94/sprout/sproutletproxy.cpp#L160 is where the bug is - "port" should represent the port that this message was received on, or, for the internally-processed messages from https://github.com/Metaswitch/sprout/blob/20d1ed934828e34d804eafed42f15a8145b52b94/sprout/sproutletproxy.cpp#L715, the port that this "should" have come in on. Instead it represents whatever port is in the Request-URI, even if that doesn't point to us. That's wrong.

This fixes it. Unit tested in this pull request.