11 typedef struct SunMsgFd SunMsgFd;
18 typedef struct Arg Arg;
41 n = readn(arg.fd, buf, 4);
44 n = (buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|buf[3];
45 if(arg.srv->chatty) fprint(2, "%.8ux...", n);
48 p = erealloc(p, tot+n);
49 if(readn(arg.fd, p+tot, n) != n)
53 msg = emalloc(sizeof(SunMsgFd));
56 msg->msg.creply = arg.creply;
57 sendp(arg.srv->crequest, msg);
74 while((msg = recvp(arg.creply)) != nil){
76 buf[0] = (n>>24)|0x80;
80 if(write(arg.fd, buf, 4) != 4
81 || write(arg.fd, msg->msg.data, msg->msg.count) != msg->msg.count)
82 fprint(2, "sunFdWrite: %r\n");
89 sunSrvFd(SunSrv *srv, int fd)
93 arg = emalloc(sizeof(Arg));
96 arg->csync = chancreate(sizeof(void*), 0);
97 arg->creply = chancreate(sizeof(SunMsg*), 10);
99 proccreate(sunFdRead, arg, SunStackSize);
100 proccreate(sunFdWrite, arg, SunStackSize);
104 chanfree(arg->csync);