Mercurial > hg > nginx
comparison src/core/ngx_connection.c @ 7007:ed1101bbf19f
Introduced ngx_tcp_nodelay().
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 26 May 2017 22:52:48 +0300 |
parents | 426828549afc |
children | ecb5cd305b06 |
comparison
equal
deleted
inserted
replaced
7006:9552758a786e | 7007:ed1101bbf19f |
---|---|
1344 return NGX_OK; | 1344 return NGX_OK; |
1345 } | 1345 } |
1346 | 1346 |
1347 | 1347 |
1348 ngx_int_t | 1348 ngx_int_t |
1349 ngx_tcp_nodelay(ngx_connection_t *c) | |
1350 { | |
1351 int tcp_nodelay; | |
1352 | |
1353 if (c->tcp_nodelay != NGX_TCP_NODELAY_UNSET) { | |
1354 return NGX_OK; | |
1355 } | |
1356 | |
1357 ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0, "tcp_nodelay"); | |
1358 | |
1359 tcp_nodelay = 1; | |
1360 | |
1361 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
1362 (const void *) &tcp_nodelay, sizeof(int)) | |
1363 == -1) | |
1364 { | |
1365 #if (NGX_SOLARIS) | |
1366 if (c->log_error == NGX_ERROR_INFO) { | |
1367 | |
1368 /* Solaris returns EINVAL if a socket has been shut down */ | |
1369 c->log_error = NGX_ERROR_IGNORE_EINVAL; | |
1370 | |
1371 ngx_connection_error(c, ngx_socket_errno, | |
1372 "setsockopt(TCP_NODELAY) failed"); | |
1373 | |
1374 c->log_error = NGX_ERROR_INFO; | |
1375 | |
1376 return NGX_ERROR; | |
1377 } | |
1378 #endif | |
1379 | |
1380 ngx_connection_error(c, ngx_socket_errno, | |
1381 "setsockopt(TCP_NODELAY) failed"); | |
1382 return NGX_ERROR; | |
1383 } | |
1384 | |
1385 c->tcp_nodelay = NGX_TCP_NODELAY_SET; | |
1386 | |
1387 return NGX_OK; | |
1388 } | |
1389 | |
1390 | |
1391 ngx_int_t | |
1349 ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text) | 1392 ngx_connection_error(ngx_connection_t *c, ngx_err_t err, char *text) |
1350 { | 1393 { |
1351 ngx_uint_t level; | 1394 ngx_uint_t level; |
1352 | 1395 |
1353 /* Winsock may return NGX_ECONNABORTED instead of NGX_ECONNRESET */ | 1396 /* Winsock may return NGX_ECONNABORTED instead of NGX_ECONNRESET */ |