Bug 837033

Summary: Squid should set CLOEXEC on opened FDs
Product: Red Hat Enterprise Linux 6 Reporter: Julio Entrena Perez <jentrena>
Component: squidAssignee: LuboŇ° Uhliarik <luhliari>
Status: CLOSED WONTFIX QA Contact: Martin Frodl <mfrodl>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: cww, dkutalek, jentrena, jkejda, mfrodl, optak, ovasik, prc, thozza
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1303057 (view as bug list) Environment:
Last Closed: 2016-07-28 19:37:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 840699, 1172231, 1269194, 1269889, 1303057    

Description Julio Entrena Perez 2012-07-02 14:51:52 UTC
Description of problem:
Squid doesn't seem to use CLOEXEC flag on opened file descriptors.
Child processes created for url rewriters execute 32k+ close() syscalls after the clone() call and before the execvp() call.
In squid-3.1.10/src/ipc.cc:

240     if (pid > 0) {              /* parent */
241         /* close shared socket with child */
[...] parent code
296     }
298     /* child */
[...] child code.
      A bit later:
381     /* Make sure all other filedescriptors are closed */
382     for (x = 3; x < SQUID_MAXFD; x++)
383         close(x);

32k+ close() calls in each child process take a long time ([12-56] seconds) in Xen PV guests.
Squid re-creates all the url rewriter child processes even for a 'reload' action.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Install Squid in a RHEL6 Xen PV guest running in a RHEL5 Xen host.
2. Configure an external url rewriter and a pool of several processes:
url_rewrite_program /usr/local/bin/my_custom_url_rewriter
url_rewrite_children 24
3. Issue a 'service squid reload'.
Actual results:
Squid child processes take a long time to execute the 32k+ * 24 close() calls.
Browsing the Internet from clients configured to use the Squid proxy becomes unavailable for up to one minute.
Configuration changes can not be applied during work hours.

Expected results:
Squid creates file descriptors using O_CLOEXEC.
Squid doesn't need to attempt to close 32k+ FDs in each child process.
'service squid reload' completes quickly even in a Xen PV guest.

Additional info:
syscalls in a Xen PV guest perform slower than in HVM guests or bare metal, which amplifies the impact of poor FD handling in Squid child processes.

Comment 7 RHEL Program Management 2013-10-14 00:35:01 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.