void
CommIO::Initialise()
{
+ if (CommIO::Initialised)
+ return;
+
/* Initialize done pipe signal */
int DonePipe[2];
if (pipe(DonePipe)) {}
DoneFD = DonePipe[1];
DoneReadFD = DonePipe[0];
- fd_open(DoneReadFD, FD_PIPE, "async-io completetion event: main");
- fd_open(DoneFD, FD_PIPE, "async-io completetion event: threads");
+ fd_open(DoneReadFD, FD_PIPE, "async-io completion event: main");
+ fd_open(DoneFD, FD_PIPE, "async-io completion event: threads");
commSetNonBlocking(DoneReadFD);
commSetNonBlocking(DoneFD);
Comm::SetSelect(DoneReadFD, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
static int DoneReadFD;
};
-/* Inline code. TODO: make structued approach to inlining */
+/* Inline code. TODO: make structured approach to inlining */
void
CommIO::NotifyIOCompleted()
{
- if (!Initialised)
- Initialise();
+ if (!Initialised) {
+ fatalf("Disk Threads I/O pipes not initialized before first use.");
+ }
if (!DoneSignalled) {
DoneSignalled = true;
done_queue.blocked = 0;
+ // Initialize the thread I/O pipes before creating any threads
+ // see bug 3189 comment 5 about race conditions.
+ CommIO::Initialize();
+
/* Create threads and get them to sit in their wait loop */
squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));