The api user should not have to care about normalizing the io input
buffer (i.e. resetting the read/write pos in the buffer).
Do it internally when reloading the io event.

Eric.

Index: bounce.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/bounce.c,v
retrieving revision 1.75
diff -u -p -r1.75 bounce.c
--- bounce.c    21 Nov 2016 13:00:43 -0000      1.75
+++ bounce.c    21 Nov 2016 19:33:46 -0000
@@ -728,10 +728,8 @@ bounce_io(struct io *io, int evt, void *
                        return;
                }
 
-               if (line == NULL) {
-                       iobuf_normalize(&s->iobuf);
+               if (line == NULL)
                        break;
-               }
 
                log_trace(TRACE_BOUNCE, "bounce: %p: <<< %s", s, line);
 
Index: filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/filter.c,v
retrieving revision 1.22
diff -u -p -r1.22 filter.c
--- filter.c    21 Nov 2016 13:00:43 -0000      1.22
+++ filter.c    21 Nov 2016 19:33:46 -0000
@@ -706,7 +706,6 @@ filter_tx_io(struct io *io, int evt, voi
                }
                s->idatalen += n;
                io_drop(&s->iev, n);
-               iobuf_normalize(&s->ibuf);
                return;
 
        case IO_DISCONNECTED:
Index: ioev.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/ioev.c,v
retrieving revision 1.30
diff -u -p -r1.30 ioev.c
--- ioev.c      20 Nov 2016 08:43:36 -0000      1.30
+++ ioev.c      21 Nov 2016 19:33:46 -0000
@@ -465,6 +465,9 @@ io_reload(struct io *io)
        if (io->flags & IO_HELD)
                return;
 
+       if (io->iobuf)
+               iobuf_normalize(io->iobuf);
+
 #ifdef IO_SSL
        if (io->ssl) {
                io_reload_ssl(io);
Index: mta_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/mta_session.c,v
retrieving revision 1.88
diff -u -p -r1.88 mta_session.c
--- mta_session.c       21 Nov 2016 13:00:43 -0000      1.88
+++ mta_session.c       21 Nov 2016 19:33:47 -0000
@@ -1182,10 +1182,8 @@ mta_io(struct io *io, int evt, void *arg
                        if (io_datalen(&s->io) >= LINE_MAX) {
                                mta_error(s, "Input too long");
                                mta_free(s);
-                               return;
                        }
-                       iobuf_normalize(&s->iobuf);
-                       break;
+                       return;
                }
 
                log_trace(TRACE_MTA, "mta: %p: <<< %s", s, line);
@@ -1263,8 +1261,6 @@ mta_io(struct io *io, int evt, void *arg
                        mta_connect(s);
                        return;
                }
-
-               iobuf_normalize(&s->iobuf);
 
                if (io_datalen(&s->io)) {
                        log_debug("debug: mta: remaining data in input buffer");
Index: smtp_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtp_session.c,v
retrieving revision 1.294
diff -u -p -r1.294 smtp_session.c
--- smtp_session.c      21 Nov 2016 13:00:43 -0000      1.294
+++ smtp_session.c      21 Nov 2016 19:33:48 -0000
@@ -1310,10 +1310,8 @@ smtp_io(struct io *io, int evt, void *ar
                }
 
                /* No complete line received */
-               if (line == NULL) {
-                       iobuf_normalize(&s->iobuf);
+               if (line == NULL)
                        return;
-               }
 
                /* Message body */
                if (s->state == STATE_BODY && strcmp(line, ".")) {
@@ -1338,7 +1336,6 @@ smtp_io(struct io *io, int evt, void *ar
 
                        rfc2822_parser_flush(&s->tx->rfc2822_parser);
 
-                       iobuf_normalize(&s->iobuf);
                        io_set_write(io);
 
                        s->tx->dataeom = 1;
@@ -1353,7 +1350,6 @@ smtp_io(struct io *io, int evt, void *ar
                (void)strlcpy(s->cmd, line, sizeof s->cmd);
                io_set_write(io);
                smtp_command(s, line);
-               iobuf_normalize(&s->iobuf);
                break;
 
        case IO_LOWAT:

Reply via email to