summaryrefslogtreecommitdiffstats
path: root/avahi-core/announce.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-06-25 01:08:29 +0200
committerLennart Poettering <lennart@poettering.net>2010-06-25 01:08:29 +0200
commita97605e07ad7f44f2f65e15be64880e61a39ab43 (patch)
tree740527503048f5a2b2078741cfd13fc2ae6d4d1e /avahi-core/announce.c
parent238909aaff10489fe538c8c54e3f82fe8a54b849 (diff)
from now on we enforce a strict whitespace regime
Diffstat (limited to 'avahi-core/announce.c')
-rw-r--r--avahi-core/announce.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index d0fd598..5a35045 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -45,7 +45,7 @@ static void remove_announcer(AvahiServer *s, AvahiAnnouncer *a) {
AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_interface, a->interface->announcers, a);
AVAHI_LLIST_REMOVE(AvahiAnnouncer, by_entry, a->entry->announcers, a);
-
+
avahi_free(a);
}
@@ -61,7 +61,7 @@ static void set_timeout(AvahiAnnouncer *a, const struct timeval *tv) {
}
} else {
- if (a->time_event)
+ if (a->time_event)
avahi_time_event_update(a->time_event, tv);
else
a->time_event = avahi_time_event_new(a->server->time_event_queue, tv, elapse_announce, a);
@@ -76,28 +76,28 @@ void avahi_s_entry_group_check_probed(AvahiSEntryGroup *g, int immediately) {
assert(!g->dead);
/* Check whether all group members have been probed */
-
- if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
+
+ if (g->state != AVAHI_ENTRY_GROUP_REGISTERING || g->n_probing > 0)
return;
avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_ESTABLISHED);
if (g->dead)
return;
-
+
for (e = g->entries; e; e = e->by_group_next) {
AvahiAnnouncer *a;
-
+
for (a = e->announcers; a; a = a->by_entry_next) {
-
+
if (a->state != AVAHI_WAITING)
continue;
-
+
a->state = AVAHI_ANNOUNCING;
if (immediately) {
/* Shortcut */
-
+
a->n_iteration = 1;
next_state(a);
} else {
@@ -118,17 +118,17 @@ static void next_state(AvahiAnnouncer *a) {
assert(a->entry->group);
avahi_s_entry_group_check_probed(a->entry->group, 1);
-
+
} else if (a->state == AVAHI_PROBING) {
if (a->n_iteration >= 4) {
/* Probing done */
-
+
if (a->entry->group) {
assert(a->entry->group->n_probing);
a->entry->group->n_probing--;
}
-
+
if (a->entry->group && a->entry->group->state == AVAHI_ENTRY_GROUP_REGISTERING)
a->state = AVAHI_WAITING;
else {
@@ -142,10 +142,10 @@ static void next_state(AvahiAnnouncer *a) {
struct timeval tv;
avahi_interface_post_probe(a->interface, a->entry->record, 0);
-
+
avahi_elapse_time(&tv, AVAHI_PROBE_INTERVAL_MSEC, 0);
set_timeout(a, &tv);
-
+
a->n_iteration++;
}
@@ -168,10 +168,10 @@ static void next_state(AvahiAnnouncer *a) {
} else {
struct timeval tv;
avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
-
+
if (a->n_iteration < 10)
a->sec_delay *= 2;
-
+
set_timeout(a, &tv);
}
}
@@ -185,7 +185,7 @@ static void elapse_announce(AvahiTimeEvent *e, void *userdata) {
static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
AvahiAnnouncer *a;
-
+
assert(s);
assert(e);
assert(i);
@@ -200,7 +200,7 @@ static AvahiAnnouncer *get_announcer(AvahiServer *s, AvahiEntry *e, AvahiInterfa
static void go_to_initial_state(AvahiAnnouncer *a) {
AvahiEntry *e;
struct timeval tv;
-
+
assert(a);
e = a->entry;
@@ -212,7 +212,7 @@ static void go_to_initial_state(AvahiAnnouncer *a) {
a->state = AVAHI_ANNOUNCING;
else
a->state = AVAHI_WAITING;
-
+
} else
a->state = AVAHI_ESTABLISHED;
@@ -222,9 +222,9 @@ static void go_to_initial_state(AvahiAnnouncer *a) {
if (a->state == AVAHI_PROBING && e->group)
e->group->n_probing++;
- if (a->state == AVAHI_PROBING)
+ if (a->state == AVAHI_PROBING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
- else if (a->state == AVAHI_ANNOUNCING)
+ else if (a->state == AVAHI_ANNOUNCING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
else
set_timeout(a, NULL);
@@ -243,13 +243,13 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
/* We don't want duplicate announcers */
if (get_announcer(s, e, i))
- return;
+ return;
if ((!(a = avahi_new(AvahiAnnouncer, 1)))) {
avahi_log_error(__FILE__": Out of memory.");
return;
}
-
+
a->server = s;
a->interface = i;
a->entry = e;
@@ -263,7 +263,7 @@ static void new_announcer(AvahiServer *s, AvahiInterface *i, AvahiEntry *e) {
void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
AvahiEntry *e;
-
+
assert(s);
assert(i);
@@ -277,7 +277,7 @@ void avahi_announce_interface(AvahiServer *s, AvahiInterface *i) {
static void announce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
-
+
assert(m);
assert(i);
assert(e);
@@ -296,7 +296,7 @@ void avahi_announce_entry(AvahiServer *s, AvahiEntry *e) {
void avahi_announce_group(AvahiServer *s, AvahiSEntryGroup *g) {
AvahiEntry *e;
-
+
assert(s);
assert(g);
@@ -315,7 +315,7 @@ int avahi_entry_is_registered(AvahiServer *s, AvahiEntry *e, AvahiInterface *i)
if (!(a = get_announcer(s, e, i)))
return 0;
-
+
return
a->state == AVAHI_ANNOUNCING ||
a->state == AVAHI_ESTABLISHED ||
@@ -332,7 +332,7 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
if (!(a = get_announcer(s, e, i)))
return 0;
-
+
return
a->state == AVAHI_PROBING ||
(a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE));
@@ -340,7 +340,7 @@ int avahi_entry_is_probing(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInterface *i) {
AvahiAnnouncer *a;
-
+
assert(s);
assert(e);
assert(i);
@@ -356,12 +356,12 @@ void avahi_entry_return_to_initial_state(AvahiServer *s, AvahiEntry *e, AvahiInt
static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
AvahiRecord *g;
-
+
assert(r);
if (!(g = avahi_record_copy(r)))
return NULL; /* OOM */
-
+
assert(g->ref == 1);
g->ttl = 0;
@@ -370,7 +370,7 @@ static AvahiRecord *make_goodbye_record(AvahiRecord *r) {
static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
AvahiEntry *i;
-
+
assert(s);
assert(e);
@@ -381,7 +381,7 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
if (!avahi_record_equal_no_ttl(i->record, e->record))
continue;
-
+
return 1;
}
@@ -391,7 +391,7 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
AvahiRecord *g;
-
+
assert(m);
assert(i);
assert(e);
@@ -408,10 +408,10 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v
if (is_duplicate_entry(m->server, e))
return;
-
+
if (!(g = make_goodbye_record(e->record)))
return; /* OOM */
-
+
avahi_interface_post_response(i, g, e->flags & AVAHI_PUBLISH_UNIQUE, NULL, 1);
avahi_record_unref(g);
}
@@ -419,7 +419,7 @@ static void send_goodbye_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, v
static void reannounce(AvahiAnnouncer *a) {
AvahiEntry *e;
struct timeval tv;
-
+
assert(a);
e = a->entry;
@@ -430,12 +430,12 @@ static void reannounce(AvahiAnnouncer *a) {
/* Because we might change state we decrease the probing counter first */
if (a->state == AVAHI_PROBING && a->entry->group)
a->entry->group->n_probing--;
-
+
if (a->state == AVAHI_PROBING ||
(a->state == AVAHI_WAITING && (e->flags & AVAHI_PUBLISH_UNIQUE) && !(e->flags & AVAHI_PUBLISH_NO_PROBE)))
/* We were probing or waiting after probe, so we restart probing from the beginning here */
-
+
a->state = AVAHI_PROBING;
else if (a->state == AVAHI_WAITING)
@@ -443,26 +443,26 @@ static void reannounce(AvahiAnnouncer *a) {
a->state = AVAHI_WAITING;
else if (e->flags & AVAHI_PUBLISH_NO_ANNOUNCE)
-
+
/* No announcer needed */
a->state = AVAHI_ESTABLISHED;
else {
-
+
/* Ok, let's restart announcing */
a->state = AVAHI_ANNOUNCING;
- }
-
+ }
+
/* Now let's increase the probing counter again */
if (a->state == AVAHI_PROBING && e->group)
e->group->n_probing++;
-
+
a->n_iteration = 1;
a->sec_delay = 1;
if (a->state == AVAHI_PROBING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_PROBE_JITTER_MSEC));
- else if (a->state == AVAHI_ANNOUNCING)
+ else if (a->state == AVAHI_ANNOUNCING)
set_timeout(a, avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC));
else
set_timeout(a, NULL);
@@ -472,7 +472,7 @@ static void reannounce(AvahiAnnouncer *a) {
static void reannounce_walk_callback(AvahiInterfaceMonitor *m, AvahiInterface *i, void* userdata) {
AvahiEntry *e = userdata;
AvahiAnnouncer *a;
-
+
assert(m);
assert(i);
assert(e);
@@ -492,7 +492,7 @@ void avahi_reannounce_entry(AvahiServer *s, AvahiEntry *e) {
avahi_interface_monitor_walk(s->monitor, e->interface, e->protocol, reannounce_walk_callback, e);
}
-
+
void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye, int remove) {
assert(s);
assert(i);
@@ -500,7 +500,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye
if (send_goodbye)
if (i->announcing) {
AvahiEntry *e;
-
+
for (e = s->entries; e; e = e->entries_next)
if (!e->dead)
send_goodbye_callback(s->monitor, i, e);
@@ -514,7 +514,7 @@ void avahi_goodbye_interface(AvahiServer *s, AvahiInterface *i, int send_goodbye
void avahi_goodbye_entry(AvahiServer *s, AvahiEntry *e, int send_goodbye, int remove) {
assert(s);
assert(e);
-
+
if (send_goodbye)
if (!e->dead)
avahi_interface_monitor_walk(s->monitor, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, send_goodbye_callback, e);