commit a09e80f9c414ffc815641d49836be3a2a6a07800 from: rsc date: Sun May 23 00:59:17 2004 UTC various debugging commit - 7e0e6522e576bc35b55a7182c23fb752cc1ec636 commit + a09e80f9c414ffc815641d49836be3a2a6a07800 blob - 8c58ab3d5aa7b83a0f1d503258c82597264f5512 blob + fb8f6c4c686fc03ecd839af854b9c3dd348e98c6 --- include/venti.h +++ include/venti.h @@ -446,6 +446,9 @@ uvlong vtfilegetsize(VtFile*); int vtfilesetsize(VtFile*, uvlong); int vtfileremove(VtFile*); +extern int chattyventi; +extern int ventidoublechecksha1; + #if defined(__cplusplus) } #endif blob - c16fe483b666db2f68d30cd6c78a2f9132e86013 blob + b9e866fc9da828b390058ae69120035b3d4be655 --- src/libventi/client.c +++ src/libventi/client.c @@ -2,11 +2,15 @@ #include #include +int ventidoublechecksha1 = 1; + static int vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in) { Packet *p; + if(chattyventi) + fprint(2, "%s -> %F\n", argv0, ou); p = vtfcallpack(ou); if(p == nil) return -1; @@ -16,6 +20,8 @@ vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in) packetfree(p); return -1; } + if(chattyventi) + fprint(2, "%s <- %F\n", argv0, in); if(in->type == VtRerror){ werrstr(in->error); vtfcallclear(in); @@ -70,11 +76,13 @@ vtreadpacket(VtConn *z, uchar score[VtScoreSize], uint packetfree(rx.data); return nil; } - packetsha1(rx.data, tx.score); - if(memcmp(score, tx.score, VtScoreSize) != 0){ - werrstr("read asked for %V got %V", score, tx.score); - packetfree(rx.data); - return nil; + if(ventidoublechecksha1){ + packetsha1(rx.data, tx.score); + if(memcmp(score, tx.score, VtScoreSize) != 0){ + werrstr("read asked for %V got %V", score, tx.score); + packetfree(rx.data); + return nil; + } } return rx.data; @@ -102,12 +110,15 @@ vtwritepacket(VtConn *z, uchar score[VtScoreSize], uin tx.type = VtTwrite; tx.dtype = type; tx.data = p; - packetsha1(p, score); + if(ventidoublechecksha1) + packetsha1(p, score); if(vtfcallrpc(z, &tx, &rx) < 0) return -1; - if(memcmp(score, rx.score, VtScoreSize) != 0){ - werrstr("sha1 hash mismatch: want %V got %V", score, rx.score); - return -1; + if(ventidoublechecksha1){ + if(memcmp(score, rx.score, VtScoreSize) != 0){ + werrstr("sha1 hash mismatch: want %V got %V", score, rx.score); + return -1; + } } return 0; } blob - 3fa6fbe56a264a8a98fe6bea45d56580128ad6f5 blob + 3f4197905c7771b0336f583749ca0ada7c88ee74 --- src/libventi/conn.c +++ src/libventi/conn.c @@ -3,6 +3,8 @@ #include #include "queue.h" +int chattyventi; + VtConn* vtconn(int infd, int outfd) { blob - 7ca6be8639a99af7d212a1b005b7464cebb174c6 blob + a10b7b453c826e327641923a6cf60b684f827a6d --- src/libventi/packet.c +++ src/libventi/packet.c @@ -113,7 +113,7 @@ packetalloc(void) p->last = nil; p->next = nil; -if(0)fprint(2, "packetalloc %p from %08lux %08lux %08lux\n", p, *((uint*)&p+2), *((uint*)&p+3), *((uint*)&p+4)); +//if(0)fprint(2, "packetalloc %p from %08lux %08lux %08lux\n", p, *((uint*)&p+2), *((uint*)&p+3), *((uint*)&p+4)); return p; } @@ -196,6 +196,7 @@ packetsplit(Packet *p, int n) Packet *pp; Frag *f, *ff; + if(0) fprint(2, "packetsplit %p %d\n", p, n); NOTFREE(p); if(n < 0 || n > p->size) { werrstr(EPacketSize); @@ -235,6 +236,7 @@ packetsplit(Packet *p, int n) int packetconsume(Packet *p, uchar *buf, int n) { + if(0) fprint(2, "packetconsume %p %d\n", p, n); NOTFREE(p); if(buf && packetcopy(p, buf, 0, n) < 0) return -1; @@ -246,6 +248,7 @@ packettrim(Packet *p, int offset, int n) { Frag *f, *ff; + if(0) fprint(2, "packettrim %p %d %d\n", p, offset, n); NOTFREE(p); if(offset < 0 || offset > p->size) { werrstr(EPacketOffset); @@ -341,6 +344,7 @@ packettrailer(Packet *p, int n) Mem *m; Frag *f; + if(0) fprint(2, "packettrailer %p %d\n", p, n); NOTFREE(p); if(n <= 0 || n > MaxFragSize) { werrstr(EPacketSize); @@ -603,7 +607,7 @@ uint packetsize(Packet *p) { NOTFREE(p); - if(0) { + if(1) { Frag *f; int size = 0; blob - c6119e451f1d2ba068663a9b23f672be73dc8388 blob + a39145305f655891da607ad2f121240f9cf08704 --- src/libventi/rpc.c +++ src/libventi/rpc.c @@ -3,6 +3,9 @@ * could turn this into a generic library routine rather * than keep it Venti specific. A user-level 9P client * could use something like this too. + * + * (Actually it does - this should be replaced with libmux, + * which should be renamed librpcmux.) * * This is a little more complicated than it might be * because we want it to work well within and without libthread. blob - a72a6c230c7af786988306a429bb0e66cb8c6339 blob + fd6fa57a9702e1dbddb890e6f8522fd38305ba19 --- src/libventi/send.c +++ src/libventi/send.c @@ -59,7 +59,9 @@ _vtrecv(VtConn *z) while(size < 2) { b = packettrailer(p, MaxFragSize); assert(b != nil); + if(0) fprint(2, "%d read hdr\n", getpid()); n = read(z->infd, b, MaxFragSize); + if(0) fprint(2, "%d got %d (%r)\n", getpid(), n); if(n <= 0) goto Err; size += n; @@ -72,13 +74,18 @@ _vtrecv(VtConn *z) size -= 2; while(size < len) { - n = len - size; - if(n > MaxFragSize) + // n = len - size; + // if(n > MaxFragSize) n = MaxFragSize; b = packettrailer(p, n); - if(readn(z->infd, b, n) != n) + if(0) fprint(2, "%d read body %d\n", getpid(), n); + n = read(z->infd, b, n); + if(0) fprint(2, "%d got %d (%r)\n", getpid(), n); + if(n > 0) + size += n; + packettrim(p, 0, size); + if(n <= 0) goto Err; - size += n; } p = packetsplit(p, len); return p; blob - 837cbf45ce28fcb8a3f5e443a74deff509df51f1 blob + 8aa95798caed57b08c43adcdeab82accf5bb43ad --- src/libventi/server.c +++ src/libventi/server.c @@ -102,7 +102,12 @@ connproc(void *v) Packet *p; VtReq *r; int fd; +static int first=1; +if(first){ + first=0; + fmtinstall('F', vtfcallfmt); +} r = nil; sc = v; sc->c = nil; @@ -139,6 +144,8 @@ connproc(void *v) fprint(2, "bad packet on %s: %r\n", sc->dir); continue; } + if(chattyventi) + fprint(2, "%s <- %F\n", argv0, &r->tx); packetfree(p); if(r->tx.type == VtTgoodbye) break; @@ -182,6 +189,8 @@ vtrespond(VtReq *r) abort(); if(r->rx.type != r->tx.type+1 && r->rx.type != VtRerror) abort(); + if(chattyventi) + fprint(2, "%s -> %F\n", argv0, &r->rx); if((p = vtfcallpack(&r->rx)) == nil){ fprint(2, "fcallpack on %s: %r\n", sc->dir); packetfree(p);