Sat Oct 3 00:03:05 2009 UTC ()
Make signals match what OS X and the manpage say. Implement toggles for
debug and packet trace logging.

Make this conditional on HAVE_SIGINFO. Presumably lack of SIGINFO as a
standard posix feature is why they went with different signals here in
the first place, but since we have it, let's use it.


(tsarna)
diff -r1.2 -r1.3 src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c
diff -r1.3 -r1.4 src/external/apache2/mDNSResponder/usr.sbin/mdnsd/Makefile

cvs diff -r1.2 -r1.3 src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c (expand / switch to unified diff)

--- src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c 2009/10/01 16:36:20 1.2
+++ src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c 2009/10/03 00:03:05 1.3
@@ -203,53 +203,72 @@ mDNSlocal void DumpStateLog(mDNS *const  @@ -203,53 +203,72 @@ mDNSlocal void DumpStateLog(mDNS *const
203 }  203 }
204 204
205 LogMsg("---- END STATE LOG ----"); 205 LogMsg("---- END STATE LOG ----");
206 } 206 }
207 207
208mDNSlocal mStatus MainLoop(mDNS *m) // Loop until we quit. 208mDNSlocal mStatus MainLoop(mDNS *m) // Loop until we quit.
209 { 209 {
210 sigset_t signals; 210 sigset_t signals;
211 mDNSBool gotData = mDNSfalse; 211 mDNSBool gotData = mDNSfalse;
212 212
213 mDNSPosixListenForSignalInEventLoop(SIGINT); 213 mDNSPosixListenForSignalInEventLoop(SIGINT);
214 mDNSPosixListenForSignalInEventLoop(SIGTERM); 214 mDNSPosixListenForSignalInEventLoop(SIGTERM);
215 mDNSPosixListenForSignalInEventLoop(SIGUSR1); 215 mDNSPosixListenForSignalInEventLoop(SIGUSR1);
 216#ifdef HAVE_SIGINFO
 217 mDNSPosixListenForSignalInEventLoop(SIGUSR2);
 218 mDNSPosixListenForSignalInEventLoop(SIGINFO);
 219#endif
216 mDNSPosixListenForSignalInEventLoop(SIGPIPE); 220 mDNSPosixListenForSignalInEventLoop(SIGPIPE);
217 mDNSPosixListenForSignalInEventLoop(SIGHUP) ; 221 mDNSPosixListenForSignalInEventLoop(SIGHUP) ;
218 222
219 for (; ;) 223 for (; ;)
220 { 224 {
221 // Work out how long we expect to sleep before the next scheduled task 225 // Work out how long we expect to sleep before the next scheduled task
222 struct timeval timeout; 226 struct timeval timeout;
223 mDNSs32 ticks; 227 mDNSs32 ticks;
224 228
225 // Only idle if we didn't find any data the last time around 229 // Only idle if we didn't find any data the last time around
226 if (!gotData) 230 if (!gotData)
227 { 231 {
228 mDNSs32 nextTimerEvent = mDNS_Execute(m); 232 mDNSs32 nextTimerEvent = mDNS_Execute(m);
229 nextTimerEvent = udsserver_idle(nextTimerEvent); 233 nextTimerEvent = udsserver_idle(nextTimerEvent);
230 ticks = nextTimerEvent - mDNS_TimeNow(m); 234 ticks = nextTimerEvent - mDNS_TimeNow(m);
231 if (ticks < 1) ticks = 1; 235 if (ticks < 1) ticks = 1;
232 } 236 }
233 else // otherwise call EventLoop again with 0 timemout 237 else // otherwise call EventLoop again with 0 timemout
234 ticks = 0; 238 ticks = 0;
235 239
236 timeout.tv_sec = ticks / mDNSPlatformOneSecond; 240 timeout.tv_sec = ticks / mDNSPlatformOneSecond;
237 timeout.tv_usec = (ticks % mDNSPlatformOneSecond) * 1000000 / mDNSPlatformOneSecond; 241 timeout.tv_usec = (ticks % mDNSPlatformOneSecond) * 1000000 / mDNSPlatformOneSecond;
238 242
239 (void) mDNSPosixRunEventLoopOnce(m, &timeout, &signals, &gotData); 243 (void) mDNSPosixRunEventLoopOnce(m, &timeout, &signals, &gotData);
240 244
241 if (sigismember(&signals, SIGHUP )) Reconfigure(m); 245 if (sigismember(&signals, SIGHUP )) Reconfigure(m);
 246#ifdef HAVE_SIGINFO
 247 /* use OSX-compatible signals since we can, and gain enhanced debugging */
 248 if (sigismember(&signals, SIGINFO)) DumpStateLog(m);
 249 if (sigismember(&signals, SIGUSR1))
 250 {
 251 mDNS_LoggingEnabled = mDNS_LoggingEnabled ? 0 : 1;
 252 LogMsg("SIGUSR1: Logging %s", mDNS_LoggingEnabled ? "Enabled" : "Disabled");
 253 }
 254 if (sigismember(&signals, SIGUSR2))
 255 {
 256 mDNS_PacketLoggingEnabled = mDNS_PacketLoggingEnabled ? 0 : 1;
 257 LogMsg("SIGUSR2: Packet Logging %s", mDNS_PacketLoggingEnabled ? "Enabled" : "Disabled");
 258 }
 259#else
242 if (sigismember(&signals, SIGUSR1)) DumpStateLog(m); 260 if (sigismember(&signals, SIGUSR1)) DumpStateLog(m);
 261#endif
243 // SIGPIPE happens when we try to write to a dead client; death should be detected soon in request_callback() and cleaned up. 262 // SIGPIPE happens when we try to write to a dead client; death should be detected soon in request_callback() and cleaned up.
244 if (sigismember(&signals, SIGPIPE)) LogMsg("Received SIGPIPE - ignoring"); 263 if (sigismember(&signals, SIGPIPE)) LogMsg("Received SIGPIPE - ignoring");
245 if (sigismember(&signals, SIGINT) || sigismember(&signals, SIGTERM)) break; 264 if (sigismember(&signals, SIGINT) || sigismember(&signals, SIGTERM)) break;
246 } 265 }
247 return EINTR; 266 return EINTR;
248 } 267 }
249 268
250int main(int argc, char **argv) 269int main(int argc, char **argv)
251 { 270 {
252 mStatus err; 271 mStatus err;
253 272
254 ParseCmdLinArgs(argc, argv); 273 ParseCmdLinArgs(argc, argv);
255 274

cvs diff -r1.3 -r1.4 src/external/apache2/mDNSResponder/usr.sbin/mdnsd/Makefile (expand / switch to unified diff)

--- src/external/apache2/mDNSResponder/usr.sbin/mdnsd/Makefile 2009/10/01 10:01:14 1.3
+++ src/external/apache2/mDNSResponder/usr.sbin/mdnsd/Makefile 2009/10/03 00:03:05 1.4
@@ -1,21 +1,22 @@ @@ -1,21 +1,22 @@
1# $NetBSD: Makefile,v 1.3 2009/10/01 10:01:14 tron Exp $ 1# $NetBSD: Makefile,v 1.4 2009/10/03 00:03:05 tsarna Exp $
2 2
3PROG= mdnsd 3PROG= mdnsd
4 4
5.include <bsd.init.mk> 5.include <bsd.init.mk>
6 6
7.PATH: ${DIST}/mDNSPosix ${DIST}/mDNSCore ${DIST}/mDNSShared 7.PATH: ${DIST}/mDNSPosix ${DIST}/mDNSCore ${DIST}/mDNSShared
8 8
9CPPFLAGS+=-I${DIST}/mDNSCore -I${DIST}/mDNSShared -DPROGRAM_NAME=\"mdnsd\" 9CPPFLAGS+=-I${DIST}/mDNSCore -I${DIST}/mDNSShared \
 10 -DPROGRAM_NAME=\"mdnsd\" -DHAVE_SIGINFO
10SRCS= PosixDaemon.c mDNSPosix.c mDNSUNP.c mDNS.c DNSDigest.c uDNS.c \ 11SRCS= PosixDaemon.c mDNSPosix.c mDNSUNP.c mDNS.c DNSDigest.c uDNS.c \
11 DNSCommon.c uds_daemon.c mDNSDebug.c dnssd_ipc.c GenLinkedList.c \ 12 DNSCommon.c uds_daemon.c mDNSDebug.c dnssd_ipc.c GenLinkedList.c \
12 PlatformCommon.c 13 PlatformCommon.c
13 14
14COPTS.uds_daemon.c += -Wno-stack-protector 15COPTS.uds_daemon.c += -Wno-stack-protector
15 16
16MAN= mdnsd.8 17MAN= mdnsd.8
17 18
18mdnsd.8: mDNSResponder.8 19mdnsd.8: mDNSResponder.8
19 ${TOOL_CAT} < $? > $@ 20 ${TOOL_CAT} < $? > $@
20  21
21.include <bsd.prog.mk> 22.include <bsd.prog.mk>