- if ( !(gateLock = IORecursiveLockAlloc()) )
- return false;
-
- if ( !(workToDoLock = IOSimpleLockAlloc()) )
- return false;
-
- controlG = IOCommandGate::
- commandGate(this, OSMemberFunctionCast(IOCommandGate::Action,
- this, &IOWorkLoop::_maintRequest));
- if ( !controlG )
- return false;
-
- IOSimpleLockInit(workToDoLock);
- workToDo = false;
-
- // Point the controlGate at the workLoop. Usually addEventSource
- // does this automatically. The problem is in this case addEventSource
- // uses the control gate and it has to be bootstrapped.
- controlG->setWorkLoop(this);
- if (addEventSource(controlG) != kIOReturnSuccess)
- return false;
+ if ( controlG == NULL ) {
+ controlG = IOCommandGate::commandGate(
+ this,
+ OSMemberFunctionCast(
+ IOCommandGate::Action,
+ this,
+ &IOWorkLoop::_maintRequest));
+
+ if ( !controlG )
+ return false;
+ // Point the controlGate at the workLoop. Usually addEventSource
+ // does this automatically. The problem is in this case addEventSource
+ // uses the control gate and it has to be bootstrapped.
+ controlG->setWorkLoop(this);
+ if (addEventSource(controlG) != kIOReturnSuccess)
+ return false;
+ }