session.c
changeset 38 058e5ad9ba79
parent 37 e3dccf824f91
parent 35 dcf7a837ec0b
child 39 6d2a560793d3
--- a/session.c	Sun Aug 31 16:18:35 2014 +0500
+++ b/session.c	Sun Aug 31 16:35:51 2014 +0500
@@ -147,8 +147,14 @@
 
 	io_clear(&entry->io);
 	iobuf_clear(&entry->iobuf);
-	imsgev_clear(entry->iev_maildrop);
-	entry->iev_maildrop->terminate = 1;
+	 /* 
+	  * If the session hadn't made it to TRANSACTION
+	  * iev_maildrop is not inited.
+	  */
+	if (entry->iev_maildrop) {
+		imsgev_clear(entry->iev_maildrop);
+		entry->iev_maildrop->terminate = 1;
+	}
 	logit(LOG_INFO, "%u: session closed", entry->id);
 	free(entry);
 }
@@ -440,6 +446,8 @@
 	s->iev_maildrop = xcalloc(1, sizeof(struct imsgev),
 	    "session_imsgev_init");
 	imsgev_init(s->iev_maildrop, fd, NULL, maildrop_imsgev, needfd);
+	imsgev_xcompose(s->iev_maildrop, IMSG_MAILDROP_INIT, s->id, 0,
+	    -1, s->user, sizeof(s->user), "session_imsgev_init");
 }
 
 static void