Revert "buildtools: Rename perl vendorarch configure option."
[Samba.git] / source3 / lib / smbd_tevent_queue.c
blob421f77dca267c671cc4f58a656b34494821f2f2b
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 /* Back-port of missing API from 4.2.x for tevent_queues. */
27 #include "replace.h"
28 #include <tevent.h>
29 #include "source3/lib/smbd_tevent_queue.h"
31 struct tevent_queue_wait_state {
32 uint8_t dummy;
35 static void tevent_queue_wait_trigger(struct tevent_req *req,
36 void *private_data);
38 struct tevent_req *smbd_tevent_queue_wait_send(TALLOC_CTX *mem_ctx,
39 struct tevent_context *ev,
40 struct tevent_queue *queue)
42 struct tevent_req *req;
43 struct tevent_queue_wait_state *state;
44 bool ok;
46 req = tevent_req_create(mem_ctx, &state,
47 struct tevent_queue_wait_state);
48 if (req == NULL) {
49 return NULL;
52 ok = tevent_queue_add(queue, ev, req,
53 tevent_queue_wait_trigger,
54 NULL);
55 if (!ok) {
56 tevent_req_oom(req);
57 return tevent_req_post(req, ev);
60 return req;
63 static void tevent_queue_wait_trigger(struct tevent_req *req,
64 void *private_data)
66 tevent_req_done(req);
69 bool smbd_tevent_queue_wait_recv(struct tevent_req *req)
71 enum tevent_req_state state;
72 uint64_t err;
74 if (tevent_req_is_error(req, &state, &err)) {
75 tevent_req_received(req);
76 return false;
79 tevent_req_received(req);
80 return true;