Disengaging imsgev is tricky. First imsgev_clear as we know there
isn't anything left to be written. Signal imsgev termination by
setting iev->terminate = 1(Mind that we are setting it from with
the callback). As imsgev would again callback dispatch with
IMSGEV_DONE, we cannot free imsgev yet. So iev_maildrop need to
exist beyond lifetime of session until IMSGEV_DONE. Allocating it
seperately from session.
imsgev_close is avoided as it schedules another EV_WRITE which is
not needed in our case.
This fixes a crash observed consistently with a little perl script
to simulate concurrent sessions. Thanks MALLOC_OPTIONS='SFG<<'
PROG= pop3d
MAN= pop3d.8
CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -Wmissing-declarations -Wshadow -Wpointer-arith
CFLAGS+= -Wcast-qual -Wsign-compare
CFLAGS+= -DIO_SSL
DEBUG= -g
SRCS= pop3d.c pop3e.c session.c maildrop.c maildir.c mbox.c util.c
SRCS+= imsgev.c iobuf.c ioev.c
SRCS+= ssl.c ssl_privsep.c
LDADD+= -levent -lssl -lcrypto -lutil
DPADD= ${LIBEVENT} ${LIBSSL} ${LIBCRYPTO} ${LIBUTIL}
.include <bsd.prog.mk>