diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-06-29 15:52:47 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-06-29 15:52:47 +0300 |
commit | 499a8f9ac87765252dc3656c7aac900825475a51 (patch) | |
tree | 5667d1128e4d736ffc110e11444f789694b88e94 /src/nxt_conn.c | |
parent | 52f79c3e531ec64ddd81e2467e0081616e71a7c8 (diff) | |
download | unit-499a8f9ac87765252dc3656c7aac900825475a51.tar.gz unit-499a8f9ac87765252dc3656c7aac900825475a51.tar.bz2 |
Using static and constant linger structure.
Diffstat (limited to 'src/nxt_conn.c')
-rw-r--r-- | src/nxt_conn.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/nxt_conn.c b/src/nxt_conn.c index 0cc052e8..5d84cbb4 100644 --- a/src/nxt_conn.c +++ b/src/nxt_conn.c @@ -96,10 +96,13 @@ nxt_conn_create(nxt_mp_t *mp, nxt_task_t *task) void nxt_conn_io_shutdown(nxt_task_t *task, void *obj, void *data) { - int ret; - socklen_t len; - nxt_conn_t *c; - struct linger linger; + int ret; + nxt_conn_t *c; + + static const struct linger linger_off = { + .l_onoff = 1, + .l_linger = 0, + }; c = obj; @@ -111,11 +114,8 @@ nxt_conn_io_shutdown(nxt_task_t *task, void *obj, void *data) * releases kernel memory associated with socket. * This also causes sending TCP/IP RST to a peer. */ - linger.l_onoff = 1; - linger.l_linger = 0; - len = sizeof(struct linger); - - ret = setsockopt(c->socket.fd, SOL_SOCKET, SO_LINGER, &linger, len); + ret = setsockopt(c->socket.fd, SOL_SOCKET, SO_LINGER, &linger_off, + sizeof(struct linger)); if (nxt_slow_path(ret != 0)) { nxt_log(task, NXT_LOG_CRIT, "setsockopt(%d, SO_LINGER) failed %E", |