On Sat, Sep 03, 2016 at 08:09:25PM +0200, Eric Faurot wrote: > Hi, > > Here is a diff to remove the "smtpctl stop" command. > The proper way to stop a daemon is kill(1)/pkill(1) only. > It makes no sense to have different code path for that. >
much agreed, queue code was designed to be kill-safe, the mta doesn't care because it will retry and the smtp code can catch & 421 ok by me > Index: control.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/control.c,v > retrieving revision 1.114 > diff -u -p -r1.114 control.c > --- control.c 1 Sep 2016 10:54:25 -0000 1.114 > +++ control.c 3 Sep 2016 17:42:37 -0000 > @@ -485,7 +485,7 @@ control_dispatch_ext(struct mproc *p, st > > switch (imsg->hdr.type) { > case IMSG_CTL_SMTP_SESSION: > - if (env->sc_flags & (SMTPD_SMTP_PAUSED | SMTPD_EXITING)) { > + if (env->sc_flags & SMTPD_SMTP_PAUSED) { > m_compose(p, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); > return; > } > @@ -511,22 +511,6 @@ control_dispatch_ext(struct mproc *p, st > kvp->val = val; > } > m_compose(p, IMSG_CTL_GET_STATS, 0, 0, -1, kvp, sizeof *kvp); > - return; > - > - case IMSG_CTL_SHUTDOWN: > - /* NEEDS_FIX */ > - log_debug("debug: received shutdown request"); > - > - if (c->euid) > - goto badcred; > - > - if (env->sc_flags & SMTPD_EXITING) { > - m_compose(p, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); > - return; > - } > - env->sc_flags |= SMTPD_EXITING; > - m_compose(p, IMSG_CTL_OK, 0, 0, -1, NULL, 0); > - m_compose(p_parent, IMSG_CTL_SHUTDOWN, 0, 0, -1, NULL, 0); > return; > > case IMSG_CTL_VERBOSE: > Index: smtpctl.8 > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.8,v > retrieving revision 1.57 > diff -u -p -r1.57 smtpctl.8 > --- smtpctl.8 14 Jun 2016 22:40:48 -0000 1.57 > +++ smtpctl.8 3 Sep 2016 17:42:37 -0000 > @@ -245,8 +245,6 @@ Displays runtime statistics concerning > .Xr smtpd 8 . > .It Cm show status > Shows if MTA, MDA and SMTP systems are currently running or paused. > -.It Cm stop > -Stop the server. > .It Cm trace Ar subsystem > Enables real-time tracing of > .Ar subsystem . > Index: smtpctl.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.c,v > retrieving revision 1.150 > diff -u -p -r1.150 smtpctl.c > --- smtpctl.c 3 Sep 2016 16:06:26 -0000 1.150 > +++ smtpctl.c 3 Sep 2016 17:42:37 -0000 > @@ -864,13 +864,6 @@ do_show_status(int argc, struct paramete > } > > static int > -do_stop(int argc, struct parameter *argv) > -{ > - srv_send(IMSG_CTL_SHUTDOWN, NULL, 0); > - return srv_check_result(1); > -} > - > -static int > do_trace(int argc, struct parameter *argv) > { > int v; > @@ -1080,7 +1073,6 @@ main(int argc, char **argv) > cmd_install("show routes", do_show_routes); > cmd_install("show stats", do_show_stats); > cmd_install("show status", do_show_status); > - cmd_install("stop", do_stop); > cmd_install("trace <str>", do_trace); > cmd_install("uncorrupt <msgid>", do_uncorrupt); > cmd_install("unprofile <str>", do_unprofile); > Index: smtpd.c > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/smtpd.c,v > retrieving revision 1.282 > diff -u -p -r1.282 smtpd.c > --- smtpd.c 1 Sep 2016 10:54:25 -0000 1.282 > +++ smtpd.c 3 Sep 2016 17:42:37 -0000 > @@ -257,10 +257,6 @@ parent_imsg(struct mproc *p, struct imsg > m_end(&m); > profiling = v; > return; > - > - case IMSG_CTL_SHUTDOWN: > - parent_shutdown(0); > - return; > } > } > > @@ -1752,7 +1748,6 @@ imsg_to_str(int type) > CASE(IMSG_CTL_REMOVE); > CASE(IMSG_CTL_SCHEDULE); > CASE(IMSG_CTL_SHOW_STATUS); > - CASE(IMSG_CTL_SHUTDOWN); > CASE(IMSG_CTL_TRACE_DISABLE); > CASE(IMSG_CTL_TRACE_ENABLE); > CASE(IMSG_CTL_UPDATE_TABLE); > Index: smtpd.h > =================================================================== > RCS file: /cvs/src/usr.sbin/smtpd/smtpd.h,v > retrieving revision 1.522 > diff -u -p -r1.522 smtpd.h > --- smtpd.h 3 Sep 2016 16:06:26 -0000 1.522 > +++ smtpd.h 3 Sep 2016 17:42:37 -0000 > @@ -161,7 +161,7 @@ union lookup { > * Bump IMSG_VERSION whenever a change is made to enum imsg_type. > * This will ensure that we can never use a wrong version of smtpctl with > smtpd. > */ > -#define IMSG_VERSION 15 > +#define IMSG_VERSION 16 > > enum imsg_type { > IMSG_NONE, > @@ -195,7 +195,6 @@ enum imsg_type { > IMSG_CTL_REMOVE, > IMSG_CTL_SCHEDULE, > IMSG_CTL_SHOW_STATUS, > - IMSG_CTL_SHUTDOWN, > IMSG_CTL_TRACE_DISABLE, > IMSG_CTL_TRACE_ENABLE, > IMSG_CTL_UPDATE_TABLE, > @@ -572,7 +571,7 @@ struct smtpd { > #define SMTPD_OPT_NOACTION 0x00000002 > uint32_t sc_opts; > > -#define SMTPD_EXITING 0x00000001 > +#define SMTPD_EXITING 0x00000001 /* unused */ > #define SMTPD_MDA_PAUSED 0x00000002 > #define SMTPD_MTA_PAUSED 0x00000004 > #define SMTPD_SMTP_PAUSED 0x00000008 > -- Gilles Chehade https://www.poolp.org @poolpOrg