Hi, On Thu, Mar 17, 2016 at 02:47:51PM +0100, Lukas Venhoda wrote: > When stopping the service, automatically disconnect shared folder on > windows. Not dismounting could lead to multiple shared folders. But when user disconnect, the service is not stopped, correct? I think we need some integration with spice-vdagent to be aware of when the client disconnect in order to umount the shared folder. That could be in a different bug but please file it upstream and include this bits of information there. > --- > Changes since v2: > - None > Changes since v1: > - New patch > --- > spice/spice-webdavd.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/spice/spice-webdavd.c b/spice/spice-webdavd.c > index 8f9b06b..c27cbbd 100644 > --- a/spice/spice-webdavd.c > +++ b/spice/spice-webdavd.c > @@ -835,6 +835,28 @@ map_drive(void) > } > > static void > +unmap_drive(void) > +{ > + gchar local_name[3]; > + guint32 retval; > + > + local_name[0] = drive_letter; > + local_name[1] = ':'; > + local_name[2] = 0; > + > + retval = WNetCancelConnection2(local_name, CONNECT_UPDATE_PROFILE, TRUE); > + > + if (retval == NO_ERROR) > + g_debug ("unmap_drive ok"); > + else if (retval == ERROR_NOT_CONNECTED) > + g_debug ("drive not connected"); Nothing should be done if we map the drive before but fail to unmap with ERROR_NOT_CONNECTED ? > + else > + g_critical ("map_drive error %d", retval); Also, in multiple if/else if please use braces. > + > + return; > +} > + > +static void > map_drive_cb(GTask *task, > gpointer source_object, > gpointer task_data, > @@ -969,6 +991,7 @@ service_ctrl_handler (DWORD ctrl, DWORD type, LPVOID data, LPVOID ctx) > { > case SERVICE_CONTROL_STOP: > case SERVICE_CONTROL_SHUTDOWN: > + unmap_drive (); As Pavel said, it does not seem you need drive_letter as global. You can have it as userdata in the GTask and as argument for unmap_drive () > quit (SIGTERM); > service_status.dwCurrentState = SERVICE_STOP_PENDING; > SetServiceStatus (service_status_handle, &service_status); > -- > 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