From: markus schnalke <meillo@marmaro.de>
Date: Wed, 11 Apr 2012 09:52:12 +0000 (+0200)
Subject: Don't display multipart/parallel in parallel. Always serialize displaying.
X-Git-Tag: mmh-thesis-end~102
X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=d0581ba306a7299113a346f9b4c46ce97bc4cef6;p=mmh

Don't display multipart/parallel in parallel. Always serialize displaying.
---

diff --git a/man/mhshow.man1 b/man/mhshow.man1
index 0a6513b6..13cb0151 100644
--- a/man/mhshow.man1
+++ b/man/mhshow.man1
@@ -18,7 +18,6 @@ mhshow \- display MIME messages
 .RB [ \-type
 .IR content ]
 \&...
-.RB [ \-serialonly " | " \-noserialonly ]
 .RB [ \-form
 .IR formfile ]
 .RB [ \-rcache
@@ -298,16 +297,14 @@ the shell of any funny characters that might be present in the filename.
 .PP
 Finally,
 .B mhshow
-will process each message serially\0--\0it won't start
+will process each message serially \- it won't start
 showing the next message until all the commands executed to display the
 current message have terminated.  In the case of a multipart content
 (of any subtype listed above), the content contains advice indicating if
 the parts should be displayed serially or in parallel.  Because this may
-cause confusion, particularly on uni-window displays, the
-.B \-serialonly
-switch can be given to tell
+cause confusion, particularly on uni-window displays,
 .B mhshow
-to never display parts in parallel.
+will never display parts in parallel.
 .SS "Showing Alternate Character Sets"
 Because a content of type text might be in a non-ASCII character
 set, when
@@ -578,7 +575,6 @@ mhbuild(1), mhl(1), mhlist(1), mhstore(1), sendfiles(1)
 .RB ` \-nocheck '
 .RB ` \-form \ mhl.headers'
 .RB ` \-rcache \ ask'
-.RB ` \-noserialonly '
 .RB ` \-noverbose '
 .RB ` \-wcache \ ask'
 .fi
diff --git a/uip/mhshow.c b/uip/mhshow.c
index b43d5a81..6e694c41 100644
--- a/uip/mhshow.c
+++ b/uip/mhshow.c
@@ -23,31 +23,27 @@ static struct swit switches[] = {
 	{ "check", 0 },
 #define NCHECKSW  1
 	{ "nocheck", 0 },
-#define SERIALSW  2
-	{ "serialonly", 0 },
-#define NSERIALSW  3
-	{ "noserialonly", 0 },
-#define VERBSW  4
+#define VERBSW  2
 	{ "verbose", 0 },
-#define NVERBSW  5
+#define NVERBSW  3
 	{ "noverbose", 0 },
-#define FILESW  6  /* interface from show */
+#define FILESW  4  /* interface from show */
 	{ "file file", 0 },
-#define FORMSW  7
+#define FORMSW  5
 	{ "form formfile", 0 },
-#define PARTSW  8
+#define PARTSW  6
 	{ "part number", 0 },
-#define TYPESW  9
+#define TYPESW  7
 	{ "type content", 0 },
-#define RCACHESW  10
+#define RCACHESW  8
 	{ "rcache policy", 0 },
-#define WCACHESW  11
+#define WCACHESW  9
 	{ "wcache policy", 0 },
-#define VERSIONSW  12
+#define VERSIONSW  10
 	{ "version", 0 },
-#define HELPSW  13
+#define HELPSW  11
 	{ "help", 0 },
-#define DEBUGSW  14
+#define DEBUGSW  12
 	{ "debug", -5 },
 	{ NULL, 0 }
 };
@@ -63,7 +59,6 @@ extern char *cache_public;
 extern char *cache_private;
 
 /* mhshowsbr.c */
-extern int serialsw;
 extern int nolist;
 extern char *formsw;
 
@@ -174,13 +169,6 @@ do_cache:
 				checksw = 0;
 				continue;
 
-			case SERIALSW:
-				serialsw = 1;
-				continue;
-			case NSERIALSW:
-				serialsw = 0;
-				continue;
-
 			case PARTSW:
 				if (!(cp = *argp++) || *cp == '-')
 					adios(NULL, "missing argument to %s",
diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c
index d3ddb948..75633b76 100644
--- a/uip/mhshowsbr.c
+++ b/uip/mhshowsbr.c
@@ -21,7 +21,6 @@
 
 extern int debugsw;
 
-int serialsw = 0;
 int nolist   = 0;
 char *formsw = NULL;
 pid_t xpid = 0;
@@ -44,23 +43,23 @@ int list_content(CT, int, int, int, int);
 ** prototypes
 */
 void show_all_messages(CT *);
-int show_content_aux(CT, int, int, char *, char *);
+int show_content_aux(CT, int, char *, char *);
 
 /*
 ** static prototypes
 */
 static void show_single_message(CT, char *);
 static void DisplayMsgHeader(CT, char *);
-static int show_switch(CT, int, int);
-static int show_content(CT, int, int);
-static int show_content_aux2(CT, int, int, char *, char *, int, int, int, int);
-static int show_text(CT, int, int);
-static int show_multi(CT, int, int);
-static int show_multi_internal(CT, int, int);
-static int show_multi_aux(CT, int, int, char *);
-static int show_message_rfc822(CT, int, int);
-static int show_partial(CT, int, int);
-static int show_external(CT, int, int);
+static int show_switch(CT, int);
+static int show_content(CT, int);
+static int show_content_aux2(CT, int, char *, char *, int, int, int, int);
+static int show_text(CT, int);
+static int show_multi(CT, int);
+static int show_multi_internal(CT, int);
+static int show_multi_aux(CT, int, char *);
+static int show_message_rfc822(CT, int);
+static int show_partial(CT, int);
+static int show_external(CT, int);
 
 
 /*
@@ -121,7 +120,7 @@ show_single_message(CT ct, char *form)
 		xpid = 0;
 
 	/* Show the body of the message */
-	show_switch(ct, 1, 0);
+	show_switch(ct, 0);
 
 	if (ct->c_fp) {
 		fclose(ct->c_fp);
@@ -196,40 +195,39 @@ DisplayMsgHeader(CT ct, char *form)
 */
 
 static int
-show_switch(CT ct, int serial, int alternate)
+show_switch(CT ct, int alternate)
 {
 	switch (ct->c_type) {
 	case CT_MULTIPART:
-		return show_multi(ct, serial, alternate);
+		return show_multi(ct, alternate);
 		break;
 
 	case CT_MESSAGE:
 		switch (ct->c_subtype) {
 			case MESSAGE_PARTIAL:
-				return show_partial(ct, serial, alternate);
+				return show_partial(ct, alternate);
 				break;
 
 			case MESSAGE_EXTERNAL:
-				return show_external(ct, serial, alternate);
+				return show_external(ct, alternate);
 				break;
 
 			case MESSAGE_RFC822:
 			default:
-				return show_message_rfc822(ct, serial,
-						alternate);
+				return show_message_rfc822(ct, alternate);
 				break;
 		}
 		break;
 
 	case CT_TEXT:
-		return show_text(ct, serial, alternate);
+		return show_text(ct, alternate);
 		break;
 
 	case CT_AUDIO:
 	case CT_IMAGE:
 	case CT_VIDEO:
 	case CT_APPLICATION:
-		return show_content(ct, serial, alternate);
+		return show_content(ct, alternate);
 		break;
 
 	default:
@@ -246,7 +244,7 @@ show_switch(CT ct, int serial, int alternate)
 */
 
 static int
-show_content(CT ct, int serial, int alternate)
+show_content(CT ct, int alternate)
 {
 	char *cp, buffer[BUFSIZ];
 	CI ci = &ct->c_ctinfo;
@@ -255,15 +253,15 @@ show_content(CT ct, int serial, int alternate)
 	snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
 				invo_name, ci->ci_type, ci->ci_subtype);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/* Check for mhshow-show-type */
 	snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	if ((cp = ct->c_showproc))
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/* complain if we are not a part of a multipart/alternative */
 	if (!alternate)
@@ -278,7 +276,7 @@ show_content(CT ct, int serial, int alternate)
 */
 
 int
-show_content_aux(CT ct, int serial, int alternate, char *cp, char *cracked)
+show_content_aux(CT ct, int alternate, char *cp, char *cracked)
 {
 	int fd, len, buflen, quoted;
 	int xstdin, xlist, xtty;
@@ -469,7 +467,7 @@ raw:
 	}
 
 got_command:
-	return show_content_aux2(ct, serial, alternate, cracked, buffer,
+	return show_content_aux2(ct, alternate, cracked, buffer,
 			fd, xlist, xstdin, xtty);
 }
 
@@ -479,7 +477,7 @@ got_command:
 */
 
 static int
-show_content_aux2(CT ct, int serial, int alternate, char *cracked,
+show_content_aux2(CT ct, int alternate, char *cracked,
 	char *buffer, int fd, int xlist, int xstdin, int xtty)
 {
 	pid_t child_id;
@@ -541,13 +539,7 @@ show_content_aux2(CT ct, int serial, int alternate, char *cracked,
 		/* NOTREACHED */
 
 	default:
-		if (!serial) {
-			ct->c_pid = child_id;
-			if (xtty)
-				xpid = child_id;
-		} else {
-			pidcheck(pidXwait(child_id, NULL));
-		}
+		pidcheck(pidXwait(child_id, NULL));
 
 		if (fd != NOTOK)
 			(*ct->c_ceclosefnx) (ct);
@@ -561,7 +553,7 @@ show_content_aux2(CT ct, int serial, int alternate, char *cracked,
 */
 
 static int
-show_text(CT ct, int serial, int alternate)
+show_text(CT ct, int alternate)
 {
 	char *cp, buffer[BUFSIZ];
 	CI ci = &ct->c_ctinfo;
@@ -570,12 +562,12 @@ show_text(CT ct, int serial, int alternate)
 	snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
 			invo_name, ci->ci_type, ci->ci_subtype);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/* Check for mhshow-show-type */
 	snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/*
 	** Use default method if content is text/plain, or if
@@ -584,7 +576,7 @@ show_text(CT ct, int serial, int alternate)
 	if (!alternate || ct->c_subtype == TEXT_PLAIN) {
 		snprintf(buffer, sizeof(buffer), "%%p%s '%%F'", defaultpager);
 		cp = (ct->c_showproc = getcpy(buffer));
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 	}
 
 	return NOTOK;
@@ -596,7 +588,7 @@ show_text(CT ct, int serial, int alternate)
 */
 
 static int
-show_multi(CT ct, int serial, int alternate)
+show_multi(CT ct, int alternate)
 {
 	char *cp, buffer[BUFSIZ];
 	CI ci = &ct->c_ctinfo;
@@ -605,15 +597,15 @@ show_multi(CT ct, int serial, int alternate)
 	snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
 			invo_name, ci->ci_type, ci->ci_subtype);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_multi_aux(ct, serial, alternate, cp);
+		return show_multi_aux(ct, alternate, cp);
 
 	/* Check for mhshow-show-type */
 	snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_multi_aux(ct, serial, alternate, cp);
+		return show_multi_aux(ct, alternate, cp);
 
 	if ((cp = ct->c_showproc))
-		return show_multi_aux(ct, serial, alternate, cp);
+		return show_multi_aux(ct, alternate, cp);
 
 	/*
 	** Use default method to display this multipart content
@@ -621,7 +613,7 @@ show_multi(CT ct, int serial, int alternate)
 	** or if it is one of the known subtypes of multipart.
 	*/
 	if (!alternate || ct->c_subtype != MULTI_UNKNOWN)
-		return show_multi_internal(ct, serial, alternate);
+		return show_multi_internal(ct, alternate);
 
 	return NOTOK;
 }
@@ -633,46 +625,33 @@ show_multi(CT ct, int serial, int alternate)
 */
 
 static int
-show_multi_internal(CT ct, int serial, int alternate)
+show_multi_internal(CT ct, int alternate)
 {
-	int alternating, nowalternate, nowserial, result;
+	int alternating, nowalternate, result;
 	struct multipart *m = (struct multipart *) ct->c_ctparams;
 	struct part *part;
 	CT p;
-	sigset_t set, oset;
 
 	alternating = 0;
 	nowalternate = alternate;
 
-	if (ct->c_subtype == MULTI_PARALLEL) {
-		nowserial = serialsw;
-	} else if (ct->c_subtype == MULTI_ALTERNATE) {
+	if (ct->c_subtype == MULTI_ALTERNATE) {
 		nowalternate = 1;
 		alternating  = 1;
-		nowserial = serial;
-	} else {
-		/*
-		** multipart/mixed
-		** mutlipart/digest
-		** unknown subtypes of multipart (treat as mixed per rfc2046)
-		*/
-		nowserial = serial;
 	}
 
-	/* block a few signals */
-	if (!nowserial) {
-		sigemptyset(&set);
-		sigaddset(&set, SIGHUP);
-		sigaddset(&set, SIGINT);
-		sigaddset(&set, SIGQUIT);
-		sigaddset(&set, SIGTERM);
-		sigprocmask(SIG_BLOCK, &set, &oset);
-	}
+	/*
+	** Other possible multipart types are:
+	** - multipart/parallel
+	** - multipart/mixed
+	** - multipart/digest
+	** - unknown subtypes of multipart (treat as mixed per rfc2046)
+	*/
 
-/*
-** alternate   -> we are a part inside an multipart/alternative
-** alternating -> we are a multipart/alternative
-*/
+	/*
+	** alternate   -> we are a part inside an multipart/alternative
+	** alternating -> we are a multipart/alternative
+	*/
 
 	result = alternate ? NOTOK : OK;
 
@@ -682,7 +661,7 @@ show_multi_internal(CT ct, int serial, int alternate)
 		if (part_ok(p, 1) && type_ok(p, 1)) {
 			int inneresult;
 
-			inneresult = show_switch(p, nowserial, nowalternate);
+			inneresult = show_switch(p, nowalternate);
 			switch (inneresult) {
 			case NOTOK:
 				if (alternate && !alternating) {
@@ -714,47 +693,7 @@ show_multi_internal(CT ct, int serial, int alternate)
 		result = NOTOK;
 		goto out;
 	}
-
-	if (serial && !nowserial) {
-		pid_t pid;
-		int kids;
-		int status;
-
-		kids = 0;
-		for (part = m->mp_parts; part; part = part->mp_next) {
-			p = part->mp_part;
-
-			if (p->c_pid > OK) {
-				if (kill(p->c_pid, 0) == NOTOK)
-					p->c_pid = 0;
-				else
-					kids++;
-			}
-		}
-
-		while (kids > 0 && (pid = wait(&status)) != NOTOK) {
-			pidcheck(status);
-
-			for (part = m->mp_parts; part; part = part->mp_next) {
-				p = part->mp_part;
-
-				if (xpid == pid)
-					xpid = 0;
-				if (p->c_pid == pid) {
-					p->c_pid = 0;
-					kids--;
-					break;
-				}
-			}
-		}
-	}
-
 out:
-	if (!nowserial) {
-		/* reset the signal mask */
-		sigprocmask(SIG_SETMASK, &oset, &set);
-	}
-
 	return result;
 }
 
@@ -765,7 +704,7 @@ out:
 */
 
 static int
-show_multi_aux(CT ct, int serial, int alternate, char *cp)
+show_multi_aux(CT ct, int alternate, char *cp)
 {
 	int len, buflen, quoted;
 	int xlist, xtty;
@@ -968,7 +907,7 @@ raw:
 		snprintf(buffer, sizeof(buffer), ct->c_termproc, term);
 	}
 
-	return show_content_aux2(ct, serial, alternate, NULL, buffer,
+	return show_content_aux2(ct, alternate, NULL, buffer,
 			NOTOK, xlist, 0, xtty);
 }
 
@@ -978,7 +917,7 @@ raw:
 */
 
 static int
-show_message_rfc822(CT ct, int serial, int alternate)
+show_message_rfc822(CT ct, int alternate)
 {
 	char *cp, buffer[BUFSIZ];
 	CI ci = &ct->c_ctinfo;
@@ -987,20 +926,20 @@ show_message_rfc822(CT ct, int serial, int alternate)
 	snprintf(buffer, sizeof(buffer), "%s-show-%s/%s",
 				invo_name, ci->ci_type, ci->ci_subtype);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/* Check for mhshow-show-type */
 	snprintf(buffer, sizeof(buffer), "%s-show-%s", invo_name, ci->ci_type);
 	if ((cp = context_find(buffer)) && *cp != '\0')
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	if ((cp = ct->c_showproc))
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 
 	/* default method for message/rfc822 */
 	if (ct->c_subtype == MESSAGE_RFC822) {
 		cp = (ct->c_showproc = getcpy("%pshow -file '%F'"));
-		return show_content_aux(ct, serial, alternate, cp, NULL);
+		return show_content_aux(ct, alternate, cp, NULL);
 	}
 
 	/* complain if we are not a part of a multipart/alternative */
@@ -1016,7 +955,7 @@ show_message_rfc822(CT ct, int serial, int alternate)
 */
 
 static int
-show_partial(CT ct, int serial, int alternate)
+show_partial(CT ct, int alternate)
 {
 	content_error(NULL, ct,
 		"in order to display this message, you must reassemble it");
@@ -1031,7 +970,7 @@ show_partial(CT ct, int serial, int alternate)
 */
 
 static int
-show_external(CT ct, int serial, int alternate)
+show_external(CT ct, int alternate)
 {
 	struct exbody *e = (struct exbody *) ct->c_ctparams;
 	CT p = e->eb_content;
@@ -1039,7 +978,7 @@ show_external(CT ct, int serial, int alternate)
 	if (!type_ok(p, 0))
 		return OK;
 
-	return show_switch(p, serial, alternate);
+	return show_switch(p, alternate);
 
 #if 0
 	content_error(NULL, p, "don't know how to display content");
diff --git a/uip/mhstore.c b/uip/mhstore.c
index cb411d8c..ea35f8eb 100644
--- a/uip/mhstore.c
+++ b/uip/mhstore.c
@@ -114,7 +114,7 @@ int make_intermediates(char *);
 void flush_errors(void);
 
 /* mhshowsbr.c */
-int show_content_aux(CT, int, int, char *, char *);
+int show_content_aux(CT, int, char *, char *);
 
 /*
 ** static prototypes
@@ -924,7 +924,7 @@ store_content(CT ct, CT p)
 	** content to standard input of a command and return.
 	*/
 	if (buffer[0] == '|' || buffer[0] == '!')
-		return show_content_aux(ct, 1, 0, buffer + 1, dir);
+		return show_content_aux(ct, 0, buffer + 1, dir);
 
 	/* record the filename */
 	ct->c_storage = getcpy(buffer);