# # patch "netxx_pipe.cc" # from [ad08aaaf554af2860edfba10250723ae7d6c47a3] # to [4f3d35be8b18b51086c6255e0501a047e379a2e7] # # patch "netxx_pipe.hh" # from [1d8b8627413c3dedecd8d2aba09e0696a4846435] # to [b05243d39ef00474292e6195b9c387b84f8d0176] # ======================================================================== --- netxx_pipe.cc ad08aaaf554af2860edfba10250723ae7d6c47a3 +++ netxx_pipe.cc 4f3d35be8b18b51086c6255e0501a047e379a2e7 @@ -93,12 +93,13 @@ fd2[0]=-1; fd2[1]=-1; E(_pipe(fd1,0,_O_BINARY)==0, F("first pipe failed")); - if (_pipe(fd2,0,_O_BINARY)) // | O_NOINHERIT + // there are ways to ensure that the parent side does not get inherited + // by the child (e.g. O_NOINHERIT), I don't use them for now + if (_pipe(fd2,0,_O_BINARY)) { ::close(fd1[0]); ::close(fd1[1]); E(false,F("second pipe failed")); } - // abuse dup, use spawnvp? PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; memset(&piProcInfo,0,sizeof piProcInfo); @@ -173,7 +174,7 @@ { ::close(readfd); ::close(writefd); - // wait for Process to end (before???) + // wait for Process to end #ifdef WIN32 WaitForSingleObject((HANDLE)child, INFINITE); @@ -244,8 +245,7 @@ return std::make_pair(socket_type(-1),ready_none); } -void Netxx::PipeCompatibleProbe::add - (PipeStream &ps, ready_type rt) +void Netxx::PipeCompatibleProbe::add(PipeStream &ps, ready_type rt) { assert(!is_pipe); assert(!pipe); @@ -254,35 +254,27 @@ ready_t=rt; } -void Netxx::PipeCompatibleProbe::add - (const StreamBase &sb, ready_type rt) - { // L(F("PCP::add()\n")); +void Netxx::PipeCompatibleProbe::add(const StreamBase &sb, ready_type rt) + { try { - add - (const_cast(dynamic_cast(sb)),rt); - // L(F("... was a pipe\n")); + add(const_cast(dynamic_cast(sb)),rt); } catch (...) { assert(!is_pipe); - Probe::add - (sb,rt); - // L(F("... was a socket\n")); + Probe::add(sb,rt); } } -void Netxx::PipeCompatibleProbe::add - (const StreamServer &ss, ready_type rt) +void Netxx::PipeCompatibleProbe::add(const StreamServer &ss, ready_type rt) { assert(!ip_pipe); - Probe::add - (ss,rt); + Probe::add(ss,rt); } #else // unix void -Netxx::PipeCompatibleProbe::add - (PipeStream &ps, ready_type rt) +Netxx::PipeCompatibleProbe::add(PipeStream &ps, ready_type rt) { if (rt==ready_none || rt&ready_read) add_socket(ps.get_readfd(),ready_read); @@ -291,27 +283,22 @@ } void -Netxx::PipeCompatibleProbe::add - (const StreamBase &sb, ready_type rt) +Netxx::PipeCompatibleProbe::add(const StreamBase &sb, ready_type rt) { try { - add - (const_cast(dynamic_cast(sb)),rt); + add(const_cast(dynamic_cast(sb)),rt); } catch (...) { - Probe::add - (sb,rt); + Probe::add(sb,rt); } } void -Netxx::PipeCompatibleProbe::add - (const StreamServer &ss, ready_type rt) +Netxx::PipeCompatibleProbe::add(const StreamServer &ss, ready_type rt) { - Probe::add - (ss,rt); + Probe::add(ss,rt); } #endif @@ -370,7 +357,6 @@ add_pipe_tests(test_suite * suite) { I(suite); - suite->add - (BOOST_TEST_CASE(&simple_pipe_test)); + suite->add(BOOST_TEST_CASE(&simple_pipe_test)); } #endif ======================================================================== --- netxx_pipe.hh 1d8b8627413c3dedecd8d2aba09e0696a4846435 +++ netxx_pipe.hh b05243d39ef00474292e6195b9c387b84f8d0176 @@ -41,7 +41,6 @@ class PipeStream : public StreamBase { int readfd, writefd; - // ProbeInfo pi_; int child; #ifdef WIN32 @@ -53,7 +52,8 @@ #endif public: - explicit PipeStream (int readfd, int writefd); // Timeout? + // do we need Timeout for symmetry with Stream? + explicit PipeStream (int readfd, int writefd); explicit PipeStream (const std::string &cmd, const std::vector &args); virtual signed_size_type read (void *buffer, size_type length); virtual signed_size_type write (const void *buffer, size_type length); @@ -93,38 +93,18 @@ Probe::clear(); } result_type ready(const Timeout &timeout=Timeout(), ready_type rt=ready_none); - void add - (PipeStream &ps, ready_type rt=ready_none); - void add - (const StreamBase &sb, ready_type rt=ready_none); - void add - (const StreamServer &ss, ready_type rt=ready_none); - void remove - (const PipeStream &ps); -#if 0 // should be covered by StreamBase - - template - void add - (const T &t, ready_type rt=ready_none) - { - if (is_pipe) - throw std::runtime_error("stream added to a pipe probe"); - Probe::add - (t,rt); - } -#endif - + void add(PipeStream &ps, ready_type rt=ready_none); + void add(const StreamBase &sb, ready_type rt=ready_none); + void add(const StreamServer &ss, ready_type rt=ready_none); + void remove(const PipeStream &ps); }; #else struct PipeCompatibleProbe : Probe { - void add - (PipeStream &ps, ready_type rt=ready_none); - void add - (const StreamBase &sb, ready_type rt=ready_none); - void add - (const StreamServer &ss, ready_type rt=ready_none); + void add(PipeStream &ps, ready_type rt=ready_none); + void add(const StreamBase &sb, ready_type rt=ready_none); + void add(const StreamServer &ss, ready_type rt=ready_none); }; #endif