@ -214,6 +214,59 @@ void handle_sigusr2(int signal)
flag_tree_print = true ;
}
/*
*
* Signalling mosquitto process on Win32 .
*
* On Windows we we can use named events to pass signals to the mosquitto process .
* List of events :
*
* mosqPID_shutdown
* mosqPID_reload
* mosqPID_backup
* mosqPID_vacuum
*
* ( where PID is the PID of the mosquitto process ) .
*/
# ifdef WIN32
DWORD WINAPI SigThreadProc ( void * data ) {
TCHAR evt_name [ MAX_PATH ] ;
static HANDLE evt [ 4 ] ;
int pid = GetCurrentProcessId ( ) ;
sprintf_s ( evt_name , MAX_PATH , " mosq%d_shutdown " , pid ) ;
evt [ 0 ] = CreateEvent ( NULL , TRUE , FALSE , evt_name ) ;
sprintf_s ( evt_name , MAX_PATH , " mosq%d_reload " , pid ) ;
evt [ 1 ] = CreateEvent ( NULL , FALSE , FALSE , evt_name ) ;
sprintf_s ( evt_name , MAX_PATH , " mosq%d_backup " , pid ) ;
evt [ 2 ] = CreateEvent ( NULL , FALSE , FALSE , evt_name ) ;
sprintf_s ( evt_name , MAX_PATH , " mosq%d_vacuum " , pid ) ;
evt [ 3 ] = CreateEvent ( NULL , FALSE , FALSE , evt_name ) ;
while ( true ) {
int wr = WaitForMultipleObjects ( sizeof ( evt ) / sizeof ( HANDLE ) , evt , FALSE , INFINITE ) ;
switch ( wr ) {
case WAIT_OBJECT_0 + 0 :
handle_sigint ( SIGINT ) ;
break ;
case WAIT_OBJECT_0 + 1 :
flag_reload = true ;
continue ;
case WAIT_OBJECT_0 + 2 :
handle_sigusr1 ( 0 ) ;
continue ;
case WAIT_OBJECT_0 + 3 :
handle_sigusr2 ( 0 ) ;
continue ;
}
break ;
}
CloseHandle ( evt [ 0 ] ) ;
CloseHandle ( evt [ 1 ] ) ;
CloseHandle ( evt [ 2 ] ) ;
CloseHandle ( evt [ 3 ] ) ;
return 0 ;
}
# endif
int main ( int argc , char * argv [ ] )
{
mosq_sock_t * listensock = NULL ;
@ -371,6 +424,9 @@ int main(int argc, char *argv[])
signal ( SIGUSR2 , handle_sigusr2 ) ;
signal ( SIGPIPE , SIG_IGN ) ;
# endif
# ifdef WIN32
CreateThread ( NULL , 0 , SigThreadProc , NULL , 0 , NULL ) ;
# endif
# ifdef WITH_BRIDGE
for ( i = 0 ; i < config . bridge_count ; i + + ) {