Commit bd765420 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Collapse two functions for clarity

parent 2c90d787
......@@ -127,32 +127,6 @@ sock_test(int fd)
need_test = 0;
}
/*--------------------------------------------------------------------
* Called once the workerthread gets hold of the session, to fix up
* any socket options that need it.
*/
static void
vca_prep(const struct sess *sp)
{
if (need_test)
sock_test(sp->fd);
if (need_linger)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER,
&linger, sizeof linger));
#ifdef SO_SNDTIMEO_WORKS
if (need_sndtimeo)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO,
&tv_sndtimeo, sizeof tv_sndtimeo));
#endif
#ifdef SO_RCVTIMEO_WORKS
if (need_rcvtimeo)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO,
&tv_rcvtimeo, sizeof tv_rcvtimeo));
#endif
}
/*--------------------------------------------------------------------
* If accept(2)'ing fails, we pace ourselves to relive any resource
* shortage if possible.
......@@ -285,7 +259,22 @@ VCA_SetupSess(struct worker *w)
sp->sockaddrlen = wa->acceptaddrlen;
vca_pace_good();
w->stats.sess_conn++;
vca_prep(sp);
if (need_test)
sock_test(sp->fd);
if (need_linger)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER,
&linger, sizeof linger));
#ifdef SO_SNDTIMEO_WORKS
if (need_sndtimeo)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO,
&tv_sndtimeo, sizeof tv_sndtimeo));
#endif
#ifdef SO_RCVTIMEO_WORKS
if (need_rcvtimeo)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO,
&tv_rcvtimeo, sizeof tv_rcvtimeo));
#endif
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment