mirror of
https://github.com/osmarks/ngircd.git
synced 2025-07-05 11:22:49 +00:00
Resolver: Implement signal handler and catch TERM signal
This commit is contained in:
parent
d4632a727f
commit
2d4ea28835
@ -42,6 +42,7 @@
|
|||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void Init_Subprocess PARAMS(( void ));
|
||||||
static void Do_ResolveAddr PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd ));
|
static void Do_ResolveAddr PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd ));
|
||||||
static void Do_ResolveName PARAMS(( const char *Host, int w_fd ));
|
static void Do_ResolveName PARAMS(( const char *Host, int w_fd ));
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ Resolve_Addr(PROC_STAT * s, const ng_ipaddr_t *Addr, int identsock,
|
|||||||
return true;
|
return true;
|
||||||
} else if( pid == 0 ) {
|
} else if( pid == 0 ) {
|
||||||
/* Sub process */
|
/* Sub process */
|
||||||
Log_Init_Resolver();
|
Init_Subprocess();
|
||||||
Do_ResolveAddr( Addr, identsock, pipefd[1]);
|
Do_ResolveAddr( Addr, identsock, pipefd[1]);
|
||||||
Log_Exit_Resolver( );
|
Log_Exit_Resolver( );
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -98,7 +99,7 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short))
|
|||||||
return true;
|
return true;
|
||||||
} else if( pid == 0 ) {
|
} else if( pid == 0 ) {
|
||||||
/* Sub process */
|
/* Sub process */
|
||||||
Log_Init_Resolver();
|
Init_Subprocess();
|
||||||
Do_ResolveName(Host, pipefd[1]);
|
Do_ResolveName(Host, pipefd[1]);
|
||||||
Log_Exit_Resolver( );
|
Log_Exit_Resolver( );
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -107,6 +108,33 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short))
|
|||||||
} /* Resolve_Name */
|
} /* Resolve_Name */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal handler for the forked resolver subprocess.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
Signal_Handler(int Signal)
|
||||||
|
{
|
||||||
|
switch(Signal) {
|
||||||
|
case SIGTERM:
|
||||||
|
#ifdef DEBUG
|
||||||
|
Log_Resolver(LOG_DEBUG, "Resolver: Got TERM signal, exiting.");
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize forked resolver subprocess.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
Init_Subprocess(void)
|
||||||
|
{
|
||||||
|
signal(SIGTERM, Signal_Handler);
|
||||||
|
Log_Init_Resolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
|
#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
|
||||||
#if !defined(WANT_IPV6) && defined(h_errno)
|
#if !defined(WANT_IPV6) && defined(h_errno)
|
||||||
static char *
|
static char *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user