[Spice-devel] [spice-gtk Win32 v3 02/12] NamedPipe: spice_named_pipe_new: add param to distinguish Server or Client

Uri Lublin uril at redhat.com
Thu Jun 28 04:27:57 PDT 2012


On 06/28/2012 01:31 PM, Marc-André Lureau wrote:
>>> Currently both users are servers.
>>> ---
>>>   gtk/controller/namedpipe.c                   |   24
>>> +++++++++++++++++-------
>>>   gtk/controller/namedpipe.h                   |    4 +++-
>>>   gtk/controller/spice-controller-listener.c   |    2 +-
>>>   gtk/controller/spice-foreign-menu-listener.c |    2 +-
>>>   4 files changed, 22 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/gtk/controller/namedpipe.c b/gtk/controller/namedpipe.c
>>> index 355887a..20dde4c 100644
>>> --- a/gtk/controller/namedpipe.c
>>> +++ b/gtk/controller/namedpipe.c
>>> @@ -80,12 +80,21 @@ spice_named_pipe_constructed (GObject *object)
>>>         pipe, in overlapped mode */
>>>      goto end;
>>>
>>> -  np->priv->handle = CreateNamedPipe (np->priv->name,
>>> -      PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
>>> -      PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
>>> -      PIPE_UNLIMITED_INSTANCES,
>>> -      DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE,
>>> -      0, NULL);
>>> +  if (np->priv->is_server) {
>>> +      np->priv->handle = CreateNamedPipe (np->priv->name,
>>> +          PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
>>> +          PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
>>> +          PIPE_UNLIMITED_INSTANCES,
>>> +          DEFAULT_PIPE_BUF_SIZE, DEFAULT_PIPE_BUF_SIZE,
>>> +          0, NULL);
>>> +  } else {
>>> +      np->priv->handle = CreateFile (np->priv->name,
>>> +          GENERIC_READ | GENERIC_WRITE,
>>> +          0, NULL,
>>> +          OPEN_EXISTING,
>>> +          FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
>>> +          NULL);
>>> +  }
>>>
> Are you sure you need namedpipe object for that?
>
> I think you could have used regular GWin32InputStream GWin32OutputStream..
>
> (that was my initial design, iirc)

I'm not sure I really need a namedpipe object.
It's one way to implement it, using NamedPipe and NamedPipe connection 
and GIOStream.
Does GWin32InputStream/OutputStream better ?  In what way ?

Note that the NamedPipe class was only acting as server.
These first two patches implements a NamedPipe client.

Thanks,
     Uri.


More information about the Spice-devel mailing list