~kris/9p

9hist

75cf5706b536fbb401a7127fea1ef925eff3d24b — David du Colombier 25 years ago 8eb8147
Plan 9 from Bell Labs 2001-08-23
3 files changed, 32 insertions(+), 54 deletions(-)

M ip/il.c
M port/chan.c
M port/devssl.c
M ip/il.c => ip/il.c +9 -4
@@ 537,7 537,7 @@ iliput(Proto *il, Ipifc*, Block *bp)
	uchar laddr[IPaddrlen];
	ushort sp, dp, csum;
	int plen, illen;
	Conv *s;
	Conv *new, *s;
	Ilpriv *ipriv;

	ipriv = il->priv;


@@ 596,14 596,15 @@ iliput(Proto *il, Ipifc*, Block *bp)
			goto raise;
		}

		s = Fsnewcall(s, raddr, dp, laddr, sp);
		if(s == nil){
		new = Fsnewcall(s, raddr, dp, laddr, sp);
		if(new == nil){
			qunlock(il);
			netlog(il->f, Logil, "il: bad newcall %I/%ud->%ud\n", raddr, sp, dp);
			ilsendctl(s, ih, Ilclose, 0, nhgetl(ih->ilid), 0);
			goto raise;
		}
	
		s = new;

		ic = (Ilcb*)s->ptcl;
	
		ic->conv = s;


@@ 1014,6 1015,10 @@ ilsendctl(Conv *ipc, Ilhdr *inih, int type, ulong id, ulong ack, int ilspec)

	if(ilcksum)
		hnputs(ih->ilsum, ptclcsum(bp, IL_IPSIZE, IL_HDRSIZE));
if(ipc==nil)
	panic("ipc is nil caller is %.8lux", getcallerpc(&ipc));
if(ipc->p==nil)
	panic("ipc->p is nil");

	netlog(ipc->p->f, Logilmsg, "ctl(%s id %d ack %d %d->%d)\n",
		iltype[ih->iltype], nhgetl(ih->ilid), nhgetl(ih->ilack), 

M port/chan.c => port/chan.c +3 -1
@@ 1099,7 1099,9 @@ if(c->umh != nil){
	print("cunique umh\n");
	putmhead(c->umh);
}
			if(c->qid.type&QTDIR)

			/* only save the mount head if it's a multiple element union */
			if(m && m->mount && m->mount->next)
				c->umh = m;
			else
				putmhead(m);

M port/devssl.c => port/devssl.c +20 -49
@@ 70,20 70,19 @@ struct Dstate
	int	perm;
};

Lock	dslock;
int	dshiwat;
int	maxdstate = 128;
char	**dsname;
Dstate	**dstate;
char	*encalgs;
char	*hashalgs;

enum
{
	Maxdmsg=	1<<16,
	Maxdstate=	64
	Maxdstate=	128,	/* must be a power of 2 */
};

Lock	dslock;
int	dshiwat;
char	*dsname[Maxdstate];
Dstate	*dstate[Maxdstate];
char	*encalgs;
char	*hashalgs;

enum{
	Qtopdir		= 1,	/* top level directory */
	Qprotodir,


@@ 1173,12 1172,6 @@ sslinit(void)
	int n;
	char *cp;

	if((dstate = smalloc(sizeof(Dstate*) * maxdstate)) == 0)
		panic("sslinit");

	if((dsname = smalloc(sizeof(char*) * maxdstate)) == 0)
		panic("sslinit");

	n = 1;
	for(e = encrypttab; e->name != nil; e++)
		n += strlen(e->name) + 1;


@@ 1397,6 1390,10 @@ buftochan(char *p)
	if(fd < 0)
		error(Ebadarg);
	c = fdtochan(fd, -1, 0, 1);	/* error check and inc ref */
	if(devtab[c->type] == &ssldevtab){
		cclose(c);
		error("cannot ssl encrypt devssl files");
	}
	return c;
}



@@ 1422,51 1419,25 @@ sslhangup(Dstate *s)
static Dstate*
dsclone(Chan *ch)
{
	Dstate **pp, **ep, **np;
	char **names;
	int newmax;
	int i;
	Dstate *ret;

	if(waserror()) {
		unlock(&dslock);
		nexterror();
	}
	lock(&dslock);
	ep = &dstate[maxdstate];
	for(pp = dstate; pp < ep; pp++) {
		if(*pp == 0) {
			dsnew(ch, pp);
	ret = nil;
	for(i=0; i<Maxdstate; i++){
		if(dstate[i] == nil){
			dsnew(ch, &dstate[i]);
			ret = dstate[i];
			break;
		}
	}
	if(pp >= ep) {
		if(maxdstate >= Maxdstate) {
			unlock(&dslock);
			poperror();
			return 0;
		}
		newmax = 2 * maxdstate;
		if(newmax > Maxdstate)
			newmax = Maxdstate;

		np = smalloc(sizeof(Dstate*) * newmax);
		if(np == 0)
			error(Enomem);
		memmove(np, dstate, sizeof(Dstate*) * maxdstate);
		dstate = np;
		pp = &dstate[maxdstate];

		names = smalloc(sizeof(char*) * newmax);
		if(names == 0)
			error(Enomem);
		memmove(names, dsname, sizeof(char*) * maxdstate);
		dsname = names;

		maxdstate = newmax;
		dsnew(ch, pp);
	}
	unlock(&dslock);
	poperror();
	return *pp;
	return ret;
}

static void