[svn-commits] mnicholson: trunk r273270 - /trunk/main/manager.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 30 13:48:24 CDT 2010


Author: mnicholson
Date: Wed Jun 30 13:48:21 2010
New Revision: 273270

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=273270
Log:
Set TCP_NODELAY on manager TCP sockets to prevent delays on outgoing packets.

Modified:
    trunk/main/manager.c

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=273270&r1=273269&r2=273270
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Jun 30 13:48:21 2010
@@ -4604,10 +4604,25 @@
 	};
 	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 */




More information about the svn-commits mailing list