changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/cmd/cwfs/net.c

revision 7408: 1d345066125a
parent 2853: 7f05190544eb
     1.1--- a/sys/src/cmd/cwfs/net.c
     1.2+++ b/sys/src/cmd/cwfs/net.c
     1.3@@ -49,26 +49,28 @@ char *annstrs[Maxnets];
     1.4 static void
     1.5 neti(void *v)
     1.6 {
     1.7-	int lisfd, accfd;
     1.8 	NetConnInfo *nci;
     1.9 	Network *net;
    1.10+	char *addr;
    1.11+	int nctl, data;
    1.12 
    1.13 	net = v;
    1.14 	for(;;) {
    1.15-		if((lisfd = listen(net->anndir, net->lisdir)) < 0){
    1.16+		if((nctl = listen(net->anndir, net->lisdir)) < 0){
    1.17 			fprint(2, "%s: listen %s failed: %r\n", argv0, net->anndir);
    1.18 			break;
    1.19 		}
    1.20-		/* got new call on lisfd */
    1.21-		if((accfd = accept(lisfd, net->lisdir)) < 0){
    1.22-			fprint(2, "%s: accept %d (from %s) failed: %r\n", argv0, lisfd, net->lisdir);
    1.23-			close(lisfd);
    1.24+		if((data = accept(nctl, net->lisdir)) < 0){
    1.25+			fprint(2, "%s: accept %s failed: %r\n", argv0, net->lisdir);
    1.26+			close(nctl);
    1.27 			continue;
    1.28 		}
    1.29-		nci = getnetconninfo(net->lisdir, accfd);
    1.30-		if(srvchan(accfd, nci->raddr) == nil){
    1.31-			fprint(2, "%s: srvchan failed for: %s\n", argv0, nci->raddr);
    1.32-			close(accfd);
    1.33+		close(nctl);
    1.34+		nci = getnetconninfo(net->lisdir, data);
    1.35+		addr = nci == nil ? "unknown" : nci->raddr;
    1.36+		if(srvchan(data, addr) == nil){
    1.37+			fprint(2, "%s: srvchan failed for: %s\n", argv0, addr);
    1.38+			close(data);
    1.39 		}
    1.40 		freenetconninfo(nci);
    1.41 	}