From 75cf5706b536fbb401a7127fea1ef925eff3d24b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 23 Aug 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-08-23 --- ip/il.c | 13 +++++++--- port/chan.c | 4 ++- port/devssl.c | 69 +++++++++++++++------------------------------------ 3 files changed, 32 insertions(+), 54 deletions(-) diff --git a/ip/il.c b/ip/il.c index 129bd60d7f31447d50b8cfd922e993b5720af380..192976fde4a30632f42e01400f29e1a7269242c8 100644 --- a/ip/il.c +++ b/ip/il.c @@ -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), diff --git a/port/chan.c b/port/chan.c index 4e975a3b61a5d869051373d934a881ad698a6799..494dcea91509614d5b4f15d02b65c9f36648b598 100644 --- a/port/chan.c +++ b/port/chan.c @@ -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); diff --git a/port/devssl.c b/port/devssl.c index 598355ea0f7504dd79f850d5ada21cafd3421fd3..aa301f0cc841f0cb624ef6b93704676988eeef13 100644 --- a/port/devssl.c +++ b/port/devssl.c @@ -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= 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