commit 319642b201f0fd5ebbc4dfb32bd5a83fd79514f8
parent b2e81933e8ff899320b548512188a786242a57a3
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 9 Feb 2006 14:17:50 +0100
fixed a small bug in wmiifs and wmiikeys, if a mounted 9P server dies, the client of wmiifs is closed as well and doesn;t waits forever ;)
Diffstat:
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/cmd/wmiifs.c b/cmd/wmiifs.c
@@ -100,6 +100,8 @@ xunbind(Bind *b) {
cext_array_detach((void **)bind, b, &bindsz);
nbind--;
ixp_client_deinit(&b->client);
+ if(b->tx && b->tx->close)
+ b->tx->close(b->tx);
free(b);
}
@@ -113,7 +115,7 @@ close_rx_conn(IXPConn *c)
}
static Bind *
-xbind(char *address, unsigned int fid, IXPConn *tx)
+xbind(char *address, unsigned int fid)
{
char addr[256];
Bind *b = cext_emallocz(sizeof(Bind));
@@ -124,7 +126,6 @@ xbind(char *address, unsigned int fid, IXPConn *tx)
return nil;
}
b->rx = ixp_server_open_conn(&srv, b->client.fd, do_mnt_fcall, close_rx_conn);
- b->tx = tx;
bind = (Bind **)cext_array_attach((void **)bind, b, sizeof(Bind *), &bindsz);
nbind++;
return b;
@@ -390,7 +391,7 @@ xwalk(IXPConn *c, Fcall *fcall)
unsigned int i;
Bind *b;
- if(!(b = xbind(mnt->address, fcall->fid, c)))
+ if(!(b = xbind(mnt->address, fcall->fid)))
return Enoserv;
memcpy(&b->client.fcall, fcall, sizeof(Fcall));
@@ -408,6 +409,7 @@ xwalk(IXPConn *c, Fcall *fcall)
xunbind(b);
return Enofile;
}
+ b->tx = c;
return nil;
}
else {
diff --git a/cmd/wmiikeys.c b/cmd/wmiikeys.c
@@ -637,6 +637,8 @@ xwrite(IXPConn *c, Fcall *fcall)
destroy_key(k);
}
}
+ if(!fcall->count)
+ break;
memcpy(fcallbuf, fcall->data, fcall->count);
fcallbuf[fcall->count] = 0;
if(fcall->offset) {
@@ -656,6 +658,8 @@ xwrite(IXPConn *c, Fcall *fcall)
memcpy(last, fcall->data, fcall->count);
while(p2 - fcallbuf < fcall->count) {
p1 = strchr(p2, '\n');
+ if(!p1)
+ return "cannot grab, no \n supplied";
*p1 = 0;
k = create_key(p2);
key = (Key **)cext_array_attach((void **)key, k, sizeof(Key *), &keysz);