On Mon, Nov 28, 2016 at 08:50:14PM +0100, Eric Faurot wrote:
> Hi,
>
> After the recent series of cleanups, it is now possible to make
> struct io opaque:
>
> - move struct io definition in ioev.c
> - replace io_init/io_clear with io_new/io_free
> - allocate an iobuf for each new io internally
> - use struct io pointer in the rest of the code
> - remove remaining uses of iobuf_*
>
> The diff is mostly mechanical.
>
ok gilles@
been running with this since saturday morning and tested both out and
in path, as well as bounce, without a regression
> Index: bounce.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
> retrieving revision 1.76
> diff -u -p -r1.76 bounce.c
> --- bounce.c 22 Nov 2016 07:28:42 - 1.76
> +++ bounce.c 28 Nov 2016 12:51:26 -
> @@ -80,8 +80,7 @@ struct bounce_session {
> struct bounce_message *msg;
> FILE*msgfp;
> int state;
> - struct iobuf iobuf;
> - struct ioio;
> + struct io *io;
> uint64_t boundary;
> };
>
> @@ -229,12 +228,11 @@ bounce_fd(int fd)
> s = xcalloc(1, sizeof(*s), "bounce_fd");
> s->smtpname = xstrdup(msg->smtpname, "bounce_fd");
> s->state = BOUNCE_EHLO;
> - iobuf_xinit(>iobuf, 0, 0, "bounce_run");
> - io_init(>io, >iobuf);
> - io_set_callback(>io, bounce_io, s);
> - io_set_fd(>io, fd);
> - io_set_timeout(>io, 3);
> - io_set_read(>io);
> + s->io = io_new();
> + io_set_callback(s->io, bounce_io, s);
> + io_set_fd(s->io, fd);
> + io_set_timeout(s->io, 3);
> + io_set_read(s->io);
> s->boundary = generate_uid();
>
> log_debug("debug: bounce: new session %p", s);
> @@ -313,7 +311,7 @@ bounce_send(struct bounce_session *s, co
>
> log_trace(TRACE_BOUNCE, "bounce: %p: >>> %s", s, p);
>
> - io_xprintf(>io, "%s\n", p);
> + io_xprintf(s->io, "%s\n", p);
>
> free(p);
> }
> @@ -452,7 +450,7 @@ bounce_next(struct bounce_session *s)
> case BOUNCE_DATA_NOTICE:
> /* Construct an appropriate notice. */
>
> - io_xprintf(>io,
> + io_xprintf(s->io,
> "Subject: Delivery status notification: %s\n"
> "From: Mailer Daemon \n"
> "To: %s\n"
> @@ -470,7 +468,7 @@ bounce_next(struct bounce_session *s)
> s->boundary,
> s->smtpname);
>
> - io_xprintf(>io,
> + io_xprintf(s->io,
> "--%16" PRIu64 "/%s\n"
> "Content-Description: Notification\n"
> "Content-Type: text/plain; charset=us-ascii\n"
> @@ -481,14 +479,14 @@ bounce_next(struct bounce_session *s)
>
> switch (s->msg->bounce.type) {
> case B_ERROR:
> - io_xprint(>io, notice_error);
> + io_xprint(s->io, notice_error);
> break;
> case B_WARNING:
> - io_xprintf(>io, notice_warning,
> + io_xprintf(s->io, notice_warning,
> bounce_duration(s->msg->bounce.delay));
> break;
> case B_DSN:
> - io_xprint(>io, s->msg->bounce.mta_without_dsn ?
> + io_xprint(s->io, s->msg->bounce.mta_without_dsn ?
> notice_relay : notice_success);
> break;
> default:
> @@ -496,32 +494,32 @@ bounce_next(struct bounce_session *s)
> }
>
> TAILQ_FOREACH(evp, >msg->envelopes, entry) {
> - io_xprint(>io, evp->report);
> + io_xprint(s->io, evp->report);
> }
> - io_xprint(>io, "\n");
> + io_xprint(s->io, "\n");
>
> if (s->msg->bounce.type == B_WARNING)
> - io_xprintf(>io, notice_warning2,
> + io_xprintf(s->io, notice_warning2,
> bounce_duration(s->msg->bounce.expire));
>
> - io_xprintf(>io,
> + io_xprintf(s->io,
> "Below is a copy of the original message:\n"
> "\n");
>
> - io_xprintf(>io,
> + io_xprintf(s->io,
> "--%16" PRIu64 "/%s\n"
> "Content-Description: Delivery Report\n"
> "Content-Type: message/delivery-status\n"
> "\n",
> s->boundary, s->smtpname);
>
> - io_xprintf(>io,
> + io_xprintf(s->io,
> "Reporting-MTA: dns; %s\n"
> "\n",
> s->smtpname);
>
> TAILQ_FOREACH(evp, >msg->envelopes, entry) {
> -