Alexander Morozov amorozov@etersoft.ru writes:
@@ -592,7 +586,26 @@ BOOL WINAPI StartServiceCtrlDispatcherA( const SERVICE_TABLE_ENTRYA *servent ) services[i] = info; }
- service_run_main_thread();
- disp = HeapAlloc( GetProcessHeap(), 0, sizeof(*disp) );
- if (!(disp->manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT )))
- {
ERR("failed to open service manager error %u\n", GetLastError());
HeapFree( GetProcessHeap(), 0, disp );
return FALSE;
- }
- disp->pipe = service_open_pipe();
- if (disp->pipe == INVALID_HANDLE_VALUE)
- {
WARN("failed to create control pipe error %u\n", GetLastError());
CloseServiceHandle( disp->manager );
HeapFree( GetProcessHeap(), 0, disp );
SetLastError( ERROR_FAILED_SERVICE_CONTROLLER_CONNECT );
return FALSE;
- }
- service_run_main_thread( disp );
There's no reason to duplicate that code, just do it in service_run_main_thread instead.