[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sd/source
Bryan Quigley
gquigs at gmail.com
Fri Aug 8 13:21:24 PDT 2014
sd/source/ui/remotecontrol/AvahiNetworkService.cxx | 26 +++++++++++++--------
1 file changed, 17 insertions(+), 9 deletions(-)
New commits:
commit d2eec11f0a6f27e13a4a834942f8acf20ae62cec
Author: Bryan Quigley <gquigs at gmail.com>
Date: Mon Aug 4 12:26:00 2014 -0400
fdo#81552 Fail nicely if avahi doesn't let libreoffice publish items
Change-Id: Ie264a032a71bda336158e18bd2b14c569f23f42d
Reviewed-on: https://gerrit.libreoffice.org/10735
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
(cherry picked from commit 3c57701cf0a169bd8d1893d1b2271d48b8072147)
Reviewed-on: https://gerrit.libreoffice.org/10816
diff --git a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
index d4d92cd..ad2bfef 100644
--- a/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
+++ b/sd/source/ui/remotecontrol/AvahiNetworkService.cxx
@@ -35,7 +35,7 @@ static AvahiThreadedPoll *threaded_poll = NULL;
static AvahiEntryGroup *group = NULL;
static AvahiNetworkService *avahiService = NULL;
-static void create_services(AvahiClient *c);
+static bool create_services(AvahiClient *c);
static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
assert(g == group || group == NULL);
@@ -78,16 +78,19 @@ static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
}
}
-static void create_services(AvahiClient *c) {
+static bool create_services(AvahiClient *c) {
assert(c);
/* If this is the first time we're called, let's create a new
* entry group if necessary */
+ if(!client)
+ return false;
if (!group)
if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) {
SAL_WARN("sdremote.wifi", "avahi_entry_group_new() failed: " << avahi_strerror(avahi_client_errno(c)));
avahiService->clear();
+ return false;
}
/* If the group is empty (either because it was just created, or
@@ -113,22 +116,23 @@ static void create_services(AvahiClient *c) {
avahi_entry_group_reset(group);
- create_services(c);
- return;
+ return create_services(c);
}
SAL_WARN("sdremote.wifi", "Failed to add _impressremote._tcp service: " << avahi_strerror(ret));
avahiService->clear();
+ return false;
}
/* Tell the server to register the service */
if ((ret = avahi_entry_group_commit(group)) < 0) {
SAL_WARN("sdremote.wifi", "Failed to commit entry group: " << avahi_strerror(ret));
avahiService->clear();
+ return false;
}
}
- return;
+ return true; //Services we're already created
}
static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) {
@@ -174,7 +178,8 @@ void AvahiNetworkService::setup() {
return;
}
- create_services(client);
+ if(!create_services(client))
+ return;
/* Finally, start the event loop thread */
if (avahi_threaded_poll_start(threaded_poll) < 0) {
@@ -185,7 +190,10 @@ void AvahiNetworkService::setup() {
void AvahiNetworkService::clear() {
/* Call this when the app shuts down */
- avahi_threaded_poll_stop(threaded_poll);
- avahi_client_free(client);
- avahi_threaded_poll_free(threaded_poll);
+ if(threaded_poll)
+ avahi_threaded_poll_stop(threaded_poll);
+ if(client)
+ avahi_client_free(client);
+ if(threaded_poll)
+ avahi_threaded_poll_free(threaded_poll);
}
More information about the Libreoffice-commits
mailing list