@ -71,11 +73,85 @@ int ret1(const char* s,void* foo) {
return1;
return1;
}
}
intreaderfunc(void*arg){
intfd=*(int64*)arg;
charbuf[1024];
while(read(fd,buf,sizeofbuf)==sizeofbuf){
write(1,".",1);
}
return0;
}
intmain(intargc,char*argv[]){
intmain(intargc,char*argv[]){
(void)argc;
(void)argc;
(void)argv;
(void)argv;
int64pfd[2];
size_ti;
io_socketpair(pfd);
io_fd(pfd[0]);
io_fd(pfd[1]);
io_batch*b=iob_new(1024);
// first write 1024 blocks (to activate the splitting code path)
for(i=0;i<1024;++i){
if((i%50)==0){
staticcharc=0;
char*s=alloca(1);
*s=c;
iob_addbuf(b,s,1);
++c;
}else
iob_addbuf(b,"a",1);
}
assert(iob_send(pfd[0],b)==1024);
{
charbuf[1024];
assert(read(pfd[1],buf,1024)==1024);
// drain the pipe
}
charboilerplate[]="Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time tozz get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.";
thrd_trt;
// now try setting the socket to non-blocking and write more than