summaryrefslogtreecommitdiff
path: root/main/manager.c
diff options
context:
space:
mode:
authorMatthew Nicholson <mnicholson@digium.com>2010-06-30 18:48:21 +0000
committerMatthew Nicholson <mnicholson@digium.com>2010-06-30 18:48:21 +0000
commit2dc3b3a8c2a4d66a97a94517fa61c248b4c16056 (patch)
treedb20f340738f810aa5dfdaceaa264c033f81468a /main/manager.c
parent6012128a4868d44d1d15a586aed9a80d318a182b (diff)
Set TCP_NODELAY on manager TCP sockets to prevent delays on outgoing packets. This regression was introduced in r48338.
AST-359 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@273270 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/manager.c')
-rw-r--r--main/manager.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/main/manager.c b/main/manager.c
index 9c9c5aa84..54d9760d2 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -4604,11 +4604,26 @@ static void *session_do(void *data)
};
int flags;
int res;
+ struct protoent *p;
if (session == NULL) {
goto done;
}
+ /* XXX here we set TCP_NODELAY on the socket to disable Nagle's
+ * algorithm. A better solution might be to buffer outgoing messages
+ * until they are complete then write them to the socket in one burst
+ * rather than sending them in bits and pieces. */
+ p = getprotobyname("tcp");
+ if (p) {
+ int arg = 1;
+ if( setsockopt(ser->fd, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) {
+ ast_log(LOG_WARNING, "Failed to set manager tcp connection to TCP_NODELAY mode: %s\nSome manager actions may be slow to respond.\n", strerror(errno));
+ }
+ } else {
+ ast_log(LOG_WARNING, "Failed to set manager tcp connection to TCP_NODELAY, getprotobyname(\"tcp\") failed\nSome manager actions may be slow to respond.\n");
+ }
+
flags = fcntl(ser->fd, F_GETFL);
if (!block_sockets) { /* make sure socket is non-blocking */
flags |= O_NONBLOCK;