# # patch "netxx_pipe.cc" # from [715126fb8880057611d738c641da4c7159da7136] # to [b4898ef8c28d02bd140a563ec2611f1330a40334] # # patch "netxx_pipe.hh" # from [93ca99024df9aa17e98984e836da1cf8c30fab9d] # to [00f2c8416757b75a0cff61a73e646d7143e9b843] # ======================================================================== --- netxx_pipe.cc 715126fb8880057611d738c641da4c7159da7136 +++ netxx_pipe.cc b4898ef8c28d02bd140a563ec2611f1330a40334 @@ -186,8 +186,8 @@ #define FAIL_IF(FUN,ARGS,CHECK) \ do \ if (FUN ARGS CHECK) \ - { W(F(##FUN " failed %d\n") % GetLastError()); \ - throw oops(##FUN " failed"); \ + { W(F(#FUN " failed %d\n") % GetLastError()); \ + throw oops(#FUN " failed"); \ } \ while (0) @@ -196,6 +196,7 @@ // perhaps there is a more efficient/less complicated way (tell me if you know) Netxx::Probe::result_type Netxx::PipeCompatibleProbe::ready(const Timeout &timeout, ready_type rt) { if (!is_pipe) return Probe::ready(timeout,rt); + if (rt==ready_none) rt=ready_t; // remembered from add if (rt&ready_write) return std::make_pair(pipe->get_writefd(),ready_write); if (rt&ready_read) { if (pipe->bytes_available) return std::make_pair(pipe->get_readfd(),ready_read); @@ -204,19 +205,19 @@ DWORD bytes_read=0; FAIL_IF( ReadFile,(h_read,pipe->readbuf,1,&bytes_read,&pipe->overlap),==0); if (!bytes_read) - { FAIL_IF( WaitForSingleObject,(pipe->overlap.hEvent,timeout.get_sec()),!=0); - FAIL_IF( GetOverlappedResult,(h_read,&pipe->overlap,&bytes_read,FALSE),!=0); + { FAIL_IF( WaitForSingleObject,(pipe->overlap.hEvent,timeout.get_sec()),==WAIT_FAILED); + FAIL_IF( GetOverlappedResult,(h_read,&pipe->overlap,&bytes_read,FALSE),==0); if (!bytes_read) - { FAIL_IF( CancelIO,(h_read),!=0); + { FAIL_IF( CancelIo,(h_read),==0); std::make_pair(socket_type(-1),ready_none); } } I(bytes_read==1); pipe->bytes_available=bytes_read; FAIL_IF( ReadFile,(h_read,pipe->readbuf+1,sizeof pipe->readbuf-1,&bytes_read,&pipe->overlap),==0); - FAIL_IF( CancelIO,(h_read),!=0); + FAIL_IF( CancelIo,(h_read),==0); if (!bytes_read) - { FAIL_IF( GetOverlappedResult,(h_read,&pipe->overlap,&bytes_read,FALSE),!=0); + { FAIL_IF( GetOverlappedResult,(h_read,&pipe->overlap,&bytes_read,FALSE),==0); I(!bytes_read); } else @@ -232,6 +233,7 @@ assert(!pipe); is_pipe=true; pipe=&ps; + ready_t=rt; } void Netxx::PipeCompatibleProbe::add(const StreamBase &sb, ready_type rt) ======================================================================== --- netxx_pipe.hh 93ca99024df9aa17e98984e836da1cf8c30fab9d +++ netxx_pipe.hh 00f2c8416757b75a0cff61a73e646d7143e9b843 @@ -68,8 +68,9 @@ // use WriteFileEx/ReadFileEx with Overlap? bool is_pipe; PipeStream *pipe; + ready_type ready_t; public: - PipeCompatibleProbe() : is_pipe(), pipe() {} + PipeCompatibleProbe() : is_pipe(), pipe(), ready_t() {} void clear() { if (is_pipe) { pipe=0; is_pipe=false; } else Probe::clear(); } result_type ready(const Timeout &timeout=Timeout(), ready_type rt=ready_none);