source: vendor/current/lib/tevent/tevent_wakeup.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.8 KB
Line 
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 return tevent_req_post(req, ev);
50 }
51 return req;
52}
53
54bool tevent_wakeup_recv(struct tevent_req *req)
55{
56 enum tevent_req_state state;
57 uint64_t error;
58
59 if (tevent_req_is_error(req, &state, &error)) {
60 if (state == TEVENT_REQ_TIMED_OUT) {
61 return true;
62 }
63 }
64
65 return false;
66}
67
Note: See TracBrowser for help on using the repository browser.