Commit Diff


commit - 0696aea6cc2a797fd68090de35525de6b298e406
commit + ed005105533320c10c63f61686a3aee3b564904d
blob - 9e6511fc8dbeaf5b70d67ef9082bc18e6850f5dd
blob + e522c7d28e3357f5421e4b30c01507bb1c7b64ae
--- smtp_proc.c
+++ smtp_proc.c
@@ -371,7 +371,7 @@ smtp_vprintf(const char *fmt, va_list ap)
 		buf.buf = reallocarray(buf.buf, buf.bufsize,
 		    sizeof(*(buf.buf)));
 		if (buf.buf == NULL)
-			fatalx(NULL);
+			fatal(NULL);
 		fmtlen = vsnprintf(buf.buf + buf.buflen,
 		    buf.bufsize - buf.buflen, fmt, cap);
 		if (fmtlen == -1)
@@ -393,8 +393,6 @@ smtp_write(int fd, short event, void *arg)
 	ssize_t wlen;
 
 	if (buf->buflen == 0)
-		return;
-	if (event_pending(&stdoutev, EV_WRITE, NULL))
 		return;
 	if (!evset) {
 		event_set(&stdoutev, fd, EV_WRITE, smtp_write, buf);
@@ -412,6 +410,8 @@ smtp_write(int fd, short event, void *arg)
 		event_add(&stdoutev, NULL);
 	}
 	buf->buflen -= wlen;
+	if (buf->buflen == 0 && event_pending(&stdoutev, EV_WRITE, NULL))
+		event_del(&stdoutev);
 }
 
 void