Commit Diff
Diff:
fdfef06340827dbb0d40f7a7d46fb4767de9f7da
17f7d0adedab905ab6714e2b4def5869029d5089
Commit:
17f7d0adedab905ab6714e2b4def5869029d5089
Tree:
c89e01a4fd9ed4d8764040d7d4714827e86c6769
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Dec 26 14:01:33 2017 UTC
Message:
add imsg socketpairs for the forked childs (n flag), while we don't need this really now, it will be good to have in the future when we want to do dynamic DNS and the childs will have to update the DATABASE process. Remove some dead code. Tested on OpenBSD/amd64, tested with -n 2 and -n 4 in debug mode
blob - 6f9535f4b6008398349f8223965991c6a05af0fc
blob + 94998e0226e1ec024a86ed5343ebe81469790831
--- ddd-db.h
+++ ddd-db.h
@@ -27,7 +27,7 @@
*/
/*
- * $Id: ddd-db.h,v 1.7 2017/11/28 15:02:41 pjp Exp $
+ * $Id: ddd-db.h,v 1.8 2017/12/26 14:01:33 pjp Exp $
*/
#ifndef _DB_H
@@ -499,6 +499,8 @@ struct cfg {
int recurse; /* recurse socket */
int log; /* logging socket */
int sockcount; /* set sockets */
+ int nth;
+ pid_t pid;
ddDB *db; /* database */
};
blob - 8dce5e1de3ea0a6ceaf8c965fca1a192dd016f9a
blob + d2cea5c5d9a00e66d888e47dea3fdb8d99dd6721
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.33 2017/12/14 10:37:23 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.34 2017/12/26 14:01:33 pjp Exp $
*/
#include "ddd-include.h"
@@ -868,9 +868,20 @@ main(int argc, char *argv[], char *environ[])
*
*/
+ cfg->pid = 0;
+ cfg->nth = 0;
+
for (n = 0; n < nflag; n++) {
+ if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, &cfg->my_imsg[MY_IMSG_MAX + n].imsg_fds[0]) < 0) {
+ dolog(LOG_INFO, "socketpair() failed\n");
+ slave_shutdown();
+ exit(1);
+ }
+
switch (pid = fork()) {
case 0:
+ cfg->pid = getpid();
+ cfg->nth = n;
cfg->sockcount = i;
cfg->db = db;
for (i = 0; i < cfg->sockcount; i++) {
@@ -885,11 +896,16 @@ main(int argc, char *argv[], char *environ[])
cfg->log = lfd;
+ close(cfg->my_imsg[MY_IMSG_MAX + n].imsg_fds[0]);
+ imsg_init(child_ibuf[MY_IMSG_MAX + n], cfg->my_imsg[MY_IMSG_MAX + n].imsg_fds[1]);
+ setproctitle("child %d pid %d", n, cfg->pid);
(void)mainloop(cfg, child_ibuf);
/* NOTREACHED */
default:
+ close(cfg->my_imsg[MY_IMSG_MAX + n].imsg_fds[1]);
+ imsg_init(child_ibuf[MY_IMSG_MAX + n], cfg->my_imsg[MY_IMSG_MAX + n].imsg_fds[0]);
break;
} /* switch pid= fork */
} /* for (.. nflag */
@@ -1594,7 +1610,7 @@ mainloop(struct cfg *cfg, struct imsgbuf **ibuf)
close(cfg->my_imsg[MY_IMSG_AXFR].imsg_fds[1]);
close(cfg->my_imsg[MY_IMSG_PARSER].imsg_fds[1]);
imsg_init(ibuf[MY_IMSG_PARSER], cfg->my_imsg[MY_IMSG_PARSER].imsg_fds[0]);
- setproctitle("udp parse engine");
+ setproctitle("udp parse engine %d", cfg->pid);
parseloop(cfg, ibuf);
/* NOTREACHED */
exit(1);
@@ -1626,7 +1642,7 @@ mainloop(struct cfg *cfg, struct imsgbuf **ibuf)
close(cfg->my_imsg[MY_IMSG_MASTER].imsg_fds[1]);
close(cfg->my_imsg[MY_IMSG_TCP].imsg_fds[1]);
imsg_init(ibuf[MY_IMSG_TCP], cfg->my_imsg[MY_IMSG_TCP].imsg_fds[0]);
- setproctitle("TCP engine");
+ setproctitle("TCP engine %d", cfg->pid);
tcploop(cfg, ibuf);
/* NOTREACHED */
exit(1);
@@ -1836,12 +1852,6 @@ axfrentry:
goto drop;
}
-#if 0
- if ((question = build_question(buf, len, ntohs(dh->additional))) == NULL) {
- dolog(LOG_INFO, "on descriptor %u interface \"%s\" malformed question from %s, drop\n", so, cfg->ident[i], address);
- goto drop;
- }
-#endif
/* pjp - branch to pledge parser here */
if (imsg_compose(pibuf, IMSG_PARSE_MESSAGE,
@@ -1972,13 +1982,6 @@ axfrentry:
goto udpout;
}
snprintf(replystring, DNS_MAXNAME, "REFUSED");
-#if 0
- fakequestion = build_fake_question(sd0->zone, sd0->zonelen, DNS_TYPE_SOA);
- if (fakequestion == NULL) {
- dolog(LOG_INFO, "fakequestion failed\n");
- break;
- }
-#endif
build_reply(&sreply, so, buf, len, question, from, fromlen, sd0, NULL, aregion, istcp, 0, NULL, replybuf);
slen = reply_refused(&sreply);
@@ -2816,7 +2819,7 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
close(cfg->my_imsg[MY_IMSG_TCP].imsg_fds[0]);
close(cfg->my_imsg[MY_IMSG_PARSER].imsg_fds[1]);
imsg_init(ibuf[MY_IMSG_PARSER], cfg->my_imsg[MY_IMSG_PARSER].imsg_fds[0]);
- setproctitle("tcp parse engine");
+ setproctitle("tcp parse engine %d", cfg->pid);
parseloop(cfg, ibuf);
/* NOTREACHED */
exit(1);
repomaster@centroid.eu