Esempio n. 1
0
int main(int argc, char* argv[])
{  
    if((minArgc != argc) && (maxArgc != argc))
    {
        UsageDisplay(argv[0]);
    }
    else
    {        
        int start;
        
        ServiceInit(argc, argv);            
        
        while(service.upaUeNum <= service.upaUeNumEnd) 
        {            
            start = clock();
            
            TestSetGeneratorMainFlow();   
            
            printf(" * Take Time: %f seconds.\n", (double)(clock()-start)/CLOCK_PER_SEC);
            
            service.upaUeNum += service.upaUeNumStep;
        }      
    }
    
    return 0;
}
Esempio n. 2
0
//
// Purpose: 
//   Entry point for the service
//
// Parameters:
//   dwArgc - Number of arguments in the lpszArgv array
//   lpszArgv - Array of strings. The first string is the name of
//     the service and subsequent strings are passed by the process
//     that called the StartService function to start the service.
// 
// Return value:
//   None.
//
VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
	// Register the handler function for the service

	gServiceStatusHandle = RegisterServiceCtrlHandler(gServiceName, ServiceCtrlHandler);

	if (!gServiceStatusHandle)
	{
		LogMessage(L"error: RegisterServiceCtrlHandler failed (%d)\n", GetLastError());
		return;
	}

	// These SERVICE_STATUS members remain as set here

	gServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
	gServiceStatus.dwServiceSpecificExitCode = 0;

	// Report initial status to the SCM

	ServiceReportStatus(SERVICE_START_PENDING, NO_ERROR, 3000);

	// Perform service-specific initialization and work.

	ServiceInit(dwArgc, lpszArgv);
}
Esempio n. 3
0
/*
	ServiceMain function.
	https://msdn.microsoft.com/en-us/library/windows/desktop/ms687414%28v=vs.85%29.aspx
*/
void WINAPI ServiceMain(int argc, char ** argv) {


	// first call the RegisterServiceCtrlHandler. Register the SvcHandler function as the service's handler function.
	gSvcStatusHandle = RegisterServiceCtrlHandler( SVCNAME,(LPHANDLER_FUNCTION)&ServiceCtrlHandler);
	if (gSvcStatusHandle == NULL) {		
		//SvcReportEvent(TEXT("RegisterServiceCtrl"));
		// Write in a log file
		// Stop the service on error.
		ServiceStop( );
		return;
	}

	//gSvcStatus.dwControlsAccepted = p
	gSvcStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
	gSvcStatus.dwServiceSpecificExitCode = 0;


	// Call the ReportSvcStatus function to indicate that its initial status is SERVICE_START_PENDING.
	ReportSvcStatus(SERVICE_START_PENDING, NO_ERROR, 3000);

	// Calls the SvcInit function to perform the service-specific initialization and begin the work to be performed by the service.
	ServiceInit( );

	PerformServiceAction( );



	return;
}
Esempio n. 4
0
static VOID CALLBACK
ServiceMain(DWORD argc,
            LPWSTR *argv)
{
    DWORD dwError;

    UNREFERENCED_PARAMETER(argc);
    UNREFERENCED_PARAMETER(argv);

    DPRINT("ServiceMain() called\n");

    ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
                                                        ServiceControlHandler,
                                                        NULL);
    if (!ServiceStatusHandle)
    {
        dwError = GetLastError();
        DPRINT1("RegisterServiceCtrlHandlerW() failed! (Error %lu)\n", dwError);
        return;
    }

    UpdateServiceStatus(SERVICE_START_PENDING);

    dwError = ServiceInit();
    if (dwError != ERROR_SUCCESS)
    {
        DPRINT("Service stopped (dwError: %lu\n", dwError);
        UpdateServiceStatus(SERVICE_START_PENDING);
    }
    else
    {
        DPRINT("Service started\n");
        UpdateServiceStatus(SERVICE_RUNNING);

        ReportProductInfoEvent();

        LogfReportEvent(EVENTLOG_INFORMATION_TYPE,
                        0,
                        EVENT_EventlogStarted,
                        0,
                        NULL,
                        0,
                        NULL);
    }

    DPRINT("ServiceMain() done\n");
}
Esempio n. 5
0
/*
 * Main entry point for walsendserver controller process.
 *
 * This code is heavily based on pgarch.c, q.v.
 */
int
walsendserver_start(void)
{

	pid_t		WalSendServerPID;

	
#ifdef EXEC_BACKEND
	switch ((WalSendServerPID = walsendserver_forkexec()))
#else
	switch ((WalSendServerPID = fork_process()))
#endif
	{
		case -1:
			ereport(LOG,
					(errmsg("could not fork walsendserver process: %m")));
			return 0;

#ifndef EXEC_BACKEND
		case 0:
			/* in postmaster child ... */
			/* Close the postmaster's sockets */
			ClosePostmasterPorts(false);

			ServiceInit(&WalSendServer_ServiceConfig, &WalSendServer_ServiceCtrl);
			ServiceMain(&WalSendServer_ServiceCtrl);
			break;
#endif
		default:
			return (int) WalSendServerPID;
	}

	
	/* shouldn't get here */
	return 0;
}