VERSION: Disable git snapshots for the 4.1.0rc1 release.
[Samba.git] / lib / tevent / tevent_wakeup.c
blob82c3942ba8e7233fd1e14e6d217ce29f16f45a33
1 /*
2 Unix SMB/CIFS implementation.
3 Infrastructure for async requests
4 Copyright (C) Volker Lendecke 2008
5 Copyright (C) Stefan Metzmacher 2009
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
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.
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.
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/>.
25 #include "replace.h"
26 #include "tevent.h"
27 #include "tevent_internal.h"
28 #include "tevent_util.h"
30 struct tevent_wakeup_state {
31 struct timeval wakeup_time;
34 struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
35 struct tevent_context *ev,
36 struct timeval wakeup_time)
38 struct tevent_req *req;
39 struct tevent_wakeup_state *state;
41 req = tevent_req_create(mem_ctx, &state,
42 struct tevent_wakeup_state);
43 if (!req) {
44 return NULL;
46 state->wakeup_time = wakeup_time;
48 if (!tevent_req_set_endtime(req, ev, wakeup_time)) {
49 goto post;
52 return req;
53 post:
54 return tevent_req_post(req, ev);
57 bool tevent_wakeup_recv(struct tevent_req *req)
59 enum tevent_req_state state;
60 uint64_t error;
62 if (tevent_req_is_error(req, &state, &error)) {
63 if (state == TEVENT_REQ_TIMED_OUT) {
64 return true;
68 return false;