]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 273270 via svnmerge from
authorMatthew Nicholson <mnicholson@digium.com>
Wed, 30 Jun 2010 18:50:12 +0000 (18:50 +0000)
committerMatthew Nicholson <mnicholson@digium.com>
Wed, 30 Jun 2010 18:50:12 +0000 (18:50 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
  r273270 | mnicholson | 2010-06-30 13:48:21 -0500 (Wed, 30 Jun 2010) | 2 lines

  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/branches/1.6.2@273271 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/manager.c

index 5bbeec0fca477b9d5ebf87721456e000ca0ab7a2..8502268e71f112f989794e490f4f6d18200b207a 100644 (file)
@@ -3210,10 +3210,25 @@ static void *session_do(void *data)
        struct mansession s = {.session = NULL, };
        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");
+       }
+
        session->writetimeout = 100;
        session->waiting_thread = AST_PTHREADT_NULL;