summaryrefslogtreecommitdiffstats
path: root/avahi-core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-11 23:45:42 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-11 23:45:42 +0000
commite63a65b3955b173a3e8d6b78c6377a518a9922d6 (patch)
tree9665358bbdd3c228cfeae6b3cbe27e29ac53e506 /avahi-core
parentc3d36ee186b5fb24480590080215f7e14ee0f6a6 (diff)
* drop glib from avahi-common
* add new module with avahi_malloc() and friends git-svn-id: file:///home/lennart/svn/public/avahi/trunk@298 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core')
-rw-r--r--avahi-core/announce.c10
-rw-r--r--avahi-core/browse.c4
-rw-r--r--avahi-core/cache.c10
-rw-r--r--avahi-core/cache.h4
-rw-r--r--avahi-core/probe-sched.c8
-rw-r--r--avahi-core/query-sched.c10
-rw-r--r--avahi-core/resolve-address.c2
-rw-r--r--avahi-core/resolve-host-name.c2
-rw-r--r--avahi-core/resolve-service.c2
-rw-r--r--avahi-core/response-sched.c12
-rw-r--r--avahi-core/server.c8
-rw-r--r--avahi-core/server.h4
-rw-r--r--avahi-core/timeeventq-test.c4
-rw-r--r--avahi-core/timeeventq.c31
-rw-r--r--avahi-core/timeeventq.h10
15 files changed, 67 insertions, 54 deletions
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index fe461de..5d9e8cf 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -45,7 +45,7 @@ static void remove_announcement(AvahiServer *s, AvahiAnnouncement *a) {
static void elapse_announce(AvahiTimeEvent *e, void *userdata);
-static void set_timeout(AvahiAnnouncement *a, const GTimeVal *tv) {
+static void set_timeout(AvahiAnnouncement *a, const struct timeval *tv) {
g_assert(a);
if (!tv) {
@@ -95,7 +95,7 @@ void avahi_entry_group_check_probed(AvahiEntryGroup *g, gboolean immediately) {
a->n_iteration = 1;
next_state(a);
} else {
- GTimeVal tv;
+ struct timeval tv;
a->n_iteration = 0;
avahi_elapse_time(&tv, 0, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
set_timeout(a, &tv);
@@ -140,7 +140,7 @@ static void next_state(AvahiAnnouncement *a) {
set_timeout(a, NULL);
next_state(a);
} else {
- GTimeVal tv;
+ struct timeval tv;
avahi_interface_post_probe(a->interface, a->entry->record, FALSE);
@@ -171,7 +171,7 @@ static void next_state(AvahiAnnouncement *a) {
set_timeout(a, NULL);
} else {
- GTimeVal tv;
+ struct timeval tv;
avahi_elapse_time(&tv, a->sec_delay*1000, AVAHI_ANNOUNCEMENT_JITTER_MSEC);
if (a->n_iteration < 10)
@@ -204,7 +204,7 @@ AvahiAnnouncement *avahi_get_announcement(AvahiServer *s, AvahiEntry *e, AvahiIn
static void go_to_initial_state(AvahiAnnouncement *a, gboolean immediately) {
AvahiEntry *e;
- GTimeVal tv;
+ struct timeval tv;
g_assert(a);
e = a->entry;
diff --git a/avahi-core/browse.c b/avahi-core/browse.c
index 5885cb4..42c13da 100644
--- a/avahi-core/browse.c
+++ b/avahi-core/browse.c
@@ -48,7 +48,7 @@ struct AvahiRecordBrowser {
static void elapse(AvahiTimeEvent *e, void *userdata) {
AvahiRecordBrowser *s = userdata;
- GTimeVal tv;
+ struct timeval tv;
/* gchar *t; */
g_assert(s);
@@ -118,7 +118,7 @@ static gboolean scan_idle_callback(gpointer data) {
AvahiRecordBrowser *avahi_record_browser_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key, AvahiRecordBrowserCallback callback, gpointer userdata) {
AvahiRecordBrowser *b, *t;
- GTimeVal tv;
+ struct timeval tv;
g_assert(server);
g_assert(key);
diff --git a/avahi-core/cache.c b/avahi-core/cache.c
index 174fceb..2f3296f 100644
--- a/avahi-core/cache.c
+++ b/avahi-core/cache.c
@@ -241,7 +241,7 @@ static void expire_in_one_second(AvahiCache *c, AvahiCacheEntry *e) {
g_assert(e);
e->state = AVAHI_CACHE_FINAL;
- g_get_current_time(&e->expiry);
+ gettimeofday(&e->expiry, NULL);
avahi_timeval_add(&e->expiry, 1000000); /* 1s */
update_time_event(c, e);
}
@@ -264,9 +264,9 @@ void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean cache_flush, con
} else {
AvahiCacheEntry *e = NULL, *first;
- GTimeVal now;
+ struct timeval now;
- g_get_current_time(&now);
+ gettimeofday(&now, NULL);
/* This is an update request */
@@ -378,13 +378,13 @@ void avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, gpointer userda
}
gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e) {
- GTimeVal now;
+ struct timeval now;
AvahiUsec age;
g_assert(c);
g_assert(e);
- g_get_current_time(&now);
+ gettimeofday(&now, NULL);
age = avahi_timeval_diff(&now, &e->timestamp)/1000000;
diff --git a/avahi-core/cache.h b/avahi-core/cache.h
index de685f4..2f4caa6 100644
--- a/avahi-core/cache.h
+++ b/avahi-core/cache.h
@@ -44,8 +44,8 @@ typedef struct AvahiCacheEntry AvahiCacheEntry;
struct AvahiCacheEntry {
AvahiCache *cache;
AvahiRecord *record;
- GTimeVal timestamp;
- GTimeVal expiry;
+ struct timeval timestamp;
+ struct timeval expiry;
gboolean cache_flush;
AvahiAddress origin;
diff --git a/avahi-core/probe-sched.c b/avahi-core/probe-sched.c
index d9c6599..ad23234 100644
--- a/avahi-core/probe-sched.c
+++ b/avahi-core/probe-sched.c
@@ -38,7 +38,7 @@ struct AvahiProbeJob {
gboolean chosen; /* Use for packet assembling */
gboolean done;
- GTimeVal delivery;
+ struct timeval delivery;
AvahiRecord *record;
@@ -91,7 +91,7 @@ static void job_free(AvahiProbeScheduler *s, AvahiProbeJob *pj) {
static void elapse_callback(AvahiTimeEvent *e, gpointer data);
static void job_set_elapse_time(AvahiProbeScheduler *s, AvahiProbeJob *pj, guint msec, guint jitter) {
- GTimeVal tv;
+ struct timeval tv;
g_assert(s);
g_assert(pj);
@@ -116,7 +116,7 @@ static void job_mark_done(AvahiProbeScheduler *s, AvahiProbeJob *pj) {
pj->done = TRUE;
job_set_elapse_time(s, pj, AVAHI_PROBE_HISTORY_MSEC, 0);
- g_get_current_time(&pj->delivery);
+ gettimeofday(&pj->delivery, NULL);
}
AvahiProbeScheduler *avahi_probe_scheduler_new(AvahiInterface *i) {
@@ -344,7 +344,7 @@ static AvahiProbeJob* find_history_job(AvahiProbeScheduler *s, AvahiRecord *reco
gboolean avahi_probe_scheduler_post(AvahiProbeScheduler *s, AvahiRecord *record, gboolean immediately) {
AvahiProbeJob *pj;
- GTimeVal tv;
+ struct timeval tv;
g_assert(s);
g_assert(record);
diff --git a/avahi-core/query-sched.c b/avahi-core/query-sched.c
index d5135cb..129b15e 100644
--- a/avahi-core/query-sched.c
+++ b/avahi-core/query-sched.c
@@ -37,7 +37,7 @@ struct AvahiQueryJob {
AvahiTimeEvent *time_event;
gboolean done;
- GTimeVal delivery;
+ struct timeval delivery;
AvahiKey *key;
@@ -98,7 +98,7 @@ static void job_free(AvahiQueryScheduler *s, AvahiQueryJob *qj) {
static void elapse_callback(AvahiTimeEvent *e, gpointer data);
static void job_set_elapse_time(AvahiQueryScheduler *s, AvahiQueryJob *qj, guint msec, guint jitter) {
- GTimeVal tv;
+ struct timeval tv;
g_assert(s);
g_assert(qj);
@@ -123,7 +123,7 @@ static void job_mark_done(AvahiQueryScheduler *s, AvahiQueryJob *qj) {
qj->done = TRUE;
job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0);
- g_get_current_time(&qj->delivery);
+ gettimeofday(&qj->delivery, NULL);
}
AvahiQueryScheduler *avahi_query_scheduler_new(AvahiInterface *i) {
@@ -319,7 +319,7 @@ static AvahiQueryJob* find_history_job(AvahiQueryScheduler *s, AvahiKey *key) {
}
gboolean avahi_query_scheduler_post(AvahiQueryScheduler *s, AvahiKey *key, gboolean immediately) {
- GTimeVal tv;
+ struct timeval tv;
AvahiQueryJob *qj;
g_assert(s);
@@ -373,7 +373,7 @@ void avahi_query_scheduler_incoming(AvahiQueryScheduler *s, AvahiKey *key) {
}
qj = job_new(s, key, TRUE);
- g_get_current_time(&qj->delivery);
+ gettimeofday(&qj->delivery, NULL);
job_set_elapse_time(s, qj, AVAHI_QUERY_HISTORY_MSEC, 0);
}
diff --git a/avahi-core/resolve-address.c b/avahi-core/resolve-address.c
index 89f9bcf..c386875 100644
--- a/avahi-core/resolve-address.c
+++ b/avahi-core/resolve-address.c
@@ -82,7 +82,7 @@ AvahiAddressResolver *avahi_address_resolver_new(AvahiServer *server, AvahiIfInd
AvahiAddressResolver *r;
AvahiKey *k;
gchar *n;
- GTimeVal tv;
+ struct timeval tv;
g_assert(server);
g_assert(address);
diff --git a/avahi-core/resolve-host-name.c b/avahi-core/resolve-host-name.c
index c18722d..c01c1a4 100644
--- a/avahi-core/resolve-host-name.c
+++ b/avahi-core/resolve-host-name.c
@@ -107,7 +107,7 @@ static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
AvahiHostNameResolver *avahi_host_name_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const gchar *host_name, guchar aprotocol, AvahiHostNameResolverCallback callback, gpointer userdata) {
AvahiHostNameResolver *r;
AvahiKey *k;
- GTimeVal tv;
+ struct timeval tv;
g_assert(server);
g_assert(host_name);
diff --git a/avahi-core/resolve-service.c b/avahi-core/resolve-service.c
index 2ad38f8..135543f 100644
--- a/avahi-core/resolve-service.c
+++ b/avahi-core/resolve-service.c
@@ -195,7 +195,7 @@ static void time_event_callback(AvahiTimeEvent *e, void *userdata) {
AvahiServiceResolver *avahi_service_resolver_new(AvahiServer *server, AvahiIfIndex interface, AvahiProtocol protocol, const gchar *name, const gchar *type, const gchar *domain, AvahiProtocol aprotocol, AvahiServiceResolverCallback callback, gpointer userdata) {
AvahiServiceResolver *r;
AvahiKey *k;
- GTimeVal tv;
+ struct timeval tv;
gchar t[256], *n;
size_t l;
diff --git a/avahi-core/response-sched.c b/avahi-core/response-sched.c
index 6d1269e..e1024a6 100644
--- a/avahi-core/response-sched.c
+++ b/avahi-core/response-sched.c
@@ -45,7 +45,7 @@ struct AvahiResponseJob {
AvahiTimeEvent *time_event;
AvahiResponseJobState state;
- GTimeVal delivery;
+ struct timeval delivery;
AvahiRecord *record;
gboolean flush_cache;
@@ -108,7 +108,7 @@ static void job_free(AvahiResponseScheduler *s, AvahiResponseJob *rj) {
static void elapse_callback(AvahiTimeEvent *e, gpointer data);
static void job_set_elapse_time(AvahiResponseScheduler *s, AvahiResponseJob *rj, guint msec, guint jitter) {
- GTimeVal tv;
+ struct timeval tv;
g_assert(s);
g_assert(rj);
@@ -134,7 +134,7 @@ static void job_mark_done(AvahiResponseScheduler *s, AvahiResponseJob *rj) {
job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
- g_get_current_time(&rj->delivery);
+ gettimeofday(&rj->delivery, NULL);
}
AvahiResponseScheduler *avahi_response_scheduler_new(AvahiInterface *i) {
@@ -329,7 +329,7 @@ static AvahiResponseJob* find_suppressed_job(AvahiResponseScheduler *s, AvahiRec
gboolean avahi_response_scheduler_post(AvahiResponseScheduler *s, AvahiRecord *record, gboolean flush_cache, const AvahiAddress *querier, gboolean immediately) {
AvahiResponseJob *rj;
- GTimeVal tv;
+ struct timeval tv;
/* gchar *t; */
g_assert(s);
@@ -440,7 +440,7 @@ void avahi_response_scheduler_incoming(AvahiResponseScheduler *s, AvahiRecord *r
rj->flush_cache = flush_cache;
rj->querier_valid = FALSE;
- g_get_current_time(&rj->delivery);
+ gettimeofday(&rj->delivery, NULL);
job_set_elapse_time(s, rj, AVAHI_RESPONSE_HISTORY_MSEC, 0);
}
@@ -477,7 +477,7 @@ void avahi_response_scheduler_suppress(AvahiResponseScheduler *s, AvahiRecord *r
rj->querier = *querier;
}
- g_get_current_time(&rj->delivery);
+ gettimeofday(&rj->delivery, NULL);
job_set_elapse_time(s, rj, AVAHI_RESPONSE_SUPPRESS_MSEC, 0);
}
diff --git a/avahi-core/server.c b/avahi-core/server.c
index 4d5a4ec..2bbc1f0 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -2036,7 +2036,7 @@ void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState sta
if (g->state == state)
return;
- g_assert(state >= AVAHI_ENTRY_GROUP_UNCOMMITED && state <= AVAHI_ENTRY_GROUP_COLLISION);
+ g_assert(state <= AVAHI_ENTRY_GROUP_COLLISION);
g->state = state;
@@ -2093,7 +2093,7 @@ void avahi_entry_group_free(AvahiEntryGroup *g) {
static void entry_group_commit_real(AvahiEntryGroup *g) {
g_assert(g);
- g_get_current_time(&g->register_time);
+ gettimeofday(&g->register_time, NULL);
avahi_entry_group_change_state(g, AVAHI_ENTRY_GROUP_REGISTERING);
@@ -2117,7 +2117,7 @@ static void entry_group_register_time_event_callback(AvahiTimeEvent *e, gpointer
}
gint avahi_entry_group_commit(AvahiEntryGroup *g) {
- GTimeVal now;
+ struct timeval now;
g_assert(g);
g_assert(!g->dead);
@@ -2132,7 +2132,7 @@ gint avahi_entry_group_commit(AvahiEntryGroup *g) {
AVAHI_RR_HOLDOFF_MSEC_RATE_LIMIT :
AVAHI_RR_HOLDOFF_MSEC));
- g_get_current_time(&now);
+ gettimeofday(&now, NULL);
if (avahi_timeval_compare(&g->register_time, &now) <= 0) {
/* Holdoff time passed, so let's start probing */
diff --git a/avahi-core/server.h b/avahi-core/server.h
index 5810dfa..f4c7d92 100644
--- a/avahi-core/server.h
+++ b/avahi-core/server.h
@@ -43,7 +43,7 @@ struct AvahiLegacyUnicastReflectSlot {
AvahiAddress address;
guint16 port;
gint interface;
- GTimeVal elapse_time;
+ struct timeval elapse_time;
AvahiTimeEvent *time_event;
};
@@ -76,7 +76,7 @@ struct AvahiEntryGroup {
guint n_probing;
guint n_register_try;
- GTimeVal register_time;
+ struct timeval register_time;
AvahiTimeEvent *register_time_event;
AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
diff --git a/avahi-core/timeeventq-test.c b/avahi-core/timeeventq-test.c
index 33cd2b1..91eceb6 100644
--- a/avahi-core/timeeventq-test.c
+++ b/avahi-core/timeeventq-test.c
@@ -31,7 +31,7 @@
static AvahiTimeEventQueue *q = NULL;
static void callback(AvahiTimeEvent*e, gpointer userdata) {
- GTimeVal tv = {0, 0};
+ struct timeval tv = {0, 0};
g_assert(e);
g_message("callback(%i)", GPOINTER_TO_INT(userdata));
avahi_elapse_time(&tv, 1000, 100);
@@ -40,7 +40,7 @@ static void callback(AvahiTimeEvent*e, gpointer userdata) {
int main(int argc, char *argv[]) {
GMainLoop *loop = NULL;
- GTimeVal tv;
+ struct timeval tv;
q = avahi_time_event_queue_new(NULL, 0);
diff --git a/avahi-core/timeeventq.c b/avahi-core/timeeventq.c
index 60d9fe0..fbdb6d5 100644
--- a/avahi-core/timeeventq.c
+++ b/avahi-core/timeeventq.c
@@ -38,10 +38,21 @@ static gint compare(gconstpointer _a, gconstpointer _b) {
return avahi_timeval_compare(&a->last_run, &b->last_run);
}
+static void source_get_timeval(GSource *source, struct timeval *tv) {
+ GTimeVal gtv;
+
+ g_assert(source);
+ g_assert(tv);
+
+ g_source_get_current_time(source, &gtv);
+ tv->tv_sec = gtv.tv_sec;
+ tv->tv_usec = gtv.tv_usec;
+}
+
static gboolean prepare_func(GSource *source, gint *timeout) {
AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source;
AvahiTimeEvent *e;
- GTimeVal now;
+ struct timeval now;
g_assert(source);
g_assert(timeout);
@@ -54,7 +65,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) {
e = q->prioq->root->data;
g_assert(e);
- g_source_get_current_time(source, &now);
+ source_get_timeval(source, &now);
if (avahi_timeval_compare(&now, &e->expiry) >= 0 && /* Time elapsed */
avahi_timeval_compare(&now, &e->last_run) != 0 /* Not yet run */) {
@@ -74,7 +85,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) {
static gboolean check_func(GSource *source) {
AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source;
AvahiTimeEvent *e;
- GTimeVal now;
+ struct timeval now;
g_assert(source);
@@ -84,7 +95,7 @@ static gboolean check_func(GSource *source) {
e = q->prioq->root->data;
g_assert(e);
- g_source_get_current_time(source, &now);
+ source_get_timeval(source, &now);
return
avahi_timeval_compare(&now, &e->expiry) >= 0 && /* Time elapsed */
@@ -93,11 +104,11 @@ static gboolean check_func(GSource *source) {
static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer user_data) {
AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source;
- GTimeVal now;
+ struct timeval now;
g_assert(source);
- g_source_get_current_time(source, &now);
+ source_get_timeval(source, &now);
while (q->prioq->root) {
AvahiTimeEvent *e = q->prioq->root->data;
@@ -123,10 +134,10 @@ static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer us
}
static void fix_expiry_time(AvahiTimeEvent *e) {
- GTimeVal now;
+ struct timeval now;
g_assert(e);
- g_source_get_current_time(&e->queue->source, &now);
+ source_get_timeval(&e->queue->source, &now);
if (avahi_timeval_compare(&now, &e->expiry) > 0)
e->expiry = now;
@@ -166,7 +177,7 @@ void avahi_time_event_queue_free(AvahiTimeEventQueue *q) {
g_source_unref(&q->source);
}
-AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const GTimeVal *timeval, AvahiTimeEventCallback callback, gpointer userdata) {
+AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const struct timeval *timeval, AvahiTimeEventCallback callback, gpointer userdata) {
AvahiTimeEvent *e;
g_assert(q);
@@ -199,7 +210,7 @@ void avahi_time_event_queue_remove(AvahiTimeEventQueue *q, AvahiTimeEvent *e) {
g_free(e);
}
-void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const GTimeVal *timeval) {
+void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const struct timeval *timeval) {
g_assert(q);
g_assert(e);
g_assert(e->queue == q);
diff --git a/avahi-core/timeeventq.h b/avahi-core/timeeventq.h
index a2544ff..65f1420 100644
--- a/avahi-core/timeeventq.h
+++ b/avahi-core/timeeventq.h
@@ -22,6 +22,8 @@
USA.
***/
+#include <sys/types.h>
+
typedef struct AvahiTimeEventQueue AvahiTimeEventQueue;
typedef struct AvahiTimeEvent AvahiTimeEvent;
@@ -32,8 +34,8 @@ typedef void (*AvahiTimeEventCallback)(AvahiTimeEvent *e, gpointer userdata);
struct AvahiTimeEvent {
AvahiTimeEventQueue *queue;
AvahiPrioQueueNode *node;
- GTimeVal expiry;
- GTimeVal last_run;
+ struct timeval expiry;
+ struct timeval last_run;
AvahiTimeEventCallback callback;
gpointer userdata;
};
@@ -46,10 +48,10 @@ struct AvahiTimeEventQueue {
AvahiTimeEventQueue* avahi_time_event_queue_new(GMainContext *context, gint priority);
void avahi_time_event_queue_free(AvahiTimeEventQueue *q);
-AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const GTimeVal *timeval, AvahiTimeEventCallback callback, gpointer userdata);
+AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const struct timeval *timeval, AvahiTimeEventCallback callback, gpointer userdata);
void avahi_time_event_queue_remove(AvahiTimeEventQueue *q, AvahiTimeEvent *e);
-void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const GTimeVal *timeval);
+void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const struct timeval *timeval);
AvahiTimeEvent* avahi_time_event_queue_root(AvahiTimeEventQueue *q);
AvahiTimeEvent* avahi_time_event_next(AvahiTimeEvent *e);