[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha6-934-g612c5e7
Kai Blin
kai at samba.org
Tue Feb 17 08:19:56 GMT 2009
The branch, master has been updated
via 612c5e746bd4d0059eb8bcb8dbb4944db155f071 (commit)
via 48b874e3764a20952dfd5e2957a3074073b480db (commit)
from 046cb24d0ad76b8e01c9c7d0d0146af9f6576047 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 612c5e746bd4d0059eb8bcb8dbb4944db155f071
Author: Kai Blin <kai at samba.org>
Date: Mon Feb 16 23:36:21 2009 +0100
async_sock: Use tevent_timeval instead of timeval functions
commit 48b874e3764a20952dfd5e2957a3074073b480db
Author: Kai Blin <kai at samba.org>
Date: Mon Feb 16 23:34:15 2009 +0100
tevent: Rename ev_timeval* functions to tevent_timeval, export them.
Also add tevent_timeval_add() and tevent_timeval_current_ofs()
to help not depending on lub/util/time.c for things that just need tevent
-----------------------------------------------------------------------
Summary of changes:
lib/async_req/async_req.c | 7 +++--
lib/tevent/tevent.h | 19 ++++++++++++++
lib/tevent/tevent_epoll.c | 2 +-
lib/tevent/tevent_internal.h | 2 -
lib/tevent/tevent_req.c | 2 +-
lib/tevent/tevent_select.c | 2 +-
lib/tevent/tevent_standard.c | 2 +-
lib/tevent/tevent_timed.c | 55 +++++++++++++++++++++++++++++-------------
8 files changed, 65 insertions(+), 26 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/async_req/async_req.c b/lib/async_req/async_req.c
index db47bd9..054c9f9 100644
--- a/lib/async_req/async_req.c
+++ b/lib/async_req/async_req.c
@@ -174,7 +174,7 @@ bool async_post_error(struct async_req *req, struct tevent_context *ev,
{
req->error = error;
- if (tevent_add_timer(ev, req, timeval_zero(),
+ if (tevent_add_timer(ev, req, tevent_timeval_zero(),
async_trigger, req) == NULL) {
return false;
}
@@ -208,7 +208,8 @@ bool async_req_set_timeout(struct async_req *req, struct tevent_context *ev,
struct timeval to)
{
return (tevent_add_timer(
- ev, req, timeval_current_ofs(to.tv_sec, to.tv_usec),
+ ev, req,
+ tevent_timeval_current_ofs(to.tv_sec, to.tv_usec),
async_req_timedout, req)
!= NULL);
}
@@ -300,7 +301,7 @@ bool async_req_enqueue(struct async_req_queue *queue, struct tevent_context *ev,
if (!busy) {
struct tevent_timer *te;
- te = tevent_add_timer(ev, e, timeval_zero(),
+ te = tevent_add_timer(ev, e, tevent_timeval_zero(),
async_req_immediate_trigger,
e);
if (te == NULL) {
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 9c88bb7..8e3d097 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -300,6 +300,25 @@ bool tevent_req_is_error(struct tevent_req *req,
uint64_t *error);
+int tevent_timeval_compare(const struct timeval *tv1,
+ const struct timeval *tv2);
+
+struct timeval tevent_timeval_zero(void);
+
+struct timeval tevent_timeval_current(void);
+
+struct timeval tevent_timeval_set(uint32_t secs, uint32_t usecs);
+
+struct timeval tevent_timeval_until(const struct timeval *tv1,
+ const struct timeval *tv2);
+
+bool tevent_timeval_is_zero(const struct timeval *tv);
+
+struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
+ uint32_t usecs);
+
+struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
+
#ifdef TEVENT_COMPAT_DEFINES
#define event_context tevent_context
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index d7f446a..0494f55 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -418,7 +418,7 @@ static int epoll_event_loop_once(struct tevent_context *ev)
struct timeval tval;
tval = tevent_common_loop_timer_delay(ev);
- if (ev_timeval_is_zero(&tval)) {
+ if (tevent_timeval_is_zero(&tval)) {
return 0;
}
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index a25d2b5..758bdb4 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -161,8 +161,6 @@ void tevent_common_fd_set_close_fn(struct tevent_fd *fde,
uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde);
void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
-struct timeval ev_timeval_zero(void);
-bool ev_timeval_is_zero(const struct timeval *tv);
struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,
struct timeval next_event,
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index 8f2d7bb..0846413 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -216,7 +216,7 @@ static void tevent_req_trigger(struct tevent_context *ev,
struct tevent_req *tevent_req_post(struct tevent_req *req,
struct tevent_context *ev)
{
- req->internal.trigger = tevent_add_timer(ev, req, ev_timeval_zero(),
+ req->internal.trigger = tevent_add_timer(ev, req, tevent_timeval_zero(),
tevent_req_trigger, req);
if (!req->internal.trigger) {
talloc_free(req);
diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c
index 0635be5..32678f0 100644
--- a/lib/tevent/tevent_select.c
+++ b/lib/tevent/tevent_select.c
@@ -220,7 +220,7 @@ static int select_event_loop_once(struct tevent_context *ev)
struct timeval tval;
tval = tevent_common_loop_timer_delay(ev);
- if (ev_timeval_is_zero(&tval)) {
+ if (tevent_timeval_is_zero(&tval)) {
return 0;
}
diff --git a/lib/tevent/tevent_standard.c b/lib/tevent/tevent_standard.c
index 8e10761..bbd5c5d 100644
--- a/lib/tevent/tevent_standard.c
+++ b/lib/tevent/tevent_standard.c
@@ -541,7 +541,7 @@ static int std_event_loop_once(struct tevent_context *ev)
struct timeval tval;
tval = tevent_common_loop_timer_delay(ev);
- if (ev_timeval_is_zero(&tval)) {
+ if (tevent_timeval_is_zero(&tval)) {
return 0;
}
diff --git a/lib/tevent/tevent_timed.c b/lib/tevent/tevent_timed.c
index e06102c..d75653d 100644
--- a/lib/tevent/tevent_timed.c
+++ b/lib/tevent/tevent_timed.c
@@ -36,7 +36,7 @@
Return 0 if tv1 == tv2
Return 1 if tv1 > tv2
*/
-static int ev_timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
+int tevent_timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
{
if (tv1->tv_sec > tv2->tv_sec) return 1;
if (tv1->tv_sec < tv2->tv_sec) return -1;
@@ -48,7 +48,7 @@ static int ev_timeval_compare(const struct timeval *tv1, const struct timeval *t
/**
return a zero timeval
*/
-struct timeval ev_timeval_zero(void)
+struct timeval tevent_timeval_zero(void)
{
struct timeval tv;
tv.tv_sec = 0;
@@ -59,7 +59,7 @@ struct timeval ev_timeval_zero(void)
/**
return a timeval for the current time
*/
-static struct timeval ev_timeval_current(void)
+struct timeval tevent_timeval_current(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -69,7 +69,7 @@ static struct timeval ev_timeval_current(void)
/**
return a timeval struct with the given elements
*/
-static struct timeval ev_timeval_set(uint32_t secs, uint32_t usecs)
+struct timeval tevent_timeval_set(uint32_t secs, uint32_t usecs)
{
struct timeval tv;
tv.tv_sec = secs;
@@ -82,12 +82,12 @@ static struct timeval ev_timeval_set(uint32_t secs, uint32_t usecs)
if tv1 comes after tv2, then return a zero timeval
(this is *tv2 - *tv1)
*/
-static struct timeval ev_timeval_until(const struct timeval *tv1,
- const struct timeval *tv2)
+struct timeval tevent_timeval_until(const struct timeval *tv1,
+ const struct timeval *tv2)
{
struct timeval t;
- if (ev_timeval_compare(tv1, tv2) >= 0) {
- return ev_timeval_zero();
+ if (tevent_timeval_compare(tv1, tv2) >= 0) {
+ return tevent_timeval_zero();
}
t.tv_sec = tv2->tv_sec - tv1->tv_sec;
if (tv1->tv_usec > tv2->tv_usec) {
@@ -102,11 +102,32 @@ static struct timeval ev_timeval_until(const struct timeval *tv1,
/**
return true if a timeval is zero
*/
-bool ev_timeval_is_zero(const struct timeval *tv)
+bool tevent_timeval_is_zero(const struct timeval *tv)
{
return tv->tv_sec == 0 && tv->tv_usec == 0;
}
+struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
+ uint32_t usecs)
+{
+ struct timeval tv2 = *tv;
+ tv2.tv_sec += secs;
+ tv2.tv_usec += usecs;
+ tv2.tv_sec += tv2.tv_usec / 1000000;
+ tv2.tv_usec += tv2.tv_usec % 1000000;
+
+ return tv2;
+}
+
+/**
+ return a timeval in the future with a specified offset
+*/
+struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs)
+{
+ struct timeval tv = tevent_timeval_current();
+ return tevent_timeval_add(&tv, secs, usecs);
+}
+
/*
destroy a timed event
*/
@@ -156,7 +177,7 @@ struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev, TALLOC_C
last_te = NULL;
for (cur_te = ev->timer_events; cur_te; cur_te = cur_te->next) {
/* if the new event comes before the current one break */
- if (ev_timeval_compare(&te->next_event, &cur_te->next_event) < 0) {
+ if (tevent_timeval_compare(&te->next_event, &cur_te->next_event) < 0) {
break;
}
@@ -181,14 +202,14 @@ struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev, TALLOC_C
*/
struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
{
- struct timeval current_time = ev_timeval_zero();
+ struct timeval current_time = tevent_timeval_zero();
struct tevent_timer *te = ev->timer_events;
if (!te) {
/* have a default tick time of 30 seconds. This guarantees
that code that uses its own timeout checking will be
able to proceeed eventually */
- return ev_timeval_set(30, 0);
+ return tevent_timeval_set(30, 0);
}
/*
@@ -200,13 +221,13 @@ struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
* if there's a delay till the next timed event, we're done
* with just returning the delay
*/
- if (!ev_timeval_is_zero(&te->next_event)) {
+ if (!tevent_timeval_is_zero(&te->next_event)) {
struct timeval delay;
- current_time = ev_timeval_current();
+ current_time = tevent_timeval_current();
- delay = ev_timeval_until(¤t_time, &te->next_event);
- if (!ev_timeval_is_zero(&delay)) {
+ delay = tevent_timeval_until(¤t_time, &te->next_event);
+ if (!tevent_timeval_is_zero(&delay)) {
return delay;
}
}
@@ -242,6 +263,6 @@ struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
talloc_free(te);
- return ev_timeval_zero();
+ return tevent_timeval_zero();
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list