9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] upas/fs/imap4.c
@ 2005-12-02 21:15 erik quanstrom
  0 siblings, 0 replies; only message in thread
From: erik quanstrom @ 2005-12-02 21:15 UTC (permalink / raw)
  To: 9fans

i needed to modify upas/fs/imap4.c to avoid an rfork().

i'm sure that russ will post a much better version in 30 seconds
or so. ;-)

- erik

; diff imap4.c $home/plan9~/src/cmd/upas/fs/imap4.c
6a7
> #include <thread.h>
403c404
< 		_exits(nil);
---
> 		threadexitsall("execl");
537a539,567
> static void requestdoc(Biobuf* b, ulong tag, ulong uid){
> 	fprint(2,"9X%lud UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",tag, uid);
> 	Bprint(b, "9X%lud UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",tag, uid);
> }
> 
> static long slavereq(va_list* ap){
> 	Biobuf* b;
> 	unsigned long tag;
> 	unsigned long uid;
> 
> 	b = va_arg(*ap, Biobuf*);
> 	tag = va_arg(*ap, ulong);
> 	uid = va_arg(*ap, ulong);
> 	va_end(*ap);
> 
> 	requestdoc(b,tag,uid);
> 	return 0;
> }
> 
> static long slaveflush(va_list* ap){
> 	Biobuf* b;
> 
> 	b = va_arg(*ap, Biobuf*);
> 	va_end(*ap);
> 
> 	Bflush(b);
> 	return 0;
> }
> 
542c572
< 	int i, ignore, nnew, t;
---
> 	int i, ignore, nnew;
543a574,577
> 	Ioproc* io;
> 	ulong t;
> 
> 	if (imap->debug) fprint(2, "imap4read(doplumb=%d)\n", doplumb);
600,608c634,640
< 	t = imap->tag;
< 	if(pipeline)
< 	switch(rfork(RFPROC|RFMEM)){
< 	case -1:
< 		sysfatal("rfork: %r");
< 	default:
< 		break;
< 	case 0:
< 		for(m = mb->root->part; m != nil; m = m->next){
---
> 	io=0;	// gcc cant figure out that io isn't used uninitialized.
> 	if(pipeline) {
> 		io = ioproc();
> 		t = imap->tag;
> 
> 		for(m=mb->root->part; m!=nil; m=next){
> 			next = m->next;
611,615c643,644
< 			if(imap->debug)
< 				fprint(2, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
< 					t, (ulong)m->imapuid);
< 			Bprint(&imap->bout, "9X%d UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
< 				t++, (ulong)m->imapuid);
---
> 
> 			iocall(io,  slavereq, &imap->bout, t++, (ulong)m->imapuid);
617,618c646
< 		Bflush(&imap->bout);
< 		_exits(nil);
---
> 		iocall(io, slaveflush, &imap->bout);
627,629c655,656
< 		if(!pipeline){
< 			Bprint(&imap->bout, "9X%lud UID FETCH %lud (UID RFC822.SIZE BODY[])\r\n",
< 				(ulong)imap->tag, (ulong)m->imapuid);
---
> 		if (!pipeline){
> 			requestdoc(&imap->bout, (ulong)imap->tag++, (ulong)m->imapuid);
644,645c671,673
< 	if(pipeline)
< 		waitpid();
---
> 	if(pipeline) {
> 		closeioproc(io);
> 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-12-02 21:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-02 21:15 [9fans] upas/fs/imap4.c erik quanstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).