From 287515fd3db1932f06d56da3bb388a7efc1120eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Jan 2005 11:43:18 +0000 Subject: r4710: added a smb_composite_savefile() function, and expanded the test suite a little (This used to be commit ef4dbc443dbdebc4160209ed3f23cbb97109c414) --- source4/libcli/composite/composite.c | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source4/libcli/composite/composite.c (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c new file mode 100644 index 0000000000..f7e23cd4bc --- /dev/null +++ b/source4/libcli/composite/composite.c @@ -0,0 +1,45 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +/* + composite API helper functions +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "libcli/composite/composite.h" + + +/* + block until a composite function has completed, then return the status +*/ +NTSTATUS smb_composite_wait(struct smbcli_composite *c) +{ + if (c == NULL) return NT_STATUS_NO_MEMORY; + + while (c->state < SMBCLI_REQUEST_DONE) { + if (event_loop_once(c->req->transport->event.ctx) != 0) { + return NT_STATUS_UNSUCCESSFUL; + } + } + + return c->status; +} + + -- cgit From 4e4afdb94685388f56061a5cc188a5f5b8e1ae52 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Jan 2005 10:29:43 +0000 Subject: r4754: tidied up the composite function infrastructure to make it easier to have composite functions that are not made up of functions that operate on smbcli_request structures. (This used to be commit 4f6055b4fb7e287a29544ff1ca4e22f698efc478) --- source4/libcli/composite/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index f7e23cd4bc..d4eb5a9323 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -34,7 +34,7 @@ NTSTATUS smb_composite_wait(struct smbcli_composite *c) if (c == NULL) return NT_STATUS_NO_MEMORY; while (c->state < SMBCLI_REQUEST_DONE) { - if (event_loop_once(c->req->transport->event.ctx) != 0) { + if (event_loop_once(c->event_ctx) != 0) { return NT_STATUS_UNSUCCESSFUL; } } -- cgit From 9a70f446fc4abc2bd1278772810c0e8132f4bea4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Jan 2005 08:30:44 +0000 Subject: r5126: the composite code is no longer client specific or smb specific, so rename the core structure to composite_context and the wait routine to composite_wait() (suggestion from metze) (This used to be commit cf11d05e35179c2c3e51c5ab370cd0a3fb15f24a) --- source4/libcli/composite/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index d4eb5a9323..998631204d 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -29,7 +29,7 @@ /* block until a composite function has completed, then return the status */ -NTSTATUS smb_composite_wait(struct smbcli_composite *c) +NTSTATUS composite_wait(struct composite_context *c) { if (c == NULL) return NT_STATUS_NO_MEMORY; -- cgit From 66170ef8b36b499aa5b44ef10c1bd362a50f2636 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 3 Feb 2005 02:35:52 +0000 Subject: r5185: make all the events data structures private to events.c. This will make it possible to add optimisations to the events code such as keeping the next timed event in a sorted list, and using epoll for file descriptor events. I also removed the loop events code, as it wasn't being used anywhere, and changed timed events to always be one-shot (as adding a new timed event in the event handler is so easy to do if needed) (This used to be commit d7b4b6de51342a65bf46fce772d313f92f8d73d3) --- source4/libcli/composite/composite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 998631204d..e08543a94b 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "events.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" -- cgit From 131dc76d56df40b3511c47e54f15412a25b491f8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 3 Feb 2005 11:56:03 +0000 Subject: r5197: moved events code to lib/events/ (suggestion from metze) (This used to be commit 7f54c8a339f36aa43c9340be70ab7f0067593ef2) --- source4/libcli/composite/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index e08543a94b..2b8ddea897 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -22,7 +22,7 @@ */ #include "includes.h" -#include "events.h" +#include "lib/events/events.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" -- cgit From 45f760973d9b5c0663608e779eb337c0648e9313 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 13 Sep 2005 12:46:03 +0000 Subject: r10200: added a composite_trigger_done() call that allows a composite function to cause an event to happen immediately. This allows metzes patch for recognising IPs in resolve_name() to work, and also allows us to remove some of the other code where we currently do specific checks for is_ipaddress(). (This used to be commit 9cc000d868e1257ef6429f6f6f1f9d3c28ca330f) --- source4/libcli/composite/composite.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 2b8ddea897..f04309bbfb 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -44,3 +44,27 @@ NTSTATUS composite_wait(struct composite_context *c) } +/* + callback from composite_trigger_done() +*/ +static void composite_trigger(struct event_context *ev, struct timed_event *te, + struct timeval t, void *ptr) +{ + struct composite_context *c = talloc_get_type(ptr, struct composite_context); + c->state = SMBCLI_REQUEST_DONE; + if (c->async.fn) { + c->async.fn(c); + } +} + + +/* + trigger an immediate 'done' event on a composite context + this is used when the composite code works out that the call + can be completed without waiting for any external event +*/ +void composite_trigger_done(struct composite_context *c) +{ + /* a zero timeout means immediate */ + event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); +} -- cgit From ab4d635b92b116b02b88843b4ec4f5b7517bab1a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 26 Sep 2005 11:47:55 +0000 Subject: r10504: - seperate implementation specific stuff, from the generic composite stuff. - don't use SMBCLI_REQUEST_* state's in the genreic composite stuff - move monitor_fn to libnet. NOTE: I have maybe found some bugs, in code that is dirrectly in DONE or ERROR state in the _send() function. I haven't fixed this bugs in this commit! We may need some composite_trigger_*() functions or so. And maybe some other generic helper functions... metze (This used to be commit 4527815a0a9b96e460f301cb1f0c0b3964c166fc) --- source4/libcli/composite/composite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index f04309bbfb..4a5247c9ea 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -34,7 +34,7 @@ NTSTATUS composite_wait(struct composite_context *c) { if (c == NULL) return NT_STATUS_NO_MEMORY; - while (c->state < SMBCLI_REQUEST_DONE) { + while (c->state < COMPOSITE_STATE_DONE) { if (event_loop_once(c->event_ctx) != 0) { return NT_STATUS_UNSUCCESSFUL; } @@ -51,7 +51,6 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, struct timeval t, void *ptr) { struct composite_context *c = talloc_get_type(ptr, struct composite_context); - c->state = SMBCLI_REQUEST_DONE; if (c->async.fn) { c->async.fn(c); } @@ -65,6 +64,7 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, */ void composite_trigger_done(struct composite_context *c) { + c->state = COMPOSITE_STATE_DONE; /* a zero timeout means immediate */ event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); } -- cgit From fa70d1d0c28ff8065ca40a3682dc50131b7a6ecf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Sep 2005 10:29:13 +0000 Subject: r10529: fix a crash bug in full async code the uses the composite_trigger_done() code the event subsystem wants to free timed_events! metze (This used to be commit dc5d5953b60662b895ad148525e84d82882d62a8) --- source4/libcli/composite/composite.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 4a5247c9ea..f6fc61d764 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -52,6 +52,12 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, { struct composite_context *c = talloc_get_type(ptr, struct composite_context); if (c->async.fn) { + /* + * the event is a child of req, + * and req will be free'ed by the callback fn + * but the events code wants to free the event itself + */ + talloc_steal(ev, te); c->async.fn(c); } } -- cgit From 38e43be7b89673282f8853ffedf726d84ef5ce30 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Sep 2005 12:54:08 +0000 Subject: r10537: - we now use a much nicer way to handle talloc_free(timed_event) the events code replaces a destructor to one that returns allways -1 while it's calling the event handler - we don't need the composite and winsrepl specific fixes any more - this also fixes the problem with smbcli, dcerpc, cldap, ldap and nbt request timeouts metze (This used to be commit 495996cfc49a1c6eefde6ff04fc75e0739be3aab) --- source4/libcli/composite/composite.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index f6fc61d764..4a5247c9ea 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -52,12 +52,6 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, { struct composite_context *c = talloc_get_type(ptr, struct composite_context); if (c->async.fn) { - /* - * the event is a child of req, - * and req will be free'ed by the callback fn - * but the events code wants to free the event itself - */ - talloc_steal(ev, te); c->async.fn(c); } } -- cgit From 9e5d44d56733f598e0a25ad1e72eccf3267be51a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 9 Oct 2005 20:32:24 +0000 Subject: r10852: Continuation-based programming can become a bit spaghetti... Initialize a domain structure properly. Excerpt from wb_init_domain.c: /* * Initialize a domain: * * - With schannel credentials, try to open the SMB connection with the machine * creds. Fall back to anonymous. * * - If we have schannel creds, do the auth2 and open the schannel'ed netlogon * pipe. * * - Open LSA. If we have machine creds, try to open with ntlmssp. Fall back * to schannel and then to anon bind. * * - With queryinfopolicy, verify that we're talking to the right domain * * A bit complex, but with all the combinations I think it's the best we can * get. NT4, W2k3SP1 and W2k all have different combinations, but in the end we * have a signed&sealed lsa connection on all of them. * * Is this overkill? In particular the authenticated SMB connection seems a * bit overkill, given that we do schannel for netlogon and ntlmssp for * lsa later on w2k3, the others don't do this anyway. */ Thanks to Jeremy for his detective work, and to the Samba4 team for providing such a great infrastructure. Next step is to connect to SAM. Do it via LDAP if we can, fall back to samr with all we have. Volker (This used to be commit 3e69fdc07cd76b4bc01b032148609ee4b59b8be7) --- source4/libcli/composite/composite.c | 74 +++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 4a5247c9ea..6458a971b4 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -25,7 +25,7 @@ #include "lib/events/events.h" #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" - +#include "lib/messaging/irpc.h" /* block until a composite function has completed, then return the status @@ -68,3 +68,75 @@ void composite_trigger_done(struct composite_context *c) /* a zero timeout means immediate */ event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); } + + +/* + * Some composite helpers that are handy if you write larger composite + * functions. + */ + +BOOL comp_is_ok(struct composite_context *ctx) +{ + if (NT_STATUS_IS_OK(ctx->status)) { + return True; + } + ctx->state = COMPOSITE_STATE_ERROR; + if (ctx->async.fn != NULL) { + ctx->async.fn(ctx); + } + return False; +} + +void comp_error(struct composite_context *ctx, NTSTATUS status) +{ + ctx->status = status; + SMB_ASSERT(!comp_is_ok(ctx)); +} + +BOOL comp_nomem(const void *p, struct composite_context *ctx) +{ + if (p != NULL) { + return False; + } + comp_error(ctx, NT_STATUS_NO_MEMORY); + return True; +} + +void comp_done(struct composite_context *ctx) +{ + ctx->state = COMPOSITE_STATE_DONE; + if (ctx->async.fn != NULL) { + ctx->async.fn(ctx); + } +} + +void comp_cont(struct composite_context *ctx, + struct composite_context *new_ctx, + void (*continuation)(struct composite_context *), + void *private_data) +{ + if (comp_nomem(new_ctx, ctx)) return; + new_ctx->async.fn = continuation; + new_ctx->async.private_data = private_data; +} + +void rpc_cont(struct composite_context *ctx, + struct rpc_request *new_req, + void (*continuation)(struct rpc_request *), + void *private_data) +{ + if (comp_nomem(new_req, ctx)) return; + new_req->async.callback = continuation; + new_req->async.private = private_data; +} + +void irpc_cont(struct composite_context *ctx, + struct irpc_request *new_req, + void (*continuation)(struct irpc_request *), + void *private_data) +{ + if (comp_nomem(new_req, ctx)) return; + new_req->async.fn = continuation; + new_req->async.private = private_data; +} + -- cgit From d617556ef50863d6a03c81a04f0f6b05848a250e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Oct 2005 19:57:55 +0000 Subject: r10878: Reply to some comments by tridge and metze: * rename the composite helper functions from comp_* to composite_* * Move the lsa initialization to wb_connect_lsa.c * Equip smb_composite_connect with a fallback_to_anonymous The latter two simplify wb_init_domain.c quite a bit. Volker (This used to be commit deb127e04ea01ae93394da5ebffb39d81caeb6d9) --- source4/libcli/composite/composite.c | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 6458a971b4..f5eed77300 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -75,7 +75,7 @@ void composite_trigger_done(struct composite_context *c) * functions. */ -BOOL comp_is_ok(struct composite_context *ctx) +BOOL composite_is_ok(struct composite_context *ctx) { if (NT_STATUS_IS_OK(ctx->status)) { return True; @@ -87,22 +87,22 @@ BOOL comp_is_ok(struct composite_context *ctx) return False; } -void comp_error(struct composite_context *ctx, NTSTATUS status) +void composite_error(struct composite_context *ctx, NTSTATUS status) { ctx->status = status; - SMB_ASSERT(!comp_is_ok(ctx)); + SMB_ASSERT(!composite_is_ok(ctx)); } -BOOL comp_nomem(const void *p, struct composite_context *ctx) +BOOL composite_nomem(const void *p, struct composite_context *ctx) { if (p != NULL) { return False; } - comp_error(ctx, NT_STATUS_NO_MEMORY); + composite_error(ctx, NT_STATUS_NO_MEMORY); return True; } -void comp_done(struct composite_context *ctx) +void composite_done(struct composite_context *ctx) { ctx->state = COMPOSITE_STATE_DONE; if (ctx->async.fn != NULL) { @@ -110,32 +110,32 @@ void comp_done(struct composite_context *ctx) } } -void comp_cont(struct composite_context *ctx, - struct composite_context *new_ctx, - void (*continuation)(struct composite_context *), - void *private_data) +void composite_continue(struct composite_context *ctx, + struct composite_context *new_ctx, + void (*continuation)(struct composite_context *), + void *private_data) { - if (comp_nomem(new_ctx, ctx)) return; + if (composite_nomem(new_ctx, ctx)) return; new_ctx->async.fn = continuation; new_ctx->async.private_data = private_data; } -void rpc_cont(struct composite_context *ctx, - struct rpc_request *new_req, - void (*continuation)(struct rpc_request *), - void *private_data) +void composite_continue_rpc(struct composite_context *ctx, + struct rpc_request *new_req, + void (*continuation)(struct rpc_request *), + void *private_data) { - if (comp_nomem(new_req, ctx)) return; + if (composite_nomem(new_req, ctx)) return; new_req->async.callback = continuation; new_req->async.private = private_data; } -void irpc_cont(struct composite_context *ctx, - struct irpc_request *new_req, - void (*continuation)(struct irpc_request *), - void *private_data) +void composite_continue_irpc(struct composite_context *ctx, + struct irpc_request *new_req, + void (*continuation)(struct irpc_request *), + void *private_data) { - if (comp_nomem(new_req, ctx)) return; + if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; new_req->async.private = private_data; } -- cgit From d68319431e62e43c0ecb23328e3162128d823958 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 16 Oct 2005 12:43:09 +0000 Subject: r11095: Implement wb_getuserdomgroups. Tridge, if you have the time, you might want to look at a problem I'm having with unix domain stream sockets. From a comment in this commit: /* Using composite_trigger_error here causes problems with the client * socket. Linux 2.6.8 gives me a ECONNRESET on the next read after * writing the reply when I don't wait the 100 milliseconds. */ This is in winbind/wb_cmd_userdomgroups.c:93. The problem I have is that I can not *immediately* send an error reply to the client because the next receive fails. Waiting 100 milliseconds helps. It might also be a problem with epoll(), I don't really know. I'd appreciate if you took a brief look at this, maybe I'm doing something wrong. Thanks, Volker (This used to be commit 3e535cce743710a68a4264e4f66e9c0c4d6770c6) --- source4/libcli/composite/composite.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index f5eed77300..c78d039905 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -69,6 +69,13 @@ void composite_trigger_done(struct composite_context *c) event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); } +void composite_trigger_error(struct composite_context *c) +{ + c->state = COMPOSITE_STATE_ERROR; + /* a zero timeout means immediate */ + event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); +} + /* * Some composite helpers that are handy if you write larger composite -- cgit From 8383a3459aa91a6edbdd996b19a685bf0cbd6627 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Nov 2005 18:49:30 +0000 Subject: r11885: Add forgotten files (This used to be commit 470cc5952981c3625c7e35f44c9fd41d19593396) --- source4/libcli/composite/composite.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index c78d039905..ba9b0673da 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -147,3 +147,12 @@ void composite_continue_irpc(struct composite_context *ctx, new_req->async.private = private_data; } +void composite_continue_smb(struct composite_context *ctx, + struct smbcli_request *new_req, + void (*continuation)(struct smbcli_request *), + void *private_data) +{ + if (composite_nomem(new_req, ctx)) return; + new_req->async.fn = continuation; + new_req->async.private = private_data; +} -- cgit From 9d3b3e83953a8a97cf830581bd7933a576312cad Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 30 Nov 2005 12:39:32 +0000 Subject: r11971: add nbt specific continue wrapper metze (This used to be commit b8c5978df18b98db89069e02597d483f893e39ae) --- source4/libcli/composite/composite.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index ba9b0673da..c4b771509f 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -26,6 +26,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" #include "lib/messaging/irpc.h" +#include "libcli/nbt/libnbt.h" /* block until a composite function has completed, then return the status @@ -156,3 +157,13 @@ void composite_continue_smb(struct composite_context *ctx, new_req->async.fn = continuation; new_req->async.private = private_data; } + +void composite_continue_nbt(struct composite_context *ctx, + struct nbt_name_request *new_req, + void (*continuation)(struct nbt_name_request *), + void *private_data) +{ + if (composite_nomem(new_req, ctx)) return; + new_req->async.fn = continuation; + new_req->async.private = private_data; +} -- cgit From 4a397070b6259cc97ccf7ce18f5a22dfff8e7d41 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 5 Dec 2005 22:34:45 +0000 Subject: r12079: Fix to the comment for sake of completness... rafal (This used to be commit 7aa40e3a3ff7a655c5ed8ee67c55af92193815f1) --- source4/libcli/composite/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index c4b771509f..3842ddfe9f 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -46,7 +46,7 @@ NTSTATUS composite_wait(struct composite_context *c) /* - callback from composite_trigger_done() + callback from composite_trigger_done() and composite_trigger_error() */ static void composite_trigger(struct event_context *ev, struct timed_event *te, struct timeval t, void *ptr) -- cgit From 111a920fdb92ccef32f89b2f992bdd3051e5ac54 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 8 Dec 2005 01:13:45 +0000 Subject: r12116: got rid of composite_trigger_done() and composite_trigger_error(), and instead make the normal composite_done() and composite_error() functions automatically trigger a delayed callback if the caller has had no opportunity to setup a async callback this removes one of the common mistakes in writing a composite function (This used to be commit f9413ce792ded682e05134b66d433eeec293e6f1) --- source4/libcli/composite/composite.c | 65 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 34 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 3842ddfe9f..c9cc20e923 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -35,6 +35,8 @@ NTSTATUS composite_wait(struct composite_context *c) { if (c == NULL) return NT_STATUS_NO_MEMORY; + c->used_wait = True; + while (c->state < COMPOSITE_STATE_DONE) { if (event_loop_once(c->event_ctx) != 0) { return NT_STATUS_UNSUCCESSFUL; @@ -45,44 +47,10 @@ NTSTATUS composite_wait(struct composite_context *c) } -/* - callback from composite_trigger_done() and composite_trigger_error() -*/ -static void composite_trigger(struct event_context *ev, struct timed_event *te, - struct timeval t, void *ptr) -{ - struct composite_context *c = talloc_get_type(ptr, struct composite_context); - if (c->async.fn) { - c->async.fn(c); - } -} - - -/* - trigger an immediate 'done' event on a composite context - this is used when the composite code works out that the call - can be completed without waiting for any external event -*/ -void composite_trigger_done(struct composite_context *c) -{ - c->state = COMPOSITE_STATE_DONE; - /* a zero timeout means immediate */ - event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); -} - -void composite_trigger_error(struct composite_context *c) -{ - c->state = COMPOSITE_STATE_ERROR; - /* a zero timeout means immediate */ - event_add_timed(c->event_ctx, c, timeval_zero(), composite_trigger, c); -} - - /* * Some composite helpers that are handy if you write larger composite * functions. */ - BOOL composite_is_ok(struct composite_context *ctx) { if (NT_STATUS_IS_OK(ctx->status)) { @@ -95,8 +63,34 @@ BOOL composite_is_ok(struct composite_context *ctx) return False; } +/* + callback from composite_done() and composite_error() + + this is used to allow for a composite function to complete without + going through any state transitions. When that happens the caller + has had no opportunity to fill in the async callback fields + (ctx->async.fn and ctx->async.private) which means the usual way of + dealing with composite functions doesn't work. To cope with this, + we trigger a timer event that will happen then the event loop is + re-entered. This gives the caller a chance to setup the callback, + and allows the caller to ignore the fact that the composite + function completed early +*/ +static void composite_trigger(struct event_context *ev, struct timed_event *te, + struct timeval t, void *ptr) +{ + struct composite_context *c = talloc_get_type(ptr, struct composite_context); + if (c->async.fn) { + c->async.fn(c); + } +} + + void composite_error(struct composite_context *ctx, NTSTATUS status) { + if (!ctx->used_wait && !ctx->async.fn) { + event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); + } ctx->status = status; SMB_ASSERT(!composite_is_ok(ctx)); } @@ -112,6 +106,9 @@ BOOL composite_nomem(const void *p, struct composite_context *ctx) void composite_done(struct composite_context *ctx) { + if (!ctx->used_wait && !ctx->async.fn) { + event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); + } ctx->state = COMPOSITE_STATE_DONE; if (ctx->async.fn != NULL) { ctx->async.fn(ctx); -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/libcli/composite/composite.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index c9cc20e923..33b5b77c06 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -26,7 +26,6 @@ #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" #include "lib/messaging/irpc.h" -#include "libcli/nbt/libnbt.h" /* block until a composite function has completed, then return the status -- cgit From af30a32b6924b0f2b701186e435defbca2ebd1aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 5 Mar 2006 17:15:19 +0000 Subject: r13840: Mark some functions as public. (This used to be commit 9a188eb1f48a50d92a67a4fc2b3899b90074059a) --- source4/libcli/composite/composite.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 33b5b77c06..d0d2bc3886 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -30,7 +30,7 @@ /* block until a composite function has completed, then return the status */ -NTSTATUS composite_wait(struct composite_context *c) +_PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) { if (c == NULL) return NT_STATUS_NO_MEMORY; @@ -50,7 +50,7 @@ NTSTATUS composite_wait(struct composite_context *c) * Some composite helpers that are handy if you write larger composite * functions. */ -BOOL composite_is_ok(struct composite_context *ctx) +_PUBLIC_ BOOL composite_is_ok(struct composite_context *ctx) { if (NT_STATUS_IS_OK(ctx->status)) { return True; @@ -85,7 +85,7 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, } -void composite_error(struct composite_context *ctx, NTSTATUS status) +_PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status) { if (!ctx->used_wait && !ctx->async.fn) { event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); @@ -94,7 +94,7 @@ void composite_error(struct composite_context *ctx, NTSTATUS status) SMB_ASSERT(!composite_is_ok(ctx)); } -BOOL composite_nomem(const void *p, struct composite_context *ctx) +_PUBLIC_ BOOL composite_nomem(const void *p, struct composite_context *ctx) { if (p != NULL) { return False; @@ -103,7 +103,7 @@ BOOL composite_nomem(const void *p, struct composite_context *ctx) return True; } -void composite_done(struct composite_context *ctx) +_PUBLIC_ void composite_done(struct composite_context *ctx) { if (!ctx->used_wait && !ctx->async.fn) { event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); @@ -114,7 +114,7 @@ void composite_done(struct composite_context *ctx) } } -void composite_continue(struct composite_context *ctx, +_PUBLIC_ void composite_continue(struct composite_context *ctx, struct composite_context *new_ctx, void (*continuation)(struct composite_context *), void *private_data) @@ -124,7 +124,7 @@ void composite_continue(struct composite_context *ctx, new_ctx->async.private_data = private_data; } -void composite_continue_rpc(struct composite_context *ctx, +_PUBLIC_ void composite_continue_rpc(struct composite_context *ctx, struct rpc_request *new_req, void (*continuation)(struct rpc_request *), void *private_data) @@ -134,7 +134,7 @@ void composite_continue_rpc(struct composite_context *ctx, new_req->async.private = private_data; } -void composite_continue_irpc(struct composite_context *ctx, +_PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, struct irpc_request *new_req, void (*continuation)(struct irpc_request *), void *private_data) @@ -144,7 +144,7 @@ void composite_continue_irpc(struct composite_context *ctx, new_req->async.private = private_data; } -void composite_continue_smb(struct composite_context *ctx, +_PUBLIC_ void composite_continue_smb(struct composite_context *ctx, struct smbcli_request *new_req, void (*continuation)(struct smbcli_request *), void *private_data) @@ -154,7 +154,7 @@ void composite_continue_smb(struct composite_context *ctx, new_req->async.private = private_data; } -void composite_continue_nbt(struct composite_context *ctx, +_PUBLIC_ void composite_continue_nbt(struct composite_context *ctx, struct nbt_name_request *new_req, void (*continuation)(struct nbt_name_request *), void *private_data) -- cgit From 66e3a63c19b3541c439778ad3d8cab1d8acf29d4 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Sun, 12 Mar 2006 13:14:21 +0000 Subject: r14239: Fix indentation. rafal (This used to be commit 7aa90f58b9beb410a188fd229c539f2315c81a38) --- source4/libcli/composite/composite.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index d0d2bc3886..c8d6cd136a 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -115,9 +115,9 @@ _PUBLIC_ void composite_done(struct composite_context *ctx) } _PUBLIC_ void composite_continue(struct composite_context *ctx, - struct composite_context *new_ctx, - void (*continuation)(struct composite_context *), - void *private_data) + struct composite_context *new_ctx, + void (*continuation)(struct composite_context *), + void *private_data) { if (composite_nomem(new_ctx, ctx)) return; new_ctx->async.fn = continuation; @@ -125,9 +125,9 @@ _PUBLIC_ void composite_continue(struct composite_context *ctx, } _PUBLIC_ void composite_continue_rpc(struct composite_context *ctx, - struct rpc_request *new_req, - void (*continuation)(struct rpc_request *), - void *private_data) + struct rpc_request *new_req, + void (*continuation)(struct rpc_request *), + void *private_data) { if (composite_nomem(new_req, ctx)) return; new_req->async.callback = continuation; @@ -135,9 +135,9 @@ _PUBLIC_ void composite_continue_rpc(struct composite_context *ctx, } _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, - struct irpc_request *new_req, - void (*continuation)(struct irpc_request *), - void *private_data) + struct irpc_request *new_req, + void (*continuation)(struct irpc_request *), + void *private_data) { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; @@ -145,9 +145,9 @@ _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, } _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, - struct smbcli_request *new_req, - void (*continuation)(struct smbcli_request *), - void *private_data) + struct smbcli_request *new_req, + void (*continuation)(struct smbcli_request *), + void *private_data) { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; @@ -155,9 +155,9 @@ _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, } _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx, - struct nbt_name_request *new_req, - void (*continuation)(struct nbt_name_request *), - void *private_data) + struct nbt_name_request *new_req, + void (*continuation)(struct nbt_name_request *), + void *private_data) { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; -- cgit From 35349a58df5b69446607fbd742a05f57f3515319 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 18 Mar 2006 15:42:57 +0000 Subject: r14542: Remove librpc, libndr and libnbt from includes.h (This used to be commit 51b4270513752d2eafbe77f9de598de16ef84a1f) --- source4/libcli/composite/composite.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index c8d6cd136a..9a745e3013 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -26,6 +26,8 @@ #include "libcli/raw/libcliraw.h" #include "libcli/composite/composite.h" #include "lib/messaging/irpc.h" +#include "librpc/rpc/dcerpc.h" +#include "libcli/nbt/libnbt.h" /* block until a composite function has completed, then return the status -- cgit From 7e949c9fb12483df11c7e926e2c5ed8e4b9b9d20 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 30 Jul 2006 16:48:41 +0000 Subject: r17317: - add a composite_create() function that allocates and initialize the composite_context structue, we should try to convert all code to use this because there're a lot of places where the we have bugs with this task... - add a composite_continue_smb2() helper We should try to hide the internals of the composite code from the users to avoid errors (and I found a lot of them... and will fix then step by step) metze (This used to be commit a16180f20246844d05996d385fcb71893e08f589) --- source4/libcli/composite/composite.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 9a745e3013..aea25f183e 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -24,11 +24,29 @@ #include "includes.h" #include "lib/events/events.h" #include "libcli/raw/libcliraw.h" +#include "libcli/smb2/smb2.h" #include "libcli/composite/composite.h" #include "lib/messaging/irpc.h" #include "librpc/rpc/dcerpc.h" #include "libcli/nbt/libnbt.h" +/* + create a new composite_context structure + and initialize it +*/ +_PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx, + struct event_context *ev) +{ + struct composite_context *c; + + c = talloc_zero(mem_ctx, struct composite_context); + if (!c) return NULL; + c->state = COMPOSITE_STATE_IN_PROGRESS; + c->event_ctx = ev; + + return c; +} + /* block until a composite function has completed, then return the status */ @@ -156,6 +174,16 @@ _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, new_req->async.private = private_data; } +_PUBLIC_ void composite_continue_smb2(struct composite_context *ctx, + struct smb2_request *new_req, + void (*continuation)(struct smb2_request *), + void *private_data) +{ + if (composite_nomem(new_req, ctx)) return; + new_req->async.fn = continuation; + new_req->async.private = private_data; +} + _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx, struct nbt_name_request *new_req, void (*continuation)(struct nbt_name_request *), -- cgit From ed962c833bd37b05c1fadd1857b22b5566d7f850 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 8 Sep 2006 03:06:47 +0000 Subject: r18243: when setting up a composite continuation, if the context has already finished when we need to trigger the continuation immediately. Via a fairly complex path, this fixes the problem where all hosts in the build farm that do not have ipv6 failed a lot of the RPC tests. This happened because the dcerpc_connect() async code used a composite_continue() on a context which was already in an error state, due to the socket backend saying that ipv6 was unavailable (This used to be commit dbf935d38b6b1fea5ed00e94c9b1a518cb14768b) --- source4/libcli/composite/composite.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index aea25f183e..e690c33f58 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -142,6 +142,13 @@ _PUBLIC_ void composite_continue(struct composite_context *ctx, if (composite_nomem(new_ctx, ctx)) return; new_ctx->async.fn = continuation; new_ctx->async.private_data = private_data; + + /* if we are setting up a continuation, and the context has + already finished, then we should run the callback with an + immediate event, otherwise we can be stuck forever */ + if (new_ctx->state >= COMPOSITE_STATE_DONE && continuation) { + event_add_timed(new_ctx->event_ctx, new_ctx, timeval_zero(), composite_trigger, new_ctx); + } } _PUBLIC_ void composite_continue_rpc(struct composite_context *ctx, -- cgit From 40cd2d778093d7799b27b6beb37166d8a53f965c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 May 2007 14:52:54 +0000 Subject: r22944: fix bug #4618: rename private -> private_data metze (This used to be commit 58551f2f28fce8f1fcd04736c47ecd7458f32ea2) --- source4/libcli/composite/composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index e690c33f58..e929ad70e3 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -158,7 +158,7 @@ _PUBLIC_ void composite_continue_rpc(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.callback = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx, -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/composite/composite.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index e929ad70e3..3e21c3823c 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* composite API helper functions -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/libcli/composite/composite.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 3e21c3823c..67d5885497 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -53,7 +53,7 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) { if (c == NULL) return NT_STATUS_NO_MEMORY; - c->used_wait = True; + c->used_wait = true; while (c->state < COMPOSITE_STATE_DONE) { if (event_loop_once(c->event_ctx) != 0) { @@ -69,16 +69,16 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) * Some composite helpers that are handy if you write larger composite * functions. */ -_PUBLIC_ BOOL composite_is_ok(struct composite_context *ctx) +_PUBLIC_ bool composite_is_ok(struct composite_context *ctx) { if (NT_STATUS_IS_OK(ctx->status)) { - return True; + return true; } ctx->state = COMPOSITE_STATE_ERROR; if (ctx->async.fn != NULL) { ctx->async.fn(ctx); } - return False; + return false; } /* @@ -113,13 +113,13 @@ _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status) SMB_ASSERT(!composite_is_ok(ctx)); } -_PUBLIC_ BOOL composite_nomem(const void *p, struct composite_context *ctx) +_PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx) { if (p != NULL) { - return False; + return false; } composite_error(ctx, NT_STATUS_NO_MEMORY); - return True; + return true; } _PUBLIC_ void composite_done(struct composite_context *ctx) -- cgit From e08a78abcd7cf55322cc720f47fa3a2bfe491c31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 12 Feb 2008 12:16:38 +0100 Subject: [PATCH] composite: make it possible to call composite_is_ok() without callback fn metze (This used to be commit 4e459f1fb3ab60c586df9a08cdc57db424a30b18) --- source4/libcli/composite/composite.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 67d5885497..aab7487a42 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -64,23 +64,6 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) return c->status; } - -/* - * Some composite helpers that are handy if you write larger composite - * functions. - */ -_PUBLIC_ bool composite_is_ok(struct composite_context *ctx) -{ - if (NT_STATUS_IS_OK(ctx->status)) { - return true; - } - ctx->state = COMPOSITE_STATE_ERROR; - if (ctx->async.fn != NULL) { - ctx->async.fn(ctx); - } - return false; -} - /* callback from composite_done() and composite_error() @@ -110,7 +93,10 @@ _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status) event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); } ctx->status = status; - SMB_ASSERT(!composite_is_ok(ctx)); + ctx->state = COMPOSITE_STATE_ERROR; + if (ctx->async.fn != NULL) { + ctx->async.fn(ctx); + } } _PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx) @@ -122,6 +108,15 @@ _PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx) return true; } +_PUBLIC_ bool composite_is_ok(struct composite_context *ctx) +{ + if (NT_STATUS_IS_OK(ctx->status)) { + return true; + } + composite_error(ctx, ctx->status); + return false; +} + _PUBLIC_ void composite_done(struct composite_context *ctx) { if (!ctx->used_wait && !ctx->async.fn) { -- cgit From 482f33077b965bab7f6ccb82cee03b66d70c57b7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Mar 2008 10:35:54 +0100 Subject: Add my copyright If I remember it right and when I look at the git log, then this way to do the async functions was designed by me. (This used to be commit 8d44f997c88b97fc40a88eebd50b6df720c0c10f) --- source4/libcli/composite/composite.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index aab7487a42..26169e7838 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -1,6 +1,7 @@ /* Unix SMB/CIFS implementation. + Copyright (C) Volker Lendecke 2005 Copyright (C) Andrew Tridgell 2005 This program is free software; you can redistribute it and/or modify -- cgit From 4e83011f72ba3df387512755a17760b42a7bf2f2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 21 Apr 2008 17:58:23 -0400 Subject: Remove more event_context_init() uses from function calls within deep down the code. Make sure we pass around the event_context where we need it instead. All test but a few python ones fail. Jelmer promised to fix them. (This used to be commit 3045d391626fba169aa26be52174883e18d323e9) --- source4/libcli/composite/composite.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 26169e7838..966f56cba8 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -42,7 +42,11 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx, c = talloc_zero(mem_ctx, struct composite_context); if (!c) return NULL; c->state = COMPOSITE_STATE_IN_PROGRESS; - c->event_ctx = ev; + c->event_ctx = talloc_reference(c, ev); + if (!c->event_ctx) { + talloc_free(c); + return NULL; + } return c; } -- cgit From 14ca2b5b5db4abb1e6ab624365fdebfd9ec422e0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 May 2008 15:02:58 +1000 Subject: - added a composite_wait_free() call - allow composite_error() to take NT_STATUS_OK (This used to be commit 5240e1e25655af1f9b92da99e85d845bf30c4e9e) --- source4/libcli/composite/composite.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/libcli/composite/composite.c') diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c index 966f56cba8..3e3f224f47 100644 --- a/source4/libcli/composite/composite.c +++ b/source4/libcli/composite/composite.c @@ -69,6 +69,17 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c) return c->status; } +/* + block until a composite function has completed, then return the status. + Free the composite context before returning +*/ +_PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c) +{ + NTSTATUS status = composite_wait(c); + talloc_free(c); + return status; +} + /* callback from composite_done() and composite_error() @@ -94,6 +105,12 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te, _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status) { + /* you are allowed to pass NT_STATUS_OK to composite_error(), in which + case it is equivalent to composite_done() */ + if (NT_STATUS_IS_OK(status)) { + composite_done(ctx); + return; + } if (!ctx->used_wait && !ctx->async.fn) { event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx); } @@ -187,7 +204,7 @@ _PUBLIC_ void composite_continue_smb2(struct composite_context *ctx, { if (composite_nomem(new_req, ctx)) return; new_req->async.fn = continuation; - new_req->async.private = private_data; + new_req->async.private_data = private_data; } _PUBLIC_ void composite_continue_nbt(struct composite_context *ctx, -- cgit