monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] Re: comments on win32 patches


From: Christof Petig
Subject: Re: [Monotone-devel] Re: comments on win32 patches
Date: Mon, 28 Feb 2005 22:07:18 +0100
User-agent: Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.7.5) Gecko/20050105 Debian/1.7.5-1

Jon Bright schrieb:
Hi Christof,

Christof Petig wrote:


Actually it does. Netxx is the layer used by netsync and that is exactly
what the ssh branch covers.


Just to be clear, for SSH, are you passing the data over stdin/stdout
with pipes, or port forwarding it and using local connections.  If
stdin/stdout (which I presume, otherwise there's little utility to
building in the support...), how are you getting Netxx to deal with the
pipes?

Yes, I'm passing over stdin/stdout with pipes. Look into the ssh branch
for my ~15 lines Netxx::PipeStream class (which handles the unix case of
two seperate file descriptors enough to make netsync happy). I presume
that for Pipe support on Win32 just another Netxx::Stream variant might
be necessary (we might as well call it PipeStream).

For the cvssync branch I chose to implement first (using
pipe+socket+write+al.), port later, but I would have chosen Netxx
because I need a common abstraction for spawn_with_pipes (CVS_RSH) and
socket+connect (pserver) and was familiar with Netxx from the ssh branch.

So actually Netxx would be the layer to target (or any other socket+pipe
capable abstraction).


The problem I have is that whereas in Unix, the pipes at least live in
the same namespace as sockets, on Windows, the pipes you'd get to a
child process are in a whole different namespace to normal sockets.
Looking at the netxx code, this would mean I'd need to end up writing at
least a copy of socket.cxx (win32pipe.cxx or so) implementing all those
operations for Windows pipes.  Doable, but certainly more work.

Well, implementing a new netxx class (like my PipeSocket) should cover
all possible incompatibilities. Getting select etc. work on Win32 with
pipes will likely involve more understanding of Netxx's internals than I
needed (but IIRC select is not needed for ssh (but I need it inside
cvssync to implement non blocking read after waiting for at least one
char to be present :-( )).

   Christof

PS: I include it here for easier reference:
struct PipeStream : Netxx::Stream
{       int fd_write;
      typedef Netxx::Stream Parent;
      Netxx::ProbeInfo pi_;
// override write and other methods ...
  Netxx::signed_size_type write(const void *buffer, Netxx::size_type
length);
  Netxx::signed_size_type read (void *buffer, Netxx::size_type length);
  Netxx::socket_type get_writefd() const { return fd_write; }
  bool is_pipe() const { return get_writefd()!=Netxx::socket_type(-1); }
  void close();
  const Netxx::ProbeInfo* get_probe_info() const;
// ctors
  explicit PipeStream (Netxx::socket_type socketfd, Netxx::socket_type
writefd,
const Netxx::Timeout &timeout=Netxx::Timeout())
    : Netxx::Stream(socketfd,timeout), fd_write(writefd)
  {  if (is_pipe())
     {  pi_.add_socket(get_socketfd());
        pi_.add_socket(get_writefd());
     }
  }
  explicit PipeStream(const char *uri, Netxx::port_type default_port,
const Netx
x::Timeout &timeout=Netxx::Timeout())
    : Netxx::Stream(uri,default_port,timeout), fd_write(-1)
  {}
  explicit PipeStream() : Netxx::Stream(-1), fd_write(-1) {}
};

// pass them through ... for now
Netxx::signed_size_type PipeStream::write(const void *buffer,
Netxx::size_type l
ength)
{  if (!is_pipe()) return Parent::write(buffer,length);
   else return ::write(fd_write, buffer, length);
}
Netxx::signed_size_type PipeStream::read (void *buffer, Netxx::size_type
length)

{  if (!is_pipe()) return Parent::read(buffer,length);
   else return ::read(get_socketfd(), buffer, length);
}
void PipeStream::close()
{  if (is_pipe()) ::close(fd_write);
   Parent::close();
}
const Netxx::ProbeInfo* PipeStream::get_probe_info() const
{  if (!is_pipe()) return Parent::get_probe_info();
   return &pi_;
}

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]