plan9port/src/libventi/conn.c

39 lines
532 B
C
Raw Normal View History

2003-11-23 18:19:58 +00:00
#include <u.h>
#include <libc.h>
#include <venti.h>
#include "queue.h"
2004-05-23 00:59:17 +00:00
int chattyventi;
2003-11-23 18:19:58 +00:00
VtConn*
vtconn(int infd, int outfd)
{
VtConn *z;
z = vtmallocz(sizeof(VtConn));
z->tagrend.l = &z->lk;
z->rpcfork.l = &z->lk;
z->infd = infd;
z->outfd = outfd;
z->part = packetalloc();
return z;
}
void
vtfreeconn(VtConn *z)
{
vthangup(z);
qlock(&z->lk);
for(;;){
if(z->readq)
_vtqhangup(z->readq);
else if(z->writeq)
_vtqhangup(z->writeq);
else
break;
rsleep(&z->rpcfork);
}
packetfree(z->part);
vtfree(z);
}