Hi, Koen.
You can find fix for this bug in attachment.
Please review.
Note that we can't use a mutex to protect sessionProcessPids_, because
we can't lock mutex from signal handler.
The reason is that the OS returns control to userspace code only after
it executes its signal handlers (at least freebsd and linux do so).
And if userspace code (wt application) locks and sleeps on mutex and
later the same mutex is locked from the signal handler, we'll be stuck
forever.
--
Andrii Arsirii
Streamco
http://streamco.org.ua
Index: src/fcgi/Server.C
===================================================================
--- src/fcgi/Server.C (revision 168)
+++ src/fcgi/Server.C (working copy)
@@ -445,21 +445,28 @@
clientSocket = connectToSession(sessionId, path, 1000);
}
- } else {
- /*
- * For SharedProcess, connect to a random server.
- */
- int i = lrand48() % sessionProcessPids_.size();
+ } else { // shared process
+ if (!sessionProcessPids_.empty()) { // Vector is altered from several control paths,
+ // there can be a case when it's empty.
+ // We can't use mutex here because vector is also altered
+ // from signal handler.
+ // connect to a random server.
+ int i = lrand48() % sessionProcessPids_.size();
- std::string path = conf_.runDirectory() + "/server-"
- + boost::lexical_cast<std::string>(sessionProcessPids_[i]);
+ std::string path = conf_.runDirectory() + "/server-"
+ + boost::lexical_cast<std::string>(sessionProcessPids_[i]);
- clientSocket = connectToSession("", path, 100);
+ clientSocket = connectToSession("", path, 100);
- if (clientSocket == -1)
- conf_.log("error") << "Session process " << sessionProcessPids_[i]
- << " not responding ?";
- }
+ if (clientSocket == -1)
+ conf_.log("error") << "Session process " << sessionProcessPids_[i]
+ << " not responding ?";
+ } else { // sleep until sessionProcessPids_ is not empty, this is unlikely to happen
+ conf_.log("notice") << "no shared processes available, sleeping for 1 second";
+
+ sleep(1);
+ }
+ }
}
if (clientSocket == -1) {
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest