[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#5002) Windows Service: logoff causes shutdown



This bug was fixed several years ago. You should update to a current 
release. This ITS will be closed.

mark.lakes@alcatel-lucent.com wrote:
> Full_Name: Mark Lakes
> Version: 2.1.22
> OS: Windows
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (198.206.187.100)
> 
> 
> Summary: LDAP service stops when user logs off.
> 
> The LDAP server is registered as a Windows Service and works correctly with
> SCM.
> It is registered as an automatic service so should be running all the time.
> When a user logs off from the box, the logoff triggers the service to stop
> running.
> This happens on WindowsXP and Windows 2003 Server that are configured on a
> Domain.
> 
> I have a solution.
> The problem is that despite the fact it is a service, it receives an event
> called CTRL_LOGOFF_EVENT. Since it is not handling this event, the default
> behavior by Windows is to shutdown the service.
> Add the following code to the source at an appropriate place(probably somewhere
> in ntservice.c) for when it runs as a service:
> 
> /**
> 	This is used to handle CTRL_LOGOFF_EVENT from shutting us down when we are
> 	running as a service.
>         Return TRUE works. We dont really care what the crtlType is.
>   */
> BOOL WINAPI
> WinSigHANDLER_ROUTINE(DWORD ctrlType)
> {
> /*
> 	char logstr[256];
>         sprintf(logstr, "NTservice: caught signal(%d)\n", ctrlType);
>         writeStatusLog(logstr);
> 	switch (ctrlType)
> 	{
> 	case CTRL_LOGOFF_EVENT:
> ...
> 	default:
> 
> 	} */
> 	return TRUE;
> }
> 
> Then, register the above function in the appropriate place as follows:
> SetConsoleCtrlHandler(WinSigHANDLER_ROUTINE, TRUE);
> 
> 
> 
> 


-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP     http://www.openldap.org/project/