aboutsummaryrefslogtreecommitdiff
path: root/src/libventi
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-13 18:35:32 +0000
committerrsc <devnull@localhost>2005-02-13 18:35:32 +0000
commit18b1814390e9d3bff470de940b448dfddf87187d (patch)
tree3666c50fe00ee74af90b19c378c31babd1891e5a /src/libventi
parent8f4871fd2e9806293b0d6756402b8a019c732985 (diff)
downloadplan9port-18b1814390e9d3bff470de940b448dfddf87187d.tar.gz
plan9port-18b1814390e9d3bff470de940b448dfddf87187d.tar.bz2
plan9port-18b1814390e9d3bff470de940b448dfddf87187d.zip
use nci to label connections
Diffstat (limited to 'src/libventi')
-rw-r--r--src/libventi/conn.c8
-rw-r--r--src/libventi/dial.c6
-rw-r--r--src/libventi/send.c4
-rw-r--r--src/libventi/server.c14
4 files changed, 29 insertions, 3 deletions
diff --git a/src/libventi/conn.c b/src/libventi/conn.c
index 3f419790..990e7db2 100644
--- a/src/libventi/conn.c
+++ b/src/libventi/conn.c
@@ -9,6 +9,7 @@ VtConn*
vtconn(int infd, int outfd)
{
VtConn *z;
+ NetConnInfo *nci;
z = vtmallocz(sizeof(VtConn));
z->tagrend.l = &z->lk;
@@ -16,6 +17,13 @@ vtconn(int infd, int outfd)
z->infd = infd;
z->outfd = outfd;
z->part = packetalloc();
+ nci = getnetconninfo(nil, infd);
+ if(nci == nil)
+ snprint(z->addr, sizeof z->addr, "/dev/fd/%d", infd);
+ else{
+ strecpy(z->addr, z->addr+sizeof z->addr, nci->raddr);
+ freenetconninfo(nci);
+ }
return z;
}
diff --git a/src/libventi/dial.c b/src/libventi/dial.c
index b8234b3d..060b93f6 100644
--- a/src/libventi/dial.c
+++ b/src/libventi/dial.c
@@ -7,6 +7,7 @@ vtdial(char *addr)
{
char *na;
int fd;
+ VtConn *z;
if(addr == nil)
addr = getenv("venti");
@@ -17,5 +18,8 @@ vtdial(char *addr)
if((fd = dial(na, nil, nil, nil)) < 0)
return nil;
- return vtconn(fd, fd);
+ z = vtconn(fd, fd);
+ if(z)
+ strecpy(z->addr, z->addr+sizeof z->addr, na);
+ return z;
}
diff --git a/src/libventi/send.c b/src/libventi/send.c
index bcd78507..642d4de3 100644
--- a/src/libventi/send.c
+++ b/src/libventi/send.c
@@ -37,11 +37,13 @@ _vtsend(VtConn *z, Packet *p)
if(n == 0)
break;
if(write(z->outfd, ioc.addr, ioc.len) < ioc.len){
+ vtlog(VtServerLog, "%s: sending packet %p: %r", z->addr, p);
packetfree(p);
return 0;
}
packetconsume(p, nil, ioc.len);
}
+ vtlog(VtServerLog, "%s: sent packet %p", z->addr, p);
packetfree(p);
return 1;
}
@@ -106,8 +108,10 @@ _vtrecv(VtConn *z)
ventirecvbytes += len;
ventirecvpackets++;
p = packetsplit(p, len);
+ vtlog(VtServerLog, "%s: read packet %p len %d", z->addr, p, len);
return p;
Err:
+ vtlog(VtServerLog, "%s: error reading packet: %r", z->addr);
return nil;
}
diff --git a/src/libventi/server.c b/src/libventi/server.c
index 391d7373..ae64b327 100644
--- a/src/libventi/server.c
+++ b/src/libventi/server.c
@@ -31,6 +31,8 @@ struct VtSrv
static void listenproc(void*);
static void connproc(void*);
+char *VtServerLog = "libventi/server";
+
static void
scincref(VtSconn *sc)
{
@@ -140,10 +142,12 @@ if(first && chattyventi){
while((p = vtrecv(c)) != nil){
r = vtmallocz(sizeof(VtReq));
if(vtfcallunpack(&r->tx, p) < 0){
- packetfree(p);
+ vtlog(VtServerLog, "%s: recv bad packet %p: %r", c->addr, p);
fprint(2, "bad packet on %s: %r\n", sc->dir);
+ packetfree(p);
continue;
}
+ vtlog(VtServerLog, "%s: recv packet %p (%F)", c->addr, p, &r->tx);
if(chattyventi)
fprint(2, "%s <- %F\n", argv0, &r->tx);
packetfree(p);
@@ -175,7 +179,11 @@ out:
VtReq*
vtgetreq(VtSrv *srv)
{
- return _vtqrecv(srv->q);
+ VtReq *r;
+
+ r = _vtqrecv(srv->q);
+ vtlog(VtServerLog, "%s: vtgetreq %F\n", ((VtSconn*)r->sc)->c->addr, &r->tx);
+ return r;
}
void
@@ -192,11 +200,13 @@ vtrespond(VtReq *r)
if(chattyventi)
fprint(2, "%s -> %F\n", argv0, &r->rx);
if((p = vtfcallpack(&r->rx)) == nil){
+ vtlog(VtServerLog, "%s: vtfcallpack %F: %r", sc->c->addr, &r->rx);
fprint(2, "fcallpack on %s: %r\n", sc->dir);
packetfree(p);
vtfcallclear(&r->rx);
return;
}
+ vtlog(VtServerLog, "%s: send packet %p (%F)", sc->c->addr, p, &r->rx);
if(vtsend(sc->c, p) < 0)
fprint(2, "vtsend %F: %r\n", &r->rx);
scdecref(sc);