Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <venti.h>
4 #include "queue.h"
6 int chattyventi;
8 VtConn*
9 vtconn(int infd, int outfd)
10 {
11 VtConn *z;
13 z = vtmallocz(sizeof(VtConn));
14 z->tagrend.l = &z->lk;
15 z->rpcfork.l = &z->lk;
16 z->infd = infd;
17 z->outfd = outfd;
18 z->part = packetalloc();
19 return z;
20 }
22 void
23 vtfreeconn(VtConn *z)
24 {
25 vthangup(z);
26 qlock(&z->lk);
27 for(;;){
28 if(z->readq)
29 _vtqhangup(z->readq);
30 else if(z->writeq)
31 _vtqhangup(z->writeq);
32 else
33 break;
34 rsleep(&z->rpcfork);
35 }
36 packetfree(z->part);
37 vtfree(z);
38 }