Subject: | Possible problem with file locking in ScoreBoard engine |
The new ScoreBoard engine attempts to flock its own .pm file to prevent multiple kid processes from accepting new net connections simultaneously. This is a great optimization to prevent multiple processes from waking on each incoming connection, but it has an implementation that I suspect will prove problematic.
open $config, __FILE__ or do {
$proxy->log( HTTP::Proxy::ERROR, "ERROR", "Cannot open lock file: $!" );
exit;
};
There are three problems:
1) If this .pm is not real it cannot be locked. For example, if the .pm file came from a PAR archive.
2) If this .pm is on a network share that does not have reliable locking, this will fail needlessly.
3) If there is more than one HTTP::Proxy running, this will tie them to each other. If they are listening on different ports or interfaces, they may deadlock as the wrong one may get the file lock.
All three problems have the same solution: use a per-parent process temp file for locking. The parent process should use File::Temp to create a file on the local filesystem and then ScoreBoard.pm kids should lock that file instead of __FILE__.
-- Chris