~vorlon/ubuntu/natty/avahi/multiarch

« back to all changes in this revision

Viewing changes to avahi-compat-howl/compat.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-05-06 14:04:57 UTC
  • mfrom: (4.1.13 sid)
  • Revision ID: james.westby@ubuntu.com-20090506140457-72h3msg32nuc4j7v
Tags: 0.6.27-2ubuntu1
* Merge from Debian unstable, remaining Ubuntu changes:
* debian/control:
  - Remove linux-any as it is not yet supported by Soyuz
  - Add versioned dependency on the dbus that satisfies our upstart job
    dependency.
  - Add udebs corresponding to libavahi-common3 and libavahi-core6, so that
    we can use them for Eucalyptus integration in the installer.
  - Recommend dhcp3-client instead of isc-dhcp-client (not yet available in
    Ubuntu)
* debian/rules:
* debian/avahi-daemon.init:
* debian/avahi-dnsconfd.init:
  - Avahi init scripts (daemon or dnsconfd) do not need to
    be started before gdm, and do not need to be stopped specially on
    shutdown.
* debian/avahi-daemon.postinst:
* debian/avahi-dnsconfd.postinst:
  - Use Ubuntu versions for migration scripts
* debian/avahi-autoipd.preinst:
* debian/avahi-autoipd.install:
* debian/avahi-autoipd.postinst:
* debian/avahi-autoipd.postrm:
  - Disable DHCP 3 to 4 migration (not yet in Ubuntu)
* debian/avahi-daemon.upstart:
* debian/avahi-dnsconfd.upstart:
  - Add Upstart config
* debian/patches/03_gir_1.1.patch:
  - Compile with the latest Gobject introspection

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id$ */
2
 
 
3
1
/***
4
2
  This file is part of avahi.
5
 
 
 
3
 
6
4
  avahi is free software; you can redistribute it and/or modify it
7
5
  under the terms of the GNU Lesser General Public License as
8
6
  published by the Free Software Foundation; either version 2.1 of the
9
7
  License, or (at your option) any later version.
10
 
 
 
8
 
11
9
  avahi is distributed in the hope that it will be useful, but WITHOUT
12
10
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
11
  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14
12
  Public License for more details.
15
 
 
 
13
 
16
14
  You should have received a copy of the GNU Lesser General Public
17
15
  License along with avahi; if not, write to the Free Software
18
16
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
87
85
    sw_discovery_oid oid_index;
88
86
 
89
87
    int thread_fd, main_fd;
90
 
    
 
88
 
91
89
    pthread_t thread;
92
90
    int thread_running;
93
91
 
121
119
    switch (error) {
122
120
        case AVAHI_OK:
123
121
            return SW_OKAY;
124
 
            
 
122
 
125
123
        case AVAHI_ERR_NO_MEMORY:
126
124
            return SW_E_MEM;
127
125
    }
134
132
    char command;
135
133
 
136
134
    assert(fd >= 0);
137
 
    
 
135
 
138
136
    if ((r = read(fd, &command, 1)) != 1) {
139
137
        fprintf(stderr, __FILE__": read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
140
138
        return -1;
157
155
static int poll_func(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata) {
158
156
    sw_discovery self = userdata;
159
157
    int ret;
160
 
    
 
158
 
161
159
    assert(self);
162
 
    
 
160
 
163
161
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
164
162
    ret = poll(ufds, nfds, timeout);
165
163
    ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
173
171
 
174
172
    sigfillset(&mask);
175
173
    pthread_sigmask(SIG_BLOCK, &mask, NULL);
176
 
    
 
174
 
177
175
    self->thread = pthread_self();
178
176
    self->thread_running = 1;
179
177
 
184
182
            break;
185
183
 
186
184
/*         fprintf(stderr, "Command: %c\n", command); */
187
 
        
 
185
 
188
186
        switch (command) {
189
187
 
190
188
            case COMMAND_POLL: {
194
192
 
195
193
                for (;;) {
196
194
                    errno = 0;
197
 
                
 
195
 
198
196
                    if ((ret = avahi_simple_poll_run(self->simple_poll)) < 0) {
199
 
                        
 
197
 
200
198
                        if (errno == EINTR)
201
199
                            continue;
202
 
                        
 
200
 
203
201
                        fprintf(stderr, __FILE__": avahi_simple_poll_run() failed: %s\n", strerror(errno));
204
202
                    }
205
203
 
206
204
                    break;
207
205
                }
208
 
                    
 
206
 
209
207
                ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
210
 
                
 
208
 
211
209
                if (write_command(self->thread_fd, ret < 0 ? COMMAND_POLL_FAILED : COMMAND_POLL_DONE) < 0)
212
210
                    break;
213
 
                
 
211
 
214
212
                break;
215
213
            }
216
214
 
217
215
            case COMMAND_QUIT:
218
216
                return NULL;
219
217
        }
220
 
        
 
218
 
221
219
    }
222
220
 
223
221
    return NULL;
231
229
 
232
230
        while (self->oid_index >= OID_MAX)
233
231
            self->oid_index -= OID_MAX;
234
 
        
 
232
 
235
233
        if (self->oid_table[self->oid_index].type == OID_UNUSED) {
236
234
            self->oid_table[self->oid_index].type = type;
237
235
            self->oid_table[self->oid_index].discovery = self;
238
236
 
239
237
            assert(OID_GET_INDEX(&self->oid_table[self->oid_index]) == self->oid_index);
240
 
            
 
238
 
241
239
            return self->oid_index ++;
242
240
        }
243
241
 
245
243
    }
246
244
 
247
245
    /* No free entry found */
248
 
    
 
246
 
249
247
    return (sw_discovery_oid) -1;
250
248
}
251
249
 
271
269
 
272
270
    if (self->oid_table[oid].type == OID_UNUSED)
273
271
        return NULL;
274
 
    
 
272
 
275
273
    return &self->oid_table[oid];
276
274
}
277
275
 
278
276
static service_data* service_data_new(sw_discovery self) {
279
277
    service_data *sdata;
280
 
    
 
278
 
281
279
    assert(self);
282
280
 
283
281
    if (!(sdata = avahi_new0(service_data, 1)))
284
282
        return NULL;
285
283
 
286
284
    AVAHI_LLIST_PREPEND(service_data, services, self->services, sdata);
287
 
    
 
285
 
288
286
    return sdata;
289
 
    
 
287
 
290
288
}
291
289
 
292
290
static void service_data_free(sw_discovery self, service_data* sdata) {
294
292
    assert(sdata);
295
293
 
296
294
    AVAHI_LLIST_REMOVE(service_data, services, self->services, sdata);
297
 
    
 
295
 
298
296
    avahi_free(sdata->name);
299
297
    avahi_free(sdata->regtype);
300
298
    avahi_free(sdata->domain);
308
306
static void client_callback(AvahiClient *s, AvahiClientState state, void* userdata) {
309
307
    sw_discovery self = userdata;
310
308
    sw_discovery_oid oid;
311
 
    
 
309
 
312
310
    assert(s);
313
311
    assert(self);
314
312
 
315
313
    discovery_ref(self);
316
 
    
 
314
 
317
315
    for (oid = 0; oid < OID_MAX; oid++) {
318
316
 
319
317
        switch (self->oid_table[oid].type) {
341
339
    sw_result result = SW_E_UNKNOWN;
342
340
    pthread_mutexattr_t mutex_attr;
343
341
    int error;
344
 
    
 
342
 
345
343
    assert(self);
346
 
    
 
344
 
347
345
    AVAHI_WARN_LINKAGE;
348
346
 
349
347
    *self = NULL;
350
348
 
351
349
    if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0)
352
350
        goto fail;
353
 
    
 
351
 
354
352
    if (!(*self = avahi_new(struct _sw_discovery, 1))) {
355
353
        result = SW_E_MEM;
356
354
        goto fail;
365
363
 
366
364
    memset((*self)->oid_table, 0, sizeof((*self)->oid_table));
367
365
    (*self)->oid_index = 0;
368
 
    
 
366
 
369
367
    (*self)->thread_running = 0;
370
368
 
371
369
    AVAHI_LLIST_HEAD_INIT(service_info, (*self)->services);
384
382
        result = map_error(error);
385
383
        goto fail;
386
384
    }
387
 
    
 
385
 
388
386
    /* Start simple poll */
389
387
    if (avahi_simple_poll_prepare((*self)->simple_poll, -1) < 0)
390
388
        goto fail;
392
390
    /* Queue an initial POLL command for the thread */
393
391
    if (write_command((*self)->main_fd, COMMAND_POLL) < 0)
394
392
        goto fail;
395
 
    
 
393
 
396
394
    if (pthread_create(&(*self)->thread, NULL, thread_func, *self) != 0)
397
395
        goto fail;
398
396
 
399
397
    (*self)->thread_running = 1;
400
 
    
 
398
 
401
399
    return SW_OKAY;
402
400
 
403
401
fail:
416
414
 
417
415
    if (write_command(self->main_fd, COMMAND_QUIT) < 0)
418
416
        return -1;
419
 
    
 
417
 
420
418
    avahi_simple_poll_wakeup(self->simple_poll);
421
 
    
 
419
 
422
420
    ASSERT_SUCCESS(pthread_join(self->thread, NULL));
423
421
    self->thread_running = 0;
424
422
    return 0;
459
457
 
460
458
    while (self->services)
461
459
        service_data_free(self, self->services);
462
 
    
 
460
 
463
461
    avahi_free(self);
464
462
}
465
463
 
466
464
sw_result sw_discovery_fina(sw_discovery self) {
467
465
    assert(self);
468
 
    
 
466
 
469
467
    AVAHI_WARN_LINKAGE;
470
468
 
471
469
    stop_thread(self);
472
470
    discovery_unref(self);
473
 
    
 
471
 
474
472
    return SW_OKAY;
475
473
}
476
474
 
477
475
sw_result sw_discovery_run(sw_discovery self) {
478
476
    assert(self);
479
 
    
 
477
 
480
478
    AVAHI_WARN_LINKAGE;
481
479
 
482
480
    return sw_salt_run((sw_salt) self);
484
482
 
485
483
sw_result sw_discovery_stop_run(sw_discovery self) {
486
484
    assert(self);
487
 
    
 
485
 
488
486
    AVAHI_WARN_LINKAGE;
489
487
 
490
488
    return sw_salt_stop_run((sw_salt) self);
492
490
 
493
491
int sw_discovery_socket(sw_discovery self) {
494
492
    assert(self);
495
 
    
 
493
 
496
494
    AVAHI_WARN_LINKAGE;
497
495
 
498
496
    return self->main_fd;
500
498
 
501
499
sw_result sw_discovery_read_socket(sw_discovery self) {
502
500
    sw_result result = SW_E_UNKNOWN;
503
 
    
 
501
 
504
502
    assert(self);
505
503
 
506
504
    discovery_ref(self);
507
505
 
508
506
    ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
509
 
    
 
507
 
510
508
    /* Cleanup notification socket */
511
509
    if (read_command(self->main_fd) != COMMAND_POLL_DONE)
512
510
        goto finish;
513
 
    
 
511
 
514
512
    if (avahi_simple_poll_dispatch(self->simple_poll) < 0)
515
513
        goto finish;
516
514
 
525
523
        /* Request the poll */
526
524
        if (write_command(self->main_fd, COMMAND_POLL) < 0)
527
525
            goto finish;
528
 
    
 
526
 
529
527
    result = SW_OKAY;
530
 
    
 
528
 
531
529
finish:
532
530
 
533
531
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
534
532
 
535
533
    discovery_unref(self);
536
 
    
 
534
 
537
535
    return result;
538
536
}
539
537
 
540
538
sw_result sw_discovery_salt(sw_discovery self, sw_salt *salt) {
541
539
    assert(self);
542
540
    assert(salt);
543
 
    
 
541
 
544
542
    AVAHI_WARN_LINKAGE;
545
543
 
546
544
    *salt = (sw_salt) self;
547
 
    
 
545
 
548
546
    return SW_OKAY;
549
547
}
550
548
 
557
555
 
558
556
    if (!((sw_discovery) self)->thread_running)
559
557
        return SW_E_UNKNOWN;
560
 
    
 
558
 
561
559
    memset(&p, 0, sizeof(p));
562
560
    p.fd = ((sw_discovery) self)->main_fd;
563
561
    p.events = POLLIN;
564
562
 
565
563
    if ((r = poll(&p, 1, msec ? (int) *msec : -1)) < 0) {
566
 
        
 
564
 
567
565
        /* Don't treat EINTR as error */
568
566
        if (errno == EINTR)
569
567
            return SW_OKAY;
570
 
        
 
568
 
571
569
        return SW_E_UNKNOWN;
572
 
        
 
570
 
573
571
    } else if (r == 0) {
574
 
        
 
572
 
575
573
        /* Timeoout */
576
574
        return SW_OKAY;
577
575
 
578
576
    } else {
579
577
        /* Success */
580
 
    
 
578
 
581
579
        if (p.revents != POLLIN)
582
580
            return SW_E_UNKNOWN;
583
581
 
584
582
        if ((result = sw_discovery_read_socket((sw_discovery) self)) != SW_OKAY)
585
583
            return result;
586
584
    }
587
 
    
 
585
 
588
586
    return SW_OKAY;
589
587
}
590
588
 
594
592
    AVAHI_WARN_LINKAGE;
595
593
 
596
594
    assert(self);
597
 
    
 
595
 
598
596
    for (;;)
599
597
        if ((ret = sw_salt_step(self, NULL)) != SW_OKAY)
600
598
            return ret;
622
620
 
623
621
sw_result sw_salt_unlock(sw_salt self) {
624
622
    assert(self);
625
 
    
 
623
 
626
624
    AVAHI_WARN_LINKAGE;
627
625
 
628
626
    ASSERT_SUCCESS(pthread_mutex_unlock(&((sw_discovery) self)->salt_mutex));
634
632
    sw_discovery_publish_reply reply;
635
633
 
636
634
    assert(data);
637
 
    
 
635
 
638
636
    reply = (sw_discovery_publish_reply) data->reply;
639
 
    
 
637
 
640
638
    reply(data->discovery,
641
639
          OID_GET_INDEX(data),
642
640
          status,
646
644
static int reg_create_service(oid_data *data) {
647
645
    int ret;
648
646
    const char *real_type;
649
 
    
 
647
 
650
648
    assert(data);
651
649
 
652
650
    real_type = avahi_get_type_from_subtype(data->service_data->regtype);
653
 
    
 
651
 
654
652
    if ((ret = avahi_entry_group_add_service_strlst(
655
653
             data->object,
656
654
             data->service_data->interface,
663
661
             data->service_data->port,
664
662
             data->service_data->txt)) < 0)
665
663
        return ret;
666
 
    
 
664
 
667
665
    if (real_type) {
668
666
        /* Create a subtype entry */
669
667
 
692
690
    /* We've not been setup completely */
693
691
    if (!data->object)
694
692
        return;
695
 
    
 
693
 
696
694
    switch (state) {
697
695
        case AVAHI_CLIENT_FAILURE:
698
696
            reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
699
697
            break;
700
 
        
 
698
 
701
699
        case AVAHI_CLIENT_S_RUNNING: {
702
700
            int ret;
703
701
 
706
704
                reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
707
705
                return;
708
706
            }
709
 
            
 
707
 
710
708
            break;
711
709
        }
712
 
            
 
710
 
713
711
        case AVAHI_CLIENT_S_COLLISION:
714
712
        case AVAHI_CLIENT_S_REGISTERING:
715
713
 
749
747
        case AVAHI_ENTRY_GROUP_FAILURE:
750
748
            reg_report_status(data, SW_DISCOVERY_PUBLISH_INVALID);
751
749
            break;
752
 
            
 
750
 
753
751
    }
754
752
}
755
753
 
771
769
    sw_result result = SW_E_UNKNOWN;
772
770
    service_data *sdata;
773
771
    AvahiStringList *txt = NULL;
774
 
    
 
772
 
775
773
    assert(self);
776
774
    assert(name);
777
775
    assert(type);
778
776
    assert(reply);
779
777
    assert(oid);
780
 
    
 
778
 
781
779
    AVAHI_WARN_LINKAGE;
782
780
 
783
781
    if (text_record && text_record_len > 0)
820
818
 
821
819
    if (avahi_client_get_state(self->client) == AVAHI_CLIENT_S_RUNNING) {
822
820
        int error;
823
 
        
 
821
 
824
822
        if ((error = reg_create_service(data)) < 0) {
825
823
            result = map_error(error);
826
824
            goto finish;
832
830
finish:
833
831
 
834
832
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
835
 
    
836
 
    if (result != SW_OKAY) 
 
833
 
 
834
    if (result != SW_OKAY)
837
835
        if (*oid != (sw_discovery_oid) -1)
838
836
            sw_discovery_cancel(self, *oid);
839
837
 
872
870
        case AVAHI_BROWSER_FAILURE:
873
871
            reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, NULL, NULL, domain, data->extra);
874
872
            break;
875
 
            
 
873
 
876
874
        case AVAHI_BROWSER_CACHE_EXHAUSTED:
877
875
        case AVAHI_BROWSER_ALL_FOR_NOW:
878
876
            break;
885
883
    sw_discovery_browse_reply reply,
886
884
    sw_opaque extra,
887
885
    sw_discovery_oid * oid) {
888
 
    
 
886
 
889
887
    oid_data *data;
890
888
    AvahiIfIndex ifindex;
891
889
    sw_result result = SW_E_UNKNOWN;
892
 
    
 
890
 
893
891
    assert(self);
894
892
    assert(reply);
895
893
    assert(oid);
896
 
    
 
894
 
897
895
    AVAHI_WARN_LINKAGE;
898
896
 
899
897
    if ((*oid = oid_alloc(self, OID_DOMAIN_BROWSER)) == (sw_discovery_oid) -1)
903
901
    assert(data);
904
902
    data->reply = (sw_result (*)(void)) reply;
905
903
    data->extra = extra;
906
 
    
 
904
 
907
905
    ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
908
906
 
909
907
    ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
910
 
    
 
908
 
911
909
    if (!(data->object = avahi_domain_browser_new(self->client, ifindex, AVAHI_PROTO_INET, NULL, AVAHI_DOMAIN_BROWSER_BROWSE, 0, domain_browser_callback, data))) {
912
910
        result = map_error(avahi_client_errno(self->client));
913
911
        goto finish;
918
916
finish:
919
917
 
920
918
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
921
 
    
 
919
 
922
920
    if (result != SW_OKAY)
923
921
        if (*oid != (sw_discovery_oid) -1)
924
922
            sw_discovery_cancel(self, *oid);
943
941
 
944
942
    oid_data* data = userdata;
945
943
    sw_discovery_resolve_reply reply;
946
 
    
 
944
 
947
945
    assert(r);
948
946
    assert(data);
949
947
 
960
958
            sw_ipv4_address_init_from_saddr(&addr, a->data.ipv4.address);
961
959
 
962
960
            host_name = add_trailing_dot(host_name, host_name_fixed, sizeof(host_name_fixed));
963
 
            
 
961
 
964
962
            if ((p = avahi_new0(uint8_t, (l = avahi_string_list_serialize(txt, NULL, 0))+1)))
965
963
                avahi_string_list_serialize(txt, p, l);
966
964
 
973
971
        case AVAHI_RESOLVER_FAILURE:
974
972
 
975
973
            /* Apparently there is no way in HOWL to inform about failed resolvings ... */
976
 
            
 
974
 
977
975
            avahi_warn("A service failed to resolve in the HOWL compatiblity layer of Avahi which is used by '%s'. "
978
976
                       "Since the HOWL API doesn't offer any means to inform the application about this, we have to ignore the failure. "
979
977
                       "Please fix your application to use the native API of Avahi!",
996
994
    oid_data *data;
997
995
    AvahiIfIndex ifindex;
998
996
    sw_result result = SW_E_UNKNOWN;
999
 
    
 
997
 
1000
998
    assert(self);
1001
999
    assert(name);
1002
1000
    assert(type);
1003
1001
    assert(reply);
1004
1002
    assert(oid);
1005
 
    
 
1003
 
1006
1004
    AVAHI_WARN_LINKAGE;
1007
1005
 
1008
1006
    if ((*oid = oid_alloc(self, OID_SERVICE_RESOLVER)) == (sw_discovery_oid) -1)
1012
1010
    assert(data);
1013
1011
    data->reply = (sw_result (*)(void)) reply;
1014
1012
    data->extra = extra;
1015
 
    
 
1013
 
1016
1014
    ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
1017
1015
 
1018
1016
    ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
1019
 
    
 
1017
 
1020
1018
    if (!(data->object = avahi_service_resolver_new(self->client, ifindex, AVAHI_PROTO_INET, name, type, domain, AVAHI_PROTO_INET, 0, service_resolver_callback, data))) {
1021
1019
        result = map_error(avahi_client_errno(self->client));
1022
1020
        goto finish;
1023
1021
    }
1024
1022
 
1025
1023
    result = SW_OKAY;
1026
 
    
 
1024
 
1027
1025
finish:
1028
1026
 
1029
1027
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
1030
 
    
 
1028
 
1031
1029
    if (result != SW_OKAY)
1032
1030
        if (*oid != (sw_discovery_oid) -1)
1033
1031
            sw_discovery_cancel(self, *oid);
1049
1047
    oid_data* data = userdata;
1050
1048
    char type_fixed[AVAHI_DOMAIN_NAME_MAX], domain_fixed[AVAHI_DOMAIN_NAME_MAX];
1051
1049
    sw_discovery_browse_reply reply;
1052
 
    
 
1050
 
1053
1051
    assert(b);
1054
1052
    assert(data);
1055
1053
 
1070
1068
        case AVAHI_BROWSER_FAILURE:
1071
1069
            reply(data->discovery, OID_GET_INDEX(data), SW_DISCOVERY_BROWSE_INVALID, interface, name, type, domain, data->extra);
1072
1070
            break;
1073
 
            
 
1071
 
1074
1072
        case AVAHI_BROWSER_CACHE_EXHAUSTED:
1075
1073
        case AVAHI_BROWSER_ALL_FOR_NOW:
1076
1074
            break;
1089
1087
    oid_data *data;
1090
1088
    AvahiIfIndex ifindex;
1091
1089
    sw_result result = SW_E_UNKNOWN;
1092
 
    
 
1090
 
1093
1091
    assert(self);
1094
1092
    assert(type);
1095
1093
    assert(reply);
1096
1094
    assert(oid);
1097
 
    
 
1095
 
1098
1096
    AVAHI_WARN_LINKAGE;
1099
1097
 
1100
1098
    if ((*oid = oid_alloc(self, OID_SERVICE_BROWSER)) == (sw_discovery_oid) -1)
1104
1102
    assert(data);
1105
1103
    data->reply = (sw_result (*)(void)) reply;
1106
1104
    data->extra = extra;
1107
 
    
 
1105
 
1108
1106
    ifindex = interface_index == 0 ? AVAHI_IF_UNSPEC : (AvahiIfIndex) interface_index;
1109
1107
 
1110
1108
    ASSERT_SUCCESS(pthread_mutex_lock(&self->mutex));
1111
 
    
 
1109
 
1112
1110
    if (!(data->object = avahi_service_browser_new(self->client, ifindex, AVAHI_PROTO_INET, type, domain, 0, service_browser_callback, data))) {
1113
1111
        result = map_error(avahi_client_errno(self->client));
1114
1112
        goto finish;
1115
1113
    }
1116
1114
 
1117
1115
    result = SW_OKAY;
1118
 
    
 
1116
 
1119
1117
finish:
1120
1118
 
1121
1119
    ASSERT_SUCCESS(pthread_mutex_unlock(&self->mutex));
1122
 
    
 
1120
 
1123
1121
    if (result != SW_OKAY)
1124
1122
        if (*oid != (sw_discovery_oid) -1)
1125
1123
            sw_discovery_cancel(self, *oid);
1129
1127
 
1130
1128
sw_result sw_discovery_cancel(sw_discovery self, sw_discovery_oid oid) {
1131
1129
    oid_data *data;
1132
 
    assert(self);                             
 
1130
    assert(self);
1133
1131
 
1134
1132
    AVAHI_WARN_LINKAGE;
1135
1133
 
1141
1139
            case OID_SERVICE_BROWSER:
1142
1140
                avahi_service_browser_free(data->object);
1143
1141
                break;
1144
 
                
 
1142
 
1145
1143
            case OID_SERVICE_RESOLVER:
1146
1144
                avahi_service_resolver_free(data->object);
1147
1145
                break;
1148
 
                
 
1146
 
1149
1147
            case OID_DOMAIN_BROWSER:
1150
1148
                avahi_domain_browser_free(data->object);
1151
1149
                break;
1152
 
                
 
1150
 
1153
1151
            case OID_ENTRY_GROUP:
1154
1152
                avahi_entry_group_free(data->object);
1155
1153
                break;
1156
 
                
 
1154
 
1157
1155
            case OID_UNUSED:
1158
1156
            ;
1159
1157
        }
1165
1163
    }
1166
1164
 
1167
1165
    oid_release(self, oid);
1168
 
    
 
1166
 
1169
1167
    return SW_OKAY;
1170
1168
}
1171
1169