Alex Rousskov [Sun, 2 May 2010 18:49:25 +0000 (12:49 -0600)]
Support a "shared listen" concept when multiple concurrent processes listen
on the same socket. The Coordinator is responsible for opening and caching
listening sockets, using comm_open_listener() parameters supplied by remote
callers. Sendmsg/recvmsg is used to shovel socket descriptors from Coordinator
to remote callers.
If SMP is not enabled, we call the local comm_open_listener() as usual but
return the results asynchronously to avoid making SMP/nonSMP special in
the caller code.
Alex Rousskov [Sun, 2 May 2010 01:37:34 +0000 (19:37 -0600)]
Added comm_import_opened() to update Comm state after getting a comm_open()
FD from another process. While both FDs point to the same kernel object, Squid
internal tables are local to each process and need to be maintained
separately.
Alex Rousskov [Sun, 2 May 2010 01:20:05 +0000 (19:20 -0600)]
Added whole-object comparison method so that IpAddress objects can be
properly sorted and used as std::map index.
Existing IpAddress comparison operators do not work well because they only
compare IP addresses (and incorrectly compare "none" and/or "any" IP
addresses).
Alex Rousskov [Sat, 1 May 2010 04:12:07 +0000 (22:12 -0600)]
Fixed IpAddress port printing for ports higher than 9999:
snprintf includes zero-terminator in its size limit, so 7
rather than 6 bytes are needed to snprintf a colon followed
by 5 port digits.
Whether the bug has any runtime effects in the current code,
I do not know, but I did waste a few hours following
misleading debugging output.
Alex Rousskov [Thu, 29 Apr 2010 22:35:11 +0000 (16:35 -0600)]
Implemented basic file descriptor exchange between IPC Strand and Coordinator.
Tested using on-disk file. The test hack will be removed.
Fixed Port code to allow it to receive more than one message with varying
msghdr buffer configurations. We must [re]allocate all msghdr buffers before
every read/recvmsg() call.
Alex Rousskov [Thu, 29 Apr 2010 20:12:03 +0000 (14:12 -0600)]
Switched from sendto/recvfrom to sendmsg/recvmsg for UDS I/O. Replaced
inlined sendto/recvfrom hacks with FD_WRITE/READ_METHOD-based code.
A common msghdr-based interface allows us to use the same API for regular
IPC messages and for future messages that pass socket descriptors. While
msghdr allows for complex vector-based scatter/gather I/O, the IPC code
limits complexity by using a single-element I/O vector and a control message
part dedicated to passing descriptors.
Added a temporary hack to block-sleep between IPC message sending attempts so
that we do not use up all the allowed attempts in a short period of time. The
hack will be replace with a non-blocking addEvent-based sleep.
Alex Rousskov [Mon, 26 Apr 2010 20:57:11 +0000 (14:57 -0600)]
Do not check pid file unless we are a master process. Kids processes start and
run when the pid file may point to a live Squid process.
There are some must-be-single processes like Coordinator, but it is probably
better to manage their uniqueness differently because there may be many kinds
of must-be-single processes.
Alex Rousskov [Mon, 26 Apr 2010 07:53:14 +0000 (01:53 -0600)]
Designate one process to maintain the PID file. Coordinator does that
when Squid runs in SMP mode. The only kid does it when running "mono".
The master process does it when not daemonizing. This change allows SMP
Squid to work with a single PID file.
Broadcast management signals from Coordinator to kids. This change
makes both "squid -k ..." and "kill `cat <PID file>`" work for SMP Squid.
Alex Rousskov [Mon, 26 Apr 2010 07:09:03 +0000 (01:09 -0600)]
Added IPC Strand and Coordinator classes. Strands are jobs responsible
for registering Squid processes or threads with the central Coordinator
job. Coordinator will broadcast control signals and shared ports to
Strands.
Added a simple hierarchy of inter-process communication (IPC) classes to
support Coordinator and Strands.
Print current process number (KidIdentifier) when writing debug messages.
This allows to easily isolate per-process progress even when using a single
cache.log.
Straighten the reconfigure and rotate sequences auth handling.
* Add a hook into auth API to only restart the helpers instead of
dropping auth state.
* Make reconfigure drop idle state and reset the config for new requests
to use the new config details.
This makes auth settings alterable with just a reconfigure now.
Clarify http_port mode options and enhance config validation.
This makes some changes to the config validation of http_port lines
and documentation of http_port.
It alters documentation to call accel, tproxy, intercept, and sslbump
options "mode flags" since they determine the overall code paths which
traffic received is handled by.
The http_port syntax docs are updated to show that mode flags must go
first before any options. This is not strictly true, since the mode flag
only must go before mode-specific options. But its clearer to explain the
syntax docs like this. Both mode and options remain completely optional
(except that some options require certain modes as before).
The parser is updated to validate that only one of the mode flags is used.
Attempts to mix them will result in a fatal error. Attempts to use any of
the mode-specific options without the correct mode being enabled first will
result in a fatal message.
As a side-effect of this the implicit enabling of accel on several of its
options has been dropped. Explicit use as mode flag is preferred (and
required) instead for clear reading of the config.
Implications for older configs are that the http_port may fail a parse
check until some basic re-ordering of options or splitting of http_port
into multiple entries is done. Hopefully the messages emitted on failure
are clear enough for people to follow easily.