summaryrefslogtreecommitdiff
path: root/debian/patches/0140-avahi.patch
blob: 799b350a986fc81da8957a90032ecc13502a1681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Description: Avoid assertion failure when net_avahi_init failed
Author: Andreas Henriksson <andreas@fatal.se>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=861112
Forwarded: not-needed
Last-Update: 2017-06-20
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: trunk/backend/net.c
===================================================================
--- trunk.orig/backend/net.c
+++ trunk/backend/net.c
@@ -798,7 +798,7 @@ net_avahi_browse_callback (AvahiServiceB
     {
       case AVAHI_BROWSER_FAILURE:
 	DBG (1, "net_avahi_browse_callback: %s\n", avahi_strerror (avahi_client_errno (avahi_service_browser_get_client (b))));
-	avahi_threaded_poll_quit (avahi_thread);
+	if (avahi_thread) avahi_threaded_poll_quit (avahi_thread);
 	return;
 
       case AVAHI_BROWSER_NEW:
@@ -863,7 +863,7 @@ net_avahi_callback (AvahiClient *c, Avah
 	if (avahi_browser == NULL)
 	  {
 	    DBG (1, "net_avahi_callback: could not create service browser: %s\n", avahi_strerror (avahi_client_errno (c)));
-	    avahi_threaded_poll_quit (avahi_thread);
+	    if (avahi_thread) avahi_threaded_poll_quit (avahi_thread);
 	  }
 	break;
 
@@ -886,14 +886,14 @@ net_avahi_callback (AvahiClient *c, Avah
 	    if (avahi_client == NULL)
 	      {
 		DBG (1, "net_avahi_init: could not create Avahi client: %s\n", avahi_strerror (error));
-		avahi_threaded_poll_quit (avahi_thread);
+		if (avahi_thread) avahi_threaded_poll_quit (avahi_thread);
 	      }
 	  }
 	else
 	  {
 	    /* Another error happened - game over */
 	    DBG (1, "net_avahi_callback: server connection failure: %s\n", avahi_strerror (error));
-	    avahi_threaded_poll_quit (avahi_thread);
+	    if (avahi_thread) avahi_threaded_poll_quit (avahi_thread);
 	  }
 	break;
     }
@@ -1072,12 +1072,12 @@ sane_init (SANE_Int * version_code, SANE
 	      continue;
 	    }
 #if WITH_AVAHI
-	  avahi_threaded_poll_lock (avahi_thread);
+	  if (avahi_thread) avahi_threaded_poll_lock (avahi_thread);
 #endif /* WITH_AVAHI */
 	  DBG (2, "sane_init: trying to add %s\n", device_name);
 	  add_device (device_name, 0);
 #if WITH_AVAHI
-	  avahi_threaded_poll_unlock (avahi_thread);
+	  if (avahi_thread) avahi_threaded_poll_unlock (avahi_thread);
 #endif /* WITH_AVAHI */
 	}
 
@@ -1123,12 +1123,12 @@ sane_init (SANE_Int * version_code, SANE
 		  continue;
 #endif /* ENABLE_IPV6 */
 #if WITH_AVAHI
-	      avahi_threaded_poll_lock (avahi_thread);
+	      if (avahi_thread) avahi_threaded_poll_lock (avahi_thread);
 #endif /* WITH_AVAHI */
 	      DBG (2, "sane_init: trying to add %s\n", host);
 	      add_device (host, 0);
 #if WITH_AVAHI
-	      avahi_threaded_poll_unlock (avahi_thread);
+	      if (avahi_thread) avahi_threaded_poll_unlock (avahi_thread);
 #endif /* WITH_AVAHI */
 	    }
 	  free (copy);
@@ -1546,11 +1546,11 @@ sane_open (SANE_String_Const full_name,
 	   "sane_open: device %s not found, trying to register it anyway\n",
 	   nd_name);
 #if WITH_AVAHI
-      avahi_threaded_poll_lock (avahi_thread);
+      if (avahi_thread) avahi_threaded_poll_lock (avahi_thread);
 #endif /* WITH_AVAHI */
       status = add_device (nd_name, &dev);
 #if WITH_AVAHI
-      avahi_threaded_poll_unlock (avahi_thread);
+      if (avahi_thread) avahi_threaded_poll_unlock (avahi_thread);
 #endif /* WITH_AVAHI */
       if (status != SANE_STATUS_GOOD)
 	{