various debugging
This commit is contained in:
parent
7e0e6522e5
commit
a09e80f9c4
7 changed files with 54 additions and 15 deletions
|
|
@ -446,6 +446,9 @@ uvlong vtfilegetsize(VtFile*);
|
||||||
int vtfilesetsize(VtFile*, uvlong);
|
int vtfilesetsize(VtFile*, uvlong);
|
||||||
int vtfileremove(VtFile*);
|
int vtfileremove(VtFile*);
|
||||||
|
|
||||||
|
extern int chattyventi;
|
||||||
|
extern int ventidoublechecksha1;
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,15 @@
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <venti.h>
|
#include <venti.h>
|
||||||
|
|
||||||
|
int ventidoublechecksha1 = 1;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in)
|
vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in)
|
||||||
{
|
{
|
||||||
Packet *p;
|
Packet *p;
|
||||||
|
|
||||||
|
if(chattyventi)
|
||||||
|
fprint(2, "%s -> %F\n", argv0, ou);
|
||||||
p = vtfcallpack(ou);
|
p = vtfcallpack(ou);
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -16,6 +20,8 @@ vtfcallrpc(VtConn *z, VtFcall *ou, VtFcall *in)
|
||||||
packetfree(p);
|
packetfree(p);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if(chattyventi)
|
||||||
|
fprint(2, "%s <- %F\n", argv0, in);
|
||||||
if(in->type == VtRerror){
|
if(in->type == VtRerror){
|
||||||
werrstr(in->error);
|
werrstr(in->error);
|
||||||
vtfcallclear(in);
|
vtfcallclear(in);
|
||||||
|
|
@ -70,12 +76,14 @@ vtreadpacket(VtConn *z, uchar score[VtScoreSize], uint type, int n)
|
||||||
packetfree(rx.data);
|
packetfree(rx.data);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
if(ventidoublechecksha1){
|
||||||
packetsha1(rx.data, tx.score);
|
packetsha1(rx.data, tx.score);
|
||||||
if(memcmp(score, tx.score, VtScoreSize) != 0){
|
if(memcmp(score, tx.score, VtScoreSize) != 0){
|
||||||
werrstr("read asked for %V got %V", score, tx.score);
|
werrstr("read asked for %V got %V", score, tx.score);
|
||||||
packetfree(rx.data);
|
packetfree(rx.data);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return rx.data;
|
return rx.data;
|
||||||
}
|
}
|
||||||
|
|
@ -102,13 +110,16 @@ vtwritepacket(VtConn *z, uchar score[VtScoreSize], uint type, Packet *p)
|
||||||
tx.type = VtTwrite;
|
tx.type = VtTwrite;
|
||||||
tx.dtype = type;
|
tx.dtype = type;
|
||||||
tx.data = p;
|
tx.data = p;
|
||||||
|
if(ventidoublechecksha1)
|
||||||
packetsha1(p, score);
|
packetsha1(p, score);
|
||||||
if(vtfcallrpc(z, &tx, &rx) < 0)
|
if(vtfcallrpc(z, &tx, &rx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if(ventidoublechecksha1){
|
||||||
if(memcmp(score, rx.score, VtScoreSize) != 0){
|
if(memcmp(score, rx.score, VtScoreSize) != 0){
|
||||||
werrstr("sha1 hash mismatch: want %V got %V", score, rx.score);
|
werrstr("sha1 hash mismatch: want %V got %V", score, rx.score);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
#include <venti.h>
|
#include <venti.h>
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
|
|
||||||
|
int chattyventi;
|
||||||
|
|
||||||
VtConn*
|
VtConn*
|
||||||
vtconn(int infd, int outfd)
|
vtconn(int infd, int outfd)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ packetalloc(void)
|
||||||
p->last = nil;
|
p->last = nil;
|
||||||
p->next = 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;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
@ -196,6 +196,7 @@ packetsplit(Packet *p, int n)
|
||||||
Packet *pp;
|
Packet *pp;
|
||||||
Frag *f, *ff;
|
Frag *f, *ff;
|
||||||
|
|
||||||
|
if(0) fprint(2, "packetsplit %p %d\n", p, n);
|
||||||
NOTFREE(p);
|
NOTFREE(p);
|
||||||
if(n < 0 || n > p->size) {
|
if(n < 0 || n > p->size) {
|
||||||
werrstr(EPacketSize);
|
werrstr(EPacketSize);
|
||||||
|
|
@ -235,6 +236,7 @@ packetsplit(Packet *p, int n)
|
||||||
int
|
int
|
||||||
packetconsume(Packet *p, uchar *buf, int n)
|
packetconsume(Packet *p, uchar *buf, int n)
|
||||||
{
|
{
|
||||||
|
if(0) fprint(2, "packetconsume %p %d\n", p, n);
|
||||||
NOTFREE(p);
|
NOTFREE(p);
|
||||||
if(buf && packetcopy(p, buf, 0, n) < 0)
|
if(buf && packetcopy(p, buf, 0, n) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -246,6 +248,7 @@ packettrim(Packet *p, int offset, int n)
|
||||||
{
|
{
|
||||||
Frag *f, *ff;
|
Frag *f, *ff;
|
||||||
|
|
||||||
|
if(0) fprint(2, "packettrim %p %d %d\n", p, offset, n);
|
||||||
NOTFREE(p);
|
NOTFREE(p);
|
||||||
if(offset < 0 || offset > p->size) {
|
if(offset < 0 || offset > p->size) {
|
||||||
werrstr(EPacketOffset);
|
werrstr(EPacketOffset);
|
||||||
|
|
@ -341,6 +344,7 @@ packettrailer(Packet *p, int n)
|
||||||
Mem *m;
|
Mem *m;
|
||||||
Frag *f;
|
Frag *f;
|
||||||
|
|
||||||
|
if(0) fprint(2, "packettrailer %p %d\n", p, n);
|
||||||
NOTFREE(p);
|
NOTFREE(p);
|
||||||
if(n <= 0 || n > MaxFragSize) {
|
if(n <= 0 || n > MaxFragSize) {
|
||||||
werrstr(EPacketSize);
|
werrstr(EPacketSize);
|
||||||
|
|
@ -603,7 +607,7 @@ uint
|
||||||
packetsize(Packet *p)
|
packetsize(Packet *p)
|
||||||
{
|
{
|
||||||
NOTFREE(p);
|
NOTFREE(p);
|
||||||
if(0) {
|
if(1) {
|
||||||
Frag *f;
|
Frag *f;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
* than keep it Venti specific. A user-level 9P client
|
* than keep it Venti specific. A user-level 9P client
|
||||||
* could use something like this too.
|
* 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
|
* This is a little more complicated than it might be
|
||||||
* because we want it to work well within and without libthread.
|
* because we want it to work well within and without libthread.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,9 @@ _vtrecv(VtConn *z)
|
||||||
while(size < 2) {
|
while(size < 2) {
|
||||||
b = packettrailer(p, MaxFragSize);
|
b = packettrailer(p, MaxFragSize);
|
||||||
assert(b != nil);
|
assert(b != nil);
|
||||||
|
if(0) fprint(2, "%d read hdr\n", getpid());
|
||||||
n = read(z->infd, b, MaxFragSize);
|
n = read(z->infd, b, MaxFragSize);
|
||||||
|
if(0) fprint(2, "%d got %d (%r)\n", getpid(), n);
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
size += n;
|
size += n;
|
||||||
|
|
@ -72,13 +74,18 @@ _vtrecv(VtConn *z)
|
||||||
size -= 2;
|
size -= 2;
|
||||||
|
|
||||||
while(size < len) {
|
while(size < len) {
|
||||||
n = len - size;
|
// n = len - size;
|
||||||
if(n > MaxFragSize)
|
// if(n > MaxFragSize)
|
||||||
n = MaxFragSize;
|
n = MaxFragSize;
|
||||||
b = packettrailer(p, n);
|
b = packettrailer(p, n);
|
||||||
if(readn(z->infd, b, n) != n)
|
if(0) fprint(2, "%d read body %d\n", getpid(), n);
|
||||||
goto Err;
|
n = read(z->infd, b, n);
|
||||||
|
if(0) fprint(2, "%d got %d (%r)\n", getpid(), n);
|
||||||
|
if(n > 0)
|
||||||
size += n;
|
size += n;
|
||||||
|
packettrim(p, 0, size);
|
||||||
|
if(n <= 0)
|
||||||
|
goto Err;
|
||||||
}
|
}
|
||||||
p = packetsplit(p, len);
|
p = packetsplit(p, len);
|
||||||
return p;
|
return p;
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,12 @@ connproc(void *v)
|
||||||
Packet *p;
|
Packet *p;
|
||||||
VtReq *r;
|
VtReq *r;
|
||||||
int fd;
|
int fd;
|
||||||
|
static int first=1;
|
||||||
|
|
||||||
|
if(first){
|
||||||
|
first=0;
|
||||||
|
fmtinstall('F', vtfcallfmt);
|
||||||
|
}
|
||||||
r = nil;
|
r = nil;
|
||||||
sc = v;
|
sc = v;
|
||||||
sc->c = nil;
|
sc->c = nil;
|
||||||
|
|
@ -139,6 +144,8 @@ connproc(void *v)
|
||||||
fprint(2, "bad packet on %s: %r\n", sc->dir);
|
fprint(2, "bad packet on %s: %r\n", sc->dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(chattyventi)
|
||||||
|
fprint(2, "%s <- %F\n", argv0, &r->tx);
|
||||||
packetfree(p);
|
packetfree(p);
|
||||||
if(r->tx.type == VtTgoodbye)
|
if(r->tx.type == VtTgoodbye)
|
||||||
break;
|
break;
|
||||||
|
|
@ -182,6 +189,8 @@ vtrespond(VtReq *r)
|
||||||
abort();
|
abort();
|
||||||
if(r->rx.type != r->tx.type+1 && r->rx.type != VtRerror)
|
if(r->rx.type != r->tx.type+1 && r->rx.type != VtRerror)
|
||||||
abort();
|
abort();
|
||||||
|
if(chattyventi)
|
||||||
|
fprint(2, "%s -> %F\n", argv0, &r->rx);
|
||||||
if((p = vtfcallpack(&r->rx)) == nil){
|
if((p = vtfcallpack(&r->rx)) == nil){
|
||||||
fprint(2, "fcallpack on %s: %r\n", sc->dir);
|
fprint(2, "fcallpack on %s: %r\n", sc->dir);
|
||||||
packetfree(p);
|
packetfree(p);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue