From cse.psu.edu!9fans-outgoing-owner Mon Dec 11 15:44:11 1995
Received: from psuvax1.cse.psu.edu ([130.203.1.6]) by cannon.ecf.toronto.edu with SMTP id <9696>; Mon, 11 Dec 1995 15:44:01 -0500
Received: by psuvax1.cse.psu.edu id <34096>; Mon, 11 Dec 1995 14:58:58 -0500
Received: from plan9.cs.york.ac.uk ([144.32.33.120]) by psuvax1.cse.psu.edu with SMTP id <34095>; Mon, 11 Dec 1995 14:15:44 -0500
From:	forsyth@plan9.cs.york.ac.uk
To:	9fans@cse.psu.edu
Date:	Mon, 11 Dec 1995 14:10:18 -0500
subject: APE collides in select rendezvous
Message-Id: <95Dec11.141544est.34095@psuvax1.cse.psu.edu>
Sender: owner-9fans@cse.psu.edu
Precedence: bulk
Reply-To: 9fans@cse.psu.edu
Status: RO

vortex% diff old /sys/src/ape/lib/ap/plan9/_buf.c
59c59
< 		_RFORK(RFREND);
---
> 		_RFORK(RFNAMEG);	/* ideally, RFREND */

RFREND is defined in ap/plan9's sys9.h, but isn't in plan 9 as distributed

RFNAMEG will just have to do.

the symptom is that an APE program that uses select but also forks
and execs another program using select will end up with one side
or the other, or both, being confused when the rendezvous calls clash.


From cse.psu.edu!9fans-outgoing-owner Thu Mar  7 15:09:38 1996
Received: from colossus.cse.psu.edu ([130.203.1.2]) by cannon.ecf.toronto.edu with SMTP id <9986>; Thu, 7 Mar 1996 15:09:33 -0500
Received: by colossus.cse.psu.edu id <78705>; Thu, 7 Mar 1996 15:05:11 -0500
Received: from galapagos.cse.psu.edu ([130.203.2.12]) by colossus.cse.psu.edu with SMTP id <78712>; Thu, 7 Mar 1996 15:03:56 -0500
Received: by galapagos.cse.psu.edu id <12686>; Thu, 7 Mar 1996 14:57:17 -0500
From:	Scott Schwartz <schwartz@galapagos.cse.psu.edu>
To:	9fans@cse.psu.edu
Subject: ape, gettimeofday.c
Message-Id: <96Mar7.145717est.12686@galapagos.cse.psu.edu>
Date:	Thu, 7 Mar 1996 14:57:08 -0500
Sender: owner-9fans@cse.psu.edu
Precedence: bulk
Reply-To: 9fans@cse.psu.edu
Status: RO

Pgp is much happier if gettimeofday returns something for
the usec field.  Here's a version that tries to do that.

#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>

static int
ms(void) 
{
	char b[20];
	static int f = -1;

	/* XXX - should use native plan9 syscalls herein */
	memset(b, 0, sizeof(b));
	if (f < 0) {
		f = open("/dev/msec", O_RDONLY);
		fcntl(f, FD_CLOEXEC, 1);
	}
	if (f >= 0) {
		lseek(f, 0, 0);
		read(f, b, sizeof(b));
	}
	return atol(b) % 1000;
}

int
gettimeofday(struct timeval *tp, struct timezone *tzp)
{
	tp->tv_sec = time(0);
	tp->tv_usec = ms() * 1000;

	if(tzp) {
		tzp->tz_minuteswest = 240;
		tzp->tz_dsttime = 1;
	}

	return 0;
}


From cse.psu.edu!owner-9fans Sun Aug  4 17:20:47 1996
Received: from cse.psu.edu ([130.203.3.50]) by cannon.ecf.toronto.edu with SMTP id <1247>; Sun, 4 Aug 1996 17:20:34 -0400
Received: from localhost (majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) with SMTP id RAA01610; Sun, 4 Aug 1996 17:20:46 -0400 (EDT)
Received: by claven.cse.psu.edu (bulk_mailer v1.5); Sun, 4 Aug 1996 17:15:00 -0400
Received: (from majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) id RAA01549 for 9fans-outgoing; Sun, 4 Aug 1996 17:14:54 -0400 (EDT)
X-Authentication-Warning: claven.cse.psu.edu: majordom set sender to owner-9fans using -f
Received: from angora.cse.psu.edu (nb3ppp35.cac.psu.edu [146.186.17.35]) by cse.psu.edu (8.7.5/8.7.3) with SMTP id RAA01544 for <9fans@cse.psu.edu>; Sun, 4 Aug 1996 17:14:47 -0400 (EDT)
From:	scott@angora.cse.psu.edu
Message-Id: <199608042114.RAA01544@cse.psu.edu>
To:	9fans@cse.psu.edu
Date:	Sun, 4 Aug 1996 17:00:35 -0400
Sender: owner-9fans@cse.psu.edu
Reply-To: 9fans@cse.psu.edu
Precedence: bulk
Status: RO

I've noticed that APE has some byte order problems in the bsd compatability 
code. The bsd interface uses network order exclusively, while the ape code
sometimes assumed host order. There have already been some updates on 
this topic: enclosed are a few additional changes. 

One problem that isn't fixed is that gethostbyaddr calls gethostbyname
with the ascii dotted-quad form of the network address.  That's a good
idea, except that the connection server only asks dns to return ip 
addresses, even though it returns the whole record if it came from ndb.
gethostbyname could be modified to get the answer, but I think cs is
a more appropriate place for it.

diff inet_addr.c /n/cd/sys/src/ape/lib/bsd/inet_addr.c
50d49
< 	x = htonl(x);
diff inet_ntoa.c /n/cd/sys/src/ape/lib/bsd/inet_ntoa.c
19c19
< 	x = ntohl(in.s_addr);
---
> 	x = in.s_addr;
diff gethostbyaddr.c /n/cd/sys/src/ape/lib/bsd/gethostbyaddr.c
23c23,24
< 	memcpy(&x.s_addr, addr, sizeof(x.s_addr));
---
> 	x.s_addr = (addr[0]<<24)|(addr[1]<<16)|(addr[2]<<8)|addr[3];
> 
diff gethostbyname.c /n/cd/sys/src/ape/lib/bsd/gethostbyname.c
98d97
< 			x = ntohl(x);


From cse.psu.edu!owner-9fans Mon Sep  2 00:33:10 1996
Received: from cse.psu.edu ([130.203.3.50]) by cannon.ecf.toronto.edu with SMTP id <1015>; Mon, 2 Sep 1996 00:33:08 -0400
Received: from localhost (majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) with SMTP id AAA08538; Mon, 2 Sep 1996 00:24:54 -0400 (EDT)
Received: by claven.cse.psu.edu (bulk_mailer v1.5); Mon, 2 Sep 1996 00:21:48 -0400
Received: (from majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) id AAA08495 for 9fans-outgoing; Mon, 2 Sep 1996 00:21:40 -0400 (EDT)
X-Authentication-Warning: claven.cse.psu.edu: majordom set sender to owner-9fans using -f
Received: from angora.cse.psu.edu (nb5ppp164.cac.psu.edu [146.186.17.164]) by cse.psu.edu (8.7.5/8.7.3) with SMTP id AAA08488 for <9fans@cse.psu.edu>; Mon, 2 Sep 1996 00:21:28 -0400 (EDT)
From:	scott@angora.cse.psu.edu
Message-Id: <199609020421.AAA08488@cse.psu.edu>
To:	9fans@cse.psu.edu
Date:	Mon, 2 Sep 1996 00:16:19 -0400
Sender: owner-9fans@cse.psu.edu
Reply-To: 9fans@cse.psu.edu
Precedence: bulk
Status: RO

One more ape bug...  A common unix idiom is bind followed by listen.
In ape, bind sets the socket's port, and but listen also tries to do
that.  To avoid an error in that case, I propose listen.c:139 be 
modified as follows:

		if(lip->sin_port >= 0) {
			if (write(cfd, "bind 0", 6) < 0) {
				errno = EGREG;
				close(cfd);
				return -1;
			}
			sprintf(msg, "announce %d", ntohs(lip->sin_port));


From cse.psu.edu!owner-9fans Thu Sep  5 03:11:52 1996
Received: from cse.psu.edu ([130.203.3.50]) by cannon.ecf.toronto.edu with SMTP id <1014>; Thu, 5 Sep 1996 03:11:47 -0400
Received: from localhost (majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) with SMTP id DAA22067; Thu, 5 Sep 1996 03:11:20 -0400 (EDT)
Received: by claven.cse.psu.edu (bulk_mailer v1.5); Thu, 5 Sep 1996 03:10:34 -0400
Received: (from majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) id DAA22019 for 9fans-outgoing; Thu, 5 Sep 1996 03:10:27 -0400 (EDT)
X-Authentication-Warning: claven.cse.psu.edu: majordom set sender to owner-9fans using -f
Received: from galapagos.cse.psu.edu (root@galapagos.cse.psu.edu [130.203.2.12]) by cse.psu.edu (8.7.5/8.7.3) with SMTP id DAA22015 for <9fans@cse.psu.edu>; Thu, 5 Sep 1996 03:10:22 -0400 (EDT)
Received: by galapagos.cse.psu.edu id <12690>; Thu, 5 Sep 1996 03:09:41 -0400
From:	Scott Schwartz <schwartz@galapagos.cse.psu.edu>
To:	9fans@cse.psu.edu
Subject: ape rename bug
Message-Id: <96Sep5.030941edt.12690@galapagos.cse.psu.edu>
Date:	Thu, 5 Sep 1996 03:09:37 -0400
Sender: owner-9fans@cse.psu.edu
Reply-To: 9fans@cse.psu.edu
Precedence: bulk
Status: RO

In APE, if rename has to copy, it never deletes the source file.
In that case, something like t