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

Marc-André Lureau marcandre.lureau at gmail.com
Thu Jun 28 03:31:34 PDT 2012


Hi

> Uri Lublin 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)

-- 
Marc-André Lureau


More information about the Spice-devel mailing list