fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/38610?usp=email )
Change subject: smpp: set TCP_NODELAY sockopt ......................................................................
smpp: set TCP_NODELAY sockopt
Change-Id: Ibfaaeaa6e21f621eb32b37b783e286e40859c915 Fixes: OS#5568 --- M src/libsmpputil/smpp_smsc.c M src/utils/smpp_mirror.c 2 files changed, 14 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/10/38610/1
diff --git a/src/libsmpputil/smpp_smsc.c b/src/libsmpputil/smpp_smsc.c index 34e24c5..786efa1 100644 --- a/src/libsmpputil/smpp_smsc.c +++ b/src/libsmpputil/smpp_smsc.c @@ -27,6 +27,7 @@
#include <sys/socket.h> #include <netinet/in.h> +#include <netinet/tcp.h>
#include <smpp34.h> #include <smpp34_structs.h> @@ -984,7 +985,7 @@ */ int smpp_smsc_start(struct smsc *smsc, const char *bind_addr, uint16_t port) { - int rc; + int rc, val;
LOGP(DSMPP, LOGL_NOTICE, "SMPP at %s %d\n", bind_addr ? bind_addr : "0.0.0.0", port ? port : SMPP_PORT); @@ -995,6 +996,11 @@ if (rc < 0) return rc;
+ val = 1; + rc = setsockopt(smsc->listen_ofd.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + if (rc < 0) + LOGP(DSMPP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); + /* store new address and port */ rc = smpp_smsc_conf(smsc, bind_addr, port ? port : SMPP_PORT); if (rc) diff --git a/src/utils/smpp_mirror.c b/src/utils/smpp_mirror.c index 340e94f..5df09e4 100644 --- a/src/utils/smpp_mirror.c +++ b/src/utils/smpp_mirror.c @@ -5,6 +5,7 @@ #include <string.h>
#include <netinet/in.h> +#include <netinet/tcp.h>
#include <smpp34.h> #include <smpp34_structs.h> @@ -241,7 +242,7 @@
static int smpp_esme_init(struct esme *esme, const char *host, uint16_t port) { - int rc; + int rc, val;
if (port == 0) port = SMPP_PORT; @@ -255,6 +256,11 @@ if (rc < 0) return rc;
+ val = 1; + rc = setsockopt(esme->wqueue.bfd.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + if (rc < 0) + LOGP(DSMPP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); + return bind_transceiver(esme); }