• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/samba-3.5.8/lib/tevent/
1/*
2   Unix SMB/CIFS implementation.
3   Infrastructure for async requests
4   Copyright (C) Volker Lendecke 2008
5   Copyright (C) Stefan Metzmacher 2009
6
7     ** NOTE! The following LGPL license applies to the tevent
8     ** library. This does NOT imply that all of Samba is released
9     ** under the LGPL
10
11   This library is free software; you can redistribute it and/or
12   modify it under the terms of the GNU Lesser General Public
13   License as published by the Free Software Foundation; either
14   version 3 of the License, or (at your option) any later version.
15
16   This library is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public
22   License along with this library; if not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "replace.h"
26#include "tevent.h"
27#include "tevent_internal.h"
28#include "tevent_util.h"
29
30struct tevent_wakeup_state {
31	struct timeval wakeup_time;
32};
33
34struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
35				      struct tevent_context *ev,
36				      struct timeval wakeup_time)
37{
38	struct tevent_req *req;
39	struct tevent_wakeup_state *state;
40
41	req = tevent_req_create(mem_ctx, &state,
42				struct tevent_wakeup_state);
43	if (!req) {
44		return NULL;
45	}
46	state->wakeup_time = wakeup_time;
47
48	if (!tevent_req_set_endtime(req, ev, wakeup_time)) {
49		goto post;
50	}
51
52	return req;
53post:
54	return tevent_req_post(req, ev);
55}
56
57bool tevent_wakeup_recv(struct tevent_req *req)
58{
59	enum tevent_req_state state;
60	uint64_t error;
61
62	if (tevent_req_is_error(req, &state, &error)) {
63		if (state == TEVENT_REQ_TIMED_OUT) {
64			return true;
65		}
66	}
67
68	return false;
69}
70
71