[svn-commits] kmoore: branch 11 r412748 - in /branches/11: ./ main/http.c main/manager.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Apr 21 11:13:45 CDT 2014
Author: kmoore
Date: Mon Apr 21 11:13:36 2014
New Revision: 412748
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=412748
Log:
HTTP: Add TCP_NODELAY to accepted connections
This adds the TCP_NODELAY option to accepted connections on the HTTP
server built into Asterisk. This option disables the Nagle algorithm
which controls queueing of outbound data and in some cases can cause
delays on receipt of response by the client due to how the Nagle
algorithm interacts with TCP delayed ACK. This option is already set on
all non-HTTP AMI connections and this change would cover standard HTTP
requests, manager HTTP connections, and ARI HTTP requests and
websockets in Asterisk 12+ along with any future use of the HTTP
server.
Review: https://reviewboard.asterisk.org/r/3466/
........
Merged revisions 412745 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/11/ (props changed)
branches/11/main/http.c
branches/11/main/manager.c
Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/11/main/http.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/http.c?view=diff&rev=412748&r1=412747&r2=412748
==============================================================================
--- branches/11/main/http.c (original)
+++ branches/11/main/http.c Mon Apr 21 11:13:36 2014
@@ -864,9 +864,25 @@
char *uri, *method;
enum ast_http_method http_method = AST_HTTP_UNKNOWN;
int remaining_headers;
+ struct protoent *p;
if (ast_atomic_fetchadd_int(&session_count, +1) >= session_limit) {
goto done;
+ }
+
+ /* here we set TCP_NODELAY on the socket to disable Nagle's algorithm.
+ * This is necessary to prevent delays (caused by buffering) as we
+ * write to the socket 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 TCP_NODELAY on HTTP connection: %s\n", strerror(errno));
+ ast_log(LOG_WARNING, "Some HTTP requests may be slow to respond.\n");
+ }
+ } else {
+ ast_log(LOG_WARNING, "Failed to set TCP_NODELAY on HTTP connection, getprotobyname(\"tcp\") failed\n");
+ ast_log(LOG_WARNING, "Some HTTP requests may be slow to respond.\n");
}
if (!fgets(buf, sizeof(buf), ser->f)) {
Modified: branches/11/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/manager.c?view=diff&rev=412748&r1=412747&r2=412748
==============================================================================
--- branches/11/main/manager.c (original)
+++ branches/11/main/manager.c Mon Apr 21 11:13:36 2014
@@ -5536,7 +5536,7 @@
/* here we set TCP_NODELAY on the socket to disable Nagle's algorithm.
* This is necessary to prevent delays (caused by buffering) as we
- * write to the socket in bits and peices. */
+ * write to the socket in bits and pieces. */
p = getprotobyname("tcp");
if (p) {
int arg = 1;
More information about the svn-commits
mailing list