Re: [phodav PATCH 6/7 v3] spice-webdavd-windows: Check for mapped shared folder

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

 



Hi,

On Thu, Mar 17, 2016 at 02:47:50PM +0100, Lukas Venhoda wrote:
> Check whether Spice Folder is already mapped.
> If yes, don't try to map another one.

I have found some issue with this. If I disconnect a session that
was sharing the folder (~/public) and connect again and start sharing
(~/downloads) what should happen?

It gets slow and the sharing did not really work in the second time but
it could be due another issue (I was running with valgrind too!)

Anyway, if we have a new connection we might assume that old map does
not work anymore and unmap it...

> ---
> Changes since v2:
>  - New patch
> ---
>  spice/spice-webdavd.c | 58 ++++++++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 51 insertions(+), 7 deletions(-)
>
> diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c
> index 49b1884..8f9b06b 100644
> --- a/spice/spice-webdavd.c
> +++ b/spice/spice-webdavd.c
> @@ -767,6 +767,42 @@ get_free_drive_letter(void)
>    return 0;
>  }
> 
> +static gboolean
> +is_spice_folder_mapped(void)
> +{
> +  const guint32 max_mask = 1 << 25;
> +  gchar local_name[3];
> +  gchar remote_name[32];
> +  guint32 size = sizeof(remote_name);
> +  guint32 drives;
> +  guint32 retval;
> +  guint32 mask;
> +  gint i;
> +
> +  local_name[0] = 'z';
> +  local_name[1] = ':';
> +  local_name[2] = 0;
> +
> +  drives = GetLogicalDrives ();
> +
> +  for (i = 0; i < 26; i++)
> +  {
> +    mask = max_mask >> i;
> +    if (drives & mask)
> +    {
> +      local_name[0] = 'z' - i;
> +      retval = WNetGetConnection (local_name, remote_name, (LPDWORD)&size);
> +      if (retval == NO_ERROR)
> +      {
> +        if (strncmp (remote_name, "\\\\localhost@9843\\DavWWWRoot", 28) == 0)

I think the port can be changed (--port) so, better not to hardcode it.

> +          return TRUE;
> +      }
> +    }
> +  }
> +
> +  return FALSE;
> +}
> +
>  static map_drive_enum
>  map_drive(void)
>  {
> @@ -842,11 +878,16 @@ run_service (void)
>    g_debug ("Run service");
>
>  #ifdef G_OS_WIN32
> -  GCancellable * cancel_map = g_cancellable_new ();
> -  GTask * map_drive_task = g_task_new (NULL, NULL, NULL, NULL);
> -  g_task_set_task_data (map_drive_task, cancel_map, NULL);
> -  g_task_run_in_thread (map_drive_task, map_drive_cb);
> -  g_object_unref (map_drive_task);
> +  gboolean spice_folder_mapped = is_spice_folder_mapped();
> +  GCancellable * cancel_map;
> +  if (!spice_folder_mapped)
> +  {
> +    cancel_map = g_cancellable_new ();
> +    GTask * map_drive_task = g_task_new (NULL, NULL, NULL, NULL);
> +    g_task_set_task_data (map_drive_task, cancel_map, NULL);
> +    g_task_run_in_thread (map_drive_task, map_drive_cb);
> +    g_object_unref (map_drive_task);
> +  }
>  #endif
> 
>    g_socket_service_start (socket_service);
> @@ -883,8 +924,11 @@ run_service (void)
>    g_main_loop_unref (loop);
> 
>  #ifdef G_OS_WIN32
> -  g_cancellable_cancel (cancel_map);
> -  g_object_unref (cancel_map);
> +  if (!spice_folder_mapped)
> +  {
> +    g_cancellable_cancel (cancel_map);
> +    g_object_unref (cancel_map);
> +  }
>  #endif
> 
>    g_cancellable_cancel (cancel);
> --
> 2.5.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]