mirror of
https://github.com/nginx/nginx.git
synced 2026-10-22 12:01:09 +00:00
Events: support for SO_SNDBUF on outbound peer connections
ngx_event_connect_peer() honors SO_RCVBUF via pc->rcvbuf but had no equivalent for SO_SNDBUF. This adds pc->sndbuf and the matching setsockopt() call, mirroring the existing SO_RCVBUF path. Both setsockopt() calls are made non-fatal. Existing callers leaving sndbuf at 0 retain prior behavior, since setsockopt() is only invoked when the field is non-zero. These fields are consumed by various proxying modules in follow-up commits.
This commit is contained in:
parent
a277069b14
commit
3fe9fc4573
2 changed files with 16 additions and 3 deletions
|
|
@ -65,11 +65,23 @@ ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
|||
|
||||
if (pc->rcvbuf) {
|
||||
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF,
|
||||
(const void *) &pc->rcvbuf, sizeof(int)) == -1)
|
||||
(const void *) &pc->rcvbuf, sizeof(int))
|
||||
== -1)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
|
||||
"setsockopt(SO_RCVBUF) failed");
|
||||
goto failed;
|
||||
"setsockopt(SO_RCVBUF, %d) failed, ignored",
|
||||
pc->rcvbuf);
|
||||
}
|
||||
}
|
||||
|
||||
if (pc->sndbuf) {
|
||||
if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
|
||||
(const void *) &pc->sndbuf, sizeof(int))
|
||||
== -1)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
|
||||
"setsockopt(SO_SNDBUF, %d) failed, ignored",
|
||||
pc->sndbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct ngx_peer_connection_s {
|
|||
|
||||
int type;
|
||||
int rcvbuf;
|
||||
int sndbuf;
|
||||
|
||||
ngx_log_t *log;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue