Please enable JavaScript to view this site.

Thread Validator Help

 

Troubleshooting - Service fails to start

 

If a service takes too long to start the service control manager kills the service.

 

The way to stop this is for a service to call ReportStatusToSCMgr() to tell the service control manager that the service is still OK.

 

Thread Validator can't do this for you as the call requires some data from any earlier call you have made.

 

The solution is that you provide a callback using svlTVStub_SetServiceCallback() that Thread Validator can call during the process of attaching to the service, and you can call the appropriate function.

 

Example code to set the callback:

 

 errCode = svlTVStub_SetServiceCallback(serviceCallback,                // the callback

                                              NULL);                                // some user data (we don't have any, so set NULL)

 if (bLogging)

 {

         if (errCode != SVL_OK)

         {

                 svlTVStub_writeToLogFileW(L"Setting service callback failed. \r\n");

                 svlTVStub_writeToLogFile(errCode);

         }

 

         svlTVStub_writeToLogFileW(L"Starting Thread Validator\r\n");

 }

 

 

 

Example callback:

 

static void serviceCallback(void        *userParam)

{

 // just tell the Service Control Manager that we are still busy

 // in this example userParam is not used

 //

 // note that prior to the Validator loading it's DLL ssStatus.dwCurrentState must have been initialised, most likely to SERVICE_START_PENDING

 // you could pass a fixed value here, but it would need to change once the service has finished starting up so that you don't unintentionally change the service state

 // when this callback is called. This callback is called whenever instrumentation happens (when a DLL is loaded). Thus you can't assume this is only called during service startup,

 // it may also get called later in the service lifetime.

 

 ReportStatusToSCMgr(ssStatus.dwCurrentState,        // service state

                         NO_ERROR,                        // exit code

                         3000);                                // wait hint

}

 

We strongly recommend that you set a service callback. It won't harm your program and it will remove any likelihood of your service being killed by the service control manager.

 

 

Troubleshooting - Service starts, Thread Validator gets no data

 

If you have problems getting Thread Validator to monitor your service you'll need to find out what's failing.

 

Until Thread Validator loads correctly and successfully connects to the graphical user interface you have no way of knowing what is happening.

 

The solution is to set a log file that Thread Validator can write status messages to. You can also write your own status messages to this log file.

 

Set the log file using svlTVStub_setLogFileName. Write to it using svlTVStub_writeToLogFile(), svlTVStub_writeToLogFileA(), svlTVStub_writeToLogFileW().

 

Then when things are not working as expected take a look at the log file to see the errors. The Thread Validator will often suggest what the problem is.

 

We strongly recommend that you configure the log file and use it when working with services. It has saved us a lot of time.