X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=ovsdb%2Ftrigger.c;h=74a1b0fdc7c9e61b53cf319f09d7a99569df6734;hb=HEAD;hp=1ecfdcac11bda074cf25c912d9685dc571d9d9f5;hpb=a4af00400a835eb87569ba40e21874c05e872c0f;p=cascardo%2Fovs.git diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c index 1ecfdcac1..74a1b0fdc 100644 --- a/ovsdb/trigger.c +++ b/ovsdb/trigger.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2009 Nicira Networks +/* Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,30 +17,30 @@ #include "trigger.h" -#include #include #include "json.h" #include "jsonrpc.h" #include "ovsdb.h" #include "poll-loop.h" +#include "server.h" -static bool ovsdb_trigger_try(struct ovsdb *db, struct ovsdb_trigger *, - long long int now); +static bool ovsdb_trigger_try(struct ovsdb_trigger *, long long int now); static void ovsdb_trigger_complete(struct ovsdb_trigger *); void -ovsdb_trigger_init(struct ovsdb *db, struct ovsdb_trigger *trigger, - struct json *request, struct list *completion, - long long int now) +ovsdb_trigger_init(struct ovsdb_session *session, struct ovsdb *db, + struct ovsdb_trigger *trigger, + struct json *request, long long int now) { - list_push_back(&db->triggers, &trigger->node); - trigger->completion = completion; + trigger->session = session; + trigger->db = db; + list_push_back(&trigger->db->triggers, &trigger->node); trigger->request = request; trigger->result = NULL; trigger->created = now; trigger->timeout_msec = LLONG_MAX; - ovsdb_trigger_try(db, trigger, now); + ovsdb_trigger_try(trigger, now); } void @@ -73,9 +73,9 @@ ovsdb_trigger_run(struct ovsdb *db, long long int now) run_triggers = db->run_triggers; db->run_triggers = false; - LIST_FOR_EACH_SAFE (t, next, struct ovsdb_trigger, node, &db->triggers) { + LIST_FOR_EACH_SAFE (t, next, node, &db->triggers) { if (run_triggers || now - t->created >= t->timeout_msec) { - ovsdb_trigger_try(db, t, now); + ovsdb_trigger_try(t, now); } } } @@ -89,7 +89,7 @@ ovsdb_trigger_wait(struct ovsdb *db, long long int now) long long int deadline = LLONG_MAX; struct ovsdb_trigger *t; - LIST_FOR_EACH (t, struct ovsdb_trigger, node, &db->triggers) { + LIST_FOR_EACH (t, node, &db->triggers) { if (t->created < LLONG_MAX - t->timeout_msec) { long long int t_deadline = t->created + t->timeout_msec; if (deadline > t_deadline) { @@ -102,16 +102,16 @@ ovsdb_trigger_wait(struct ovsdb *db, long long int now) } if (deadline < LLONG_MAX) { - poll_timer_wait(MIN(deadline - now, INT_MAX)); + poll_timer_wait_until(deadline); } } } static bool -ovsdb_trigger_try(struct ovsdb *db, struct ovsdb_trigger *t, long long int now) +ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now) { - t->result = ovsdb_execute(db, t->request, now - t->created, - &t->timeout_msec); + t->result = ovsdb_execute(t->db, t->session, + t->request, now - t->created, &t->timeout_msec); if (t->result) { ovsdb_trigger_complete(t); return true; @@ -123,7 +123,7 @@ ovsdb_trigger_try(struct ovsdb *db, struct ovsdb_trigger *t, long long int now) static void ovsdb_trigger_complete(struct ovsdb_trigger *t) { - assert(t->result != NULL); + ovs_assert(t->result != NULL); list_remove(&t->node); - list_push_back(t->completion, &t->node); + list_push_back(&t->session->completions, &t->node); }