From 828cf2632bd05d483dca0a95dac18519f9be9158 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sun, 22 Jan 2012 17:33:08 +0800 Subject: [PATCH] sendfile: Add sysctl to disable the usage of the asynchronized pru_send --- sys/kern/uipc_socket.c | 4 ++++ sys/kern/uipc_syscalls.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 1bd2c41f13..e11474f156 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -142,6 +142,10 @@ int use_soaccept_pred_fast = 1; SYSCTL_INT(_kern_ipc, OID_AUTO, soaccept_pred_fast, CTLFLAG_RW, &use_soaccept_pred_fast, 0, "Fast socket accept predication"); +int use_sendfile_async = 1; +SYSCTL_INT(_kern_ipc, OID_AUTO, sendfile_async, CTLFLAG_RW, + &use_sendfile_async, 0, "sendfile uses asynchronized pru_send"); + /* * Socket operation routines. * These routines are called by the routines in diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 443252d356..f02d4046e2 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -85,6 +85,7 @@ #endif /* SCTP */ extern int use_soaccept_pred_fast; +extern int use_sendfile_async; /* * System call interface to the socket abstraction. @@ -1801,7 +1802,10 @@ retry_space: } goto retry_space; } - error = so_pru_senda(so, 0, m, NULL, NULL, td); + if (use_sendfile_async) + error = so_pru_senda(so, 0, m, NULL, NULL, td); + else + error = so_pru_send(so, 0, m, NULL, NULL, td); crit_exit(); if (error) { ssb_unlock(&so->so_snd); @@ -1810,7 +1814,10 @@ retry_space: } if (mheader != NULL) { *sbytes += mheader->m_pkthdr.len; - error = so_pru_senda(so, 0, mheader, NULL, NULL, td); + if (use_sendfile_async) + error = so_pru_senda(so, 0, mheader, NULL, NULL, td); + else + error = so_pru_send(so, 0, mheader, NULL, NULL, td); mheader = NULL; } ssb_unlock(&so->so_snd); -- 2.41.0