2 Unix SMB/CIFS implementation.
4 Copyright (C) Andrew Tridgell 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 composite API helper functions
25 #include "lib/events/events.h"
26 #include "libcli/raw/libcliraw.h"
27 #include "libcli/composite/composite.h"
31 block until a composite function has completed, then return the status
33 NTSTATUS composite_wait(struct composite_context *c)
35 if (c == NULL) return NT_STATUS_NO_MEMORY;
37 while (c->state < SMBCLI_REQUEST_DONE) {
38 if (event_loop_once(c->event_ctx) != 0) {
39 return NT_STATUS_UNSUCCESSFUL;
48 callback from composite_trigger_done()
50 static void composite_trigger(struct event_context *ev, struct timed_event *te,
51 struct timeval t, void *ptr)
53 struct composite_context *c = talloc_get_type(ptr, struct composite_context);
54 c->state = SMBCLI_REQUEST_DONE;
62 trigger an immediate 'done' event on a composite context
63 this is used when the composite code works out that the call
64 can be completed without waiting for any external event
66 void composite_trigger_done(struct composite_context *c)
68 /* a zero timeout means immediate */
69 event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c);