[Spice-devel] [spice-gtk 1/2] webdav: Cope with NULL SpiceSession::shared-dir
Christophe Fergeau
cfergeau at redhat.com
Thu Jan 29 02:23:43 PST 2015
shared-dir default value is
g_get_user_special_dir(G_USER_DIRECTORY_PUBLIC_SHARE)
which can be NULL (for example if ~/.config/user-dirs.dirs does not
exist).
This commit makes sure we don't create a PhodavServer when this occurs
---
gtk/channel-webdav.c | 9 ++++++++-
gtk/spice-session.c | 4 +++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gtk/channel-webdav.c b/gtk/channel-webdav.c
index 94f3ef3..bce46fa 100644
--- a/gtk/channel-webdav.c
+++ b/gtk/channel-webdav.c
@@ -700,8 +700,15 @@ PhodavServer* channel_webdav_server_new(SpiceSession *session)
PhodavServer *dav;
SoupServer *server;
SoupSocket *listener;
+ const char *shared_dir;
- dav = phodav_server_new(0, spice_session_get_shared_dir(session));
+ shared_dir = spice_session_get_shared_dir(session);
+ if (shared_dir != NULL) {
+ g_debug("No shared dir set, not creating webdav channel");
+ return NULL;
+ }
+
+ dav = phodav_server_new(0, shared_dir);
server = phodav_server_get_soup_server(dav);
listener = soup_server_get_listener(server);
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index a62d533..059cd2f 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -2626,7 +2626,9 @@ PhodavServer* spice_session_get_webdav_server(SpiceSession *session)
session->priv->webdav_magic[i] = g_random_int_range(0, 255);
session->priv->webdav = channel_webdav_server_new(session);
- phodav_server_run(session->priv->webdav);
+ if (session->priv->webdav != NULL) {
+ phodav_server_run(session->priv->webdav);
+ }
}
g_static_mutex_unlock(&mutex);
#endif
--
2.1.0
More information about the Spice-devel
mailing list