Blob


1 #include <u.h>
2 #ifdef PLAN9PORT
3 #include <sys/socket.h>
4 #endif
5 #include <libc.h>
6 #include <venti.h>
7 #include "queue.h"
9 void
10 vthangup(VtConn *z)
11 {
12 qlock(&z->lk);
13 z->state = VtStateClosed;
14 #ifdef PLAN9PORT
15 /* try to make the read in vtrecvproc fail */
16 shutdown(SHUT_WR, z->infd);
17 shutdown(SHUT_WR, z->outfd);
18 #endif
19 if(z->infd >= 0)
20 close(z->infd);
21 if(z->outfd >= 0 && z->outfd != z->infd)
22 close(z->outfd);
23 z->infd = -1;
24 z->outfd = -1;
25 if(z->writeq)
26 _vtqhangup(z->writeq);
27 if(z->readq)
28 _vtqhangup(z->readq);
29 qunlock(&z->lk);
30 }