smbd: Fix some whitespace
[Samba.git] / lib / tevent / tevent_wakeup.c
blobe217f337e55a671764b72f674b55ac802666c411
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 return tevent_req_post(req, ev);
51 return req;
54 bool tevent_wakeup_recv(struct tevent_req *req)
56 enum tevent_req_state state;
57 uint64_t error;
59 if (tevent_req_is_error(req, &state, &error)) {
60 if (state == TEVENT_REQ_TIMED_OUT) {
61 return true;
65 return false;