mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-04 07:15:35 -04:00
zeroconf: add some more error checking
Also publish domain and host when we can and fix a memleak.
This commit is contained in:
parent
79d8e7f61d
commit
cd77dd0e62
1 changed files with 13 additions and 5 deletions
|
|
@ -369,6 +369,7 @@ static int do_announce(struct pw_zeroconf *zc, struct entry *e)
|
||||||
int res;
|
int res;
|
||||||
const struct spa_dict_item *it;
|
const struct spa_dict_item *it;
|
||||||
const char *session_name = "unnamed", *service = NULL;
|
const char *session_name = "unnamed", *service = NULL;
|
||||||
|
const char *domain = NULL, *host = NULL;
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
|
|
||||||
if (e->group == NULL) {
|
if (e->group == NULL) {
|
||||||
|
|
@ -390,6 +391,10 @@ static int do_announce(struct pw_zeroconf *zc, struct entry *e)
|
||||||
port = atoi(it->value);
|
port = atoi(it->value);
|
||||||
else if (spa_streq(it->key, "zeroconf.service"))
|
else if (spa_streq(it->key, "zeroconf.service"))
|
||||||
service = it->value;
|
service = it->value;
|
||||||
|
else if (spa_streq(it->key, "zeroconf.domain"))
|
||||||
|
domain = it->value;
|
||||||
|
else if (spa_streq(it->key, "zeroconf.host"))
|
||||||
|
host = it->value;
|
||||||
else
|
else
|
||||||
txt = avahi_string_list_add_pair(txt, it->key, it->value);
|
txt = avahi_string_list_add_pair(txt, it->key, it->value);
|
||||||
}
|
}
|
||||||
|
|
@ -397,12 +402,13 @@ static int do_announce(struct pw_zeroconf *zc, struct entry *e)
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
pw_log_error("no service provided");
|
pw_log_error("no service provided");
|
||||||
pw_zeroconf_emit_error(zc, res, spa_strerror(res));
|
pw_zeroconf_emit_error(zc, res, spa_strerror(res));
|
||||||
|
avahi_string_list_free(txt);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
res = avahi_entry_group_add_service_strlst(e->group,
|
res = avahi_entry_group_add_service_strlst(e->group,
|
||||||
AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
|
AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
|
||||||
(AvahiPublishFlags)0, session_name,
|
(AvahiPublishFlags)0, session_name,
|
||||||
service, NULL, NULL, port, txt);
|
service, domain, host, port, txt);
|
||||||
avahi_string_list_free(txt);
|
avahi_string_list_free(txt);
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
|
|
@ -482,22 +488,24 @@ static struct entry *entry_new(struct pw_zeroconf *zc, uint32_t type, void *user
|
||||||
static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info)
|
static int set_entry(struct pw_zeroconf *zc, uint32_t type, void *user, const struct spa_dict *info)
|
||||||
{
|
{
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
e = entry_find(zc, type, user);
|
e = entry_find(zc, type, user);
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
e = entry_new(zc, type, user, info);
|
if ((e = entry_new(zc, type, user, info)) == NULL)
|
||||||
entry_start(zc, e);
|
return -errno;
|
||||||
|
res = entry_start(zc, e);
|
||||||
} else {
|
} else {
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
entry_free(e);
|
entry_free(e);
|
||||||
else {
|
else {
|
||||||
pw_properties_update(e->props, info);
|
pw_properties_update(e->props, info);
|
||||||
entry_start(zc, e);
|
res = entry_start(zc, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return res;
|
||||||
}
|
}
|
||||||
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info)
|
int pw_zeroconf_set_announce(struct pw_zeroconf *zc, void *user, const struct spa_dict *info)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue