[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Mon Oct 10 15:24:04 MDT 2011
The branch, master has been updated
via b787b6e libcli/cldap: don't pass tevent_context to cldap_socket_init()
via af24591 libcli/cldap: make use of explicit tevent_contexts
via 5a7a1b3 libcli/cldap: pass tevent_context to cldap_search_send()
via 2cd76b0 libcli/cldap: pass tevent_context to cldap_netlogon_send()
via 3ed85d7 libcli/cldap: pass tevent_context to cldap_set_incoming_handler()
from ec0c1f2 s3:smb2_create: fix allocation size return value when opening existing files
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit b787b6e1bd70f90702568fa4503c1d2e6ca0a59e
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 10 15:58:24 2011 +0200
libcli/cldap: don't pass tevent_context to cldap_socket_init()
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Mon Oct 10 23:23:07 CEST 2011 on sn-devel-104
commit af24591a20c7412862c74f7e088e9d59bf667309
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 10 15:48:11 2011 +0200
libcli/cldap: make use of explicit tevent_contexts
metze
commit 5a7a1b35be01b7461549a2202ccabd3608b054a1
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 10 15:46:17 2011 +0200
libcli/cldap: pass tevent_context to cldap_search_send()
metze
commit 2cd76b0931582463a6e72df227f3e100dfb00f84
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 10 15:42:57 2011 +0200
libcli/cldap: pass tevent_context to cldap_netlogon_send()
metze
commit 3ed85d7c69f9b68a709572ab221b9da1c17a146e
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Oct 10 15:38:22 2011 +0200
libcli/cldap: pass tevent_context to cldap_set_incoming_handler()
metze
-----------------------------------------------------------------------
Summary of changes:
libcli/cldap/cldap.c | 144 +++++++++++++++++++++--------------
libcli/cldap/cldap.h | 4 +-
source3/libads/cldap.c | 2 +-
source3/nmbd/nmbd_processlogon.c | 5 +-
source4/cldap_server/cldap_server.c | 4 +-
source4/libcli/finddcs_cldap.c | 9 +-
source4/libnet/libnet_become_dc.c | 6 +-
source4/libnet/libnet_site.c | 2 +-
source4/libnet/libnet_unbecome_dc.c | 6 +-
source4/torture/ldap/cldap.c | 8 +-
source4/torture/ldap/cldapbench.c | 9 +-
11 files changed, 116 insertions(+), 83 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/cldap/cldap.c b/libcli/cldap/cldap.c
index a5a0e41..219b343 100644
--- a/libcli/cldap/cldap.c
+++ b/libcli/cldap/cldap.c
@@ -61,15 +61,6 @@ struct cldap_socket {
*/
bool connected;
- /*
- * we allow sync requests only, if the caller
- * did not pass an event context to cldap_socket_init()
- */
- struct {
- bool allow_poll;
- struct tevent_context *ctx;
- } event;
-
/* the queue for outgoing dgrams */
struct tevent_queue *send_queue;
@@ -86,6 +77,7 @@ struct cldap_socket {
/* what to do with incoming request packets */
struct {
+ struct tevent_context *ev;
void (*handler)(struct cldap_socket *,
void *private_data,
struct cldap_incoming *);
@@ -97,6 +89,7 @@ struct cldap_search_state {
struct cldap_search_state *prev, *next;
struct {
+ struct tevent_context *ev;
struct cldap_socket *cldap;
} caller;
@@ -136,6 +129,8 @@ static void cldap_recvfrom_done(struct tevent_req *subreq);
static bool cldap_recvfrom_setup(struct cldap_socket *c)
{
+ struct tevent_context *ev;
+
if (c->recv_subreq) {
return true;
}
@@ -144,7 +139,12 @@ static bool cldap_recvfrom_setup(struct cldap_socket *c)
return true;
}
- c->recv_subreq = tdgram_recvfrom_send(c, c->event.ctx, c->sock);
+ ev = c->incoming.ev;
+ if (ev == NULL) {
+ ev = c->searches.list->caller.ev;
+ }
+
+ c->recv_subreq = tdgram_recvfrom_send(c, ev, c->sock);
if (!c->recv_subreq) {
return false;
}
@@ -304,7 +304,6 @@ done:
initialise a cldap_sock
*/
NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
const struct tsocket_address *local_addr,
const struct tsocket_address *remote_addr,
struct cldap_socket **_cldap)
@@ -319,15 +318,6 @@ NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
goto nomem;
}
- if (!ev) {
- ev = tevent_context_init(c);
- if (!ev) {
- goto nomem;
- }
- c->event.allow_poll = true;
- }
- c->event.ctx = ev;
-
if (!local_addr) {
/* we use ipv4 here instead of ip, as otherwise we end
up with a PF_INET6 socket, and sendto() for ipv4
@@ -381,6 +371,7 @@ nterror:
setup a handler for incoming requests
*/
NTSTATUS cldap_set_incoming_handler(struct cldap_socket *c,
+ struct tevent_context *ev,
void (*handler)(struct cldap_socket *,
void *private_data,
struct cldap_incoming *),
@@ -390,11 +381,7 @@ NTSTATUS cldap_set_incoming_handler(struct cldap_socket *c,
return NT_STATUS_PIPE_CONNECTED;
}
- /* if sync requests are allowed, we don't allow an incoming handler */
- if (c->event.allow_poll) {
- return NT_STATUS_INVALID_PIPE_STATE;
- }
-
+ c->incoming.ev = ev;
c->incoming.handler = handler;
c->incoming.private_data = private_data;
@@ -428,6 +415,10 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
return NT_STATUS_PIPE_CONNECTED;
}
+ if (cldap->incoming.ev == NULL) {
+ return NT_STATUS_INVALID_PIPE_STATE;
+ }
+
if (!io->dest) {
return NT_STATUS_INVALID_ADDRESS;
}
@@ -480,7 +471,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
data_blob_free(&blob2);
subreq = tdgram_sendto_queue_send(state,
- cldap->event.ctx,
+ cldap->incoming.ev,
cldap->sock,
cldap->send_queue,
state->blob.data,
@@ -533,8 +524,9 @@ static void cldap_search_state_wakeup_done(struct tevent_req *subreq);
queue a cldap reply for send
*/
struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
- struct cldap_socket *cldap,
- const struct cldap_search *io)
+ struct tevent_context *ev,
+ struct cldap_socket *cldap,
+ const struct cldap_search *io)
{
struct tevent_req *req, *subreq;
struct cldap_search_state *state = NULL;
@@ -551,6 +543,7 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
return NULL;
}
ZERO_STRUCTP(state);
+ state->caller.ev = ev;
state->req = req;
state->caller.cldap = cldap;
state->message_id = -1;
@@ -630,13 +623,13 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
state->request.delay % 1000000);
}
- if (!tevent_req_set_endtime(req, state->caller.cldap->event.ctx, end)) {
+ if (!tevent_req_set_endtime(req, state->caller.ev, end)) {
tevent_req_oom(req);
goto post;
}
subreq = tdgram_sendto_queue_send(state,
- state->caller.cldap->event.ctx,
+ state->caller.ev,
state->caller.cldap->sock,
state->caller.cldap->send_queue,
state->request.blob.data,
@@ -652,7 +645,7 @@ struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
return req;
post:
- return tevent_req_post(req, cldap->event.ctx);
+ return tevent_req_post(req, state->caller.ev);
}
static void cldap_search_state_queue_done(struct tevent_req *subreq)
@@ -692,7 +685,7 @@ static void cldap_search_state_queue_done(struct tevent_req *subreq)
next = tevent_timeval_current_ofs(state->request.delay / 1000000,
state->request.delay % 1000000);
subreq = tevent_wakeup_send(state,
- state->caller.cldap->event.ctx,
+ state->caller.ev,
next);
if (tevent_req_nomem(subreq, req)) {
return;
@@ -716,7 +709,7 @@ static void cldap_search_state_wakeup_done(struct tevent_req *subreq)
}
subreq = tdgram_sendto_queue_send(state,
- state->caller.cldap->event.ctx,
+ state->caller.ev,
state->caller.cldap->sock,
state->caller.cldap->send_queue,
state->request.blob.data,
@@ -805,29 +798,47 @@ NTSTATUS cldap_search(struct cldap_socket *cldap,
TALLOC_CTX *mem_ctx,
struct cldap_search *io)
{
+ TALLOC_CTX *frame;
struct tevent_req *req;
+ struct tevent_context *ev;
NTSTATUS status;
- if (!cldap->event.allow_poll) {
+ if (cldap->searches.list) {
+ return NT_STATUS_PIPE_BUSY;
+ }
+
+ if (cldap->incoming.handler) {
return NT_STATUS_INVALID_PIPE_STATE;
}
- if (cldap->searches.list) {
- return NT_STATUS_PIPE_BUSY;
+ frame = talloc_stackframe();
+
+ ev = tevent_context_init(frame);
+ if (ev == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
}
- req = cldap_search_send(mem_ctx, cldap, io);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ req = cldap_search_send(mem_ctx, ev, cldap, io);
+ if (req == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
- if (!tevent_req_poll(req, cldap->event.ctx)) {
- talloc_free(req);
- return NT_STATUS_INTERNAL_ERROR;
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix_common(errno);
+ TALLOC_FREE(frame);
+ return status;
}
status = cldap_search_recv(req, mem_ctx, io);
- talloc_free(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(frame);
+ return status;
+ }
- return status;
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
}
struct cldap_netlogon_state {
@@ -839,8 +850,9 @@ static void cldap_netlogon_state_done(struct tevent_req *subreq);
queue a cldap netlogon for send
*/
struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
- struct cldap_socket *cldap,
- const struct cldap_netlogon *io)
+ struct tevent_context *ev,
+ struct cldap_socket *cldap,
+ const struct cldap_netlogon *io)
{
struct tevent_req *req, *subreq;
struct cldap_netlogon_state *state;
@@ -928,7 +940,7 @@ struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
state->search.in.timeout = 2;
state->search.in.retries = 2;
- subreq = cldap_search_send(state, cldap, &state->search);
+ subreq = cldap_search_send(state, ev, cldap, &state->search);
if (tevent_req_nomem(subreq, req)) {
goto post;
}
@@ -936,7 +948,7 @@ struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
return req;
post:
- return tevent_req_post(req, cldap->event.ctx);
+ return tevent_req_post(req, ev);
}
static void cldap_netlogon_state_done(struct tevent_req *subreq)
@@ -1010,29 +1022,47 @@ NTSTATUS cldap_netlogon(struct cldap_socket *cldap,
TALLOC_CTX *mem_ctx,
struct cldap_netlogon *io)
{
+ TALLOC_CTX *frame;
struct tevent_req *req;
+ struct tevent_context *ev;
NTSTATUS status;
- if (!cldap->event.allow_poll) {
+ if (cldap->searches.list) {
+ return NT_STATUS_PIPE_BUSY;
+ }
+
+ if (cldap->incoming.handler) {
return NT_STATUS_INVALID_PIPE_STATE;
}
- if (cldap->searches.list) {
- return NT_STATUS_PIPE_BUSY;
+ frame = talloc_stackframe();
+
+ ev = tevent_context_init(frame);
+ if (ev == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
}
- req = cldap_netlogon_send(mem_ctx, cldap, io);
- NT_STATUS_HAVE_NO_MEMORY(req);
+ req = cldap_netlogon_send(mem_ctx, ev, cldap, io);
+ if (req == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
- if (!tevent_req_poll(req, cldap->event.ctx)) {
- talloc_free(req);
- return NT_STATUS_INTERNAL_ERROR;
+ if (!tevent_req_poll(req, ev)) {
+ status = map_nt_error_from_unix_common(errno);
+ TALLOC_FREE(frame);
+ return status;
}
status = cldap_netlogon_recv(req, mem_ctx, io);
- talloc_free(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(frame);
+ return status;
+ }
- return status;
+ TALLOC_FREE(frame);
+ return NT_STATUS_OK;
}
diff --git a/libcli/cldap/cldap.h b/libcli/cldap/cldap.h
index d119748..0bc9454 100644
--- a/libcli/cldap/cldap.h
+++ b/libcli/cldap/cldap.h
@@ -52,17 +52,18 @@ struct cldap_search {
};
NTSTATUS cldap_socket_init(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
const struct tsocket_address *local_addr,
const struct tsocket_address *remote_addr,
struct cldap_socket **_cldap);
NTSTATUS cldap_set_incoming_handler(struct cldap_socket *cldap,
+ struct tevent_context *ev,
void (*handler)(struct cldap_socket *,
void *private_data,
struct cldap_incoming *),
void *private_data);
struct tevent_req *cldap_search_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
struct cldap_socket *cldap,
const struct cldap_search *io);
NTSTATUS cldap_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
@@ -113,6 +114,7 @@ struct cldap_netlogon {
};
struct tevent_req *cldap_netlogon_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
struct cldap_socket *cldap,
const struct cldap_netlogon *io);
NTSTATUS cldap_netlogon_recv(struct tevent_req *req,
diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c
index 03fa17c..4f725a0 100644
--- a/source3/libads/cldap.c
+++ b/source3/libads/cldap.c
@@ -59,7 +59,7 @@ bool ads_cldap_netlogon(TALLOC_CTX *mem_ctx,
/*
* as we use a connected udp socket
*/
- status = cldap_socket_init(mem_ctx, NULL, NULL, dest_addr, &cldap);
+ status = cldap_socket_init(mem_ctx, NULL, dest_addr, &cldap);
TALLOC_FREE(dest_addr);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to create cldap socket to %s: %s\n",
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 2adc81d..43ffd72 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -120,8 +120,7 @@ bool initialize_nmbd_proxy_logon(void)
}
/* we create a connected udp socket */
- status = cldap_socket_init(ctx, nmbd_event_context(), NULL,
- server_addr, &ctx->cldap_sock);
+ status = cldap_socket_init(ctx, NULL, server_addr, &ctx->cldap_sock);
TALLOC_FREE(server_addr);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(ctx);
@@ -249,7 +248,7 @@ static void nmbd_proxy_logon(struct nmbd_proxy_logon_context *ctx,
state->io.in.version = nt_version;
state->io.in.map_response = false;
- subreq = cldap_netlogon_send(state,
+ subreq = cldap_netlogon_send(state, nmbd_event_context(),
ctx->cldap_sock,
&state->io);
if (!subreq) {
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index d3e8b7f..78712bf 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -125,7 +125,6 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, struct loadparm_
/* listen for unicasts on the CLDAP port (389) */
status = cldap_socket_init(cldapd,
- cldapd->task->event_ctx,
socket_address,
NULL,
&cldapsock);
@@ -138,7 +137,8 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, struct loadparm_
}
talloc_free(socket_address);
- cldap_set_incoming_handler(cldapsock, cldapd_request_handler, cldapd);
+ cldap_set_incoming_handler(cldapsock, cldapd->task->event_ctx,
+ cldapd_request_handler, cldapd);
return NT_STATUS_OK;
}
diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c
index 293641b..0643135 100644
--- a/source4/libcli/finddcs_cldap.c
+++ b/source4/libcli/finddcs_cldap.c
@@ -131,7 +131,7 @@ static bool finddcs_cldap_ipaddress(struct finddcs_cldap_state *state, struct fi
}
state->srv_addresses[1] = NULL;
state->srv_address_index = 0;
- status = cldap_socket_init(state, state->ev, NULL, NULL, &state->cldap);
+ status = cldap_socket_init(state, NULL, NULL, &state->cldap);
if (tevent_req_nterror(state->req, status)) {
return false;
}
@@ -234,7 +234,8 @@ static void finddcs_cldap_next_server(struct finddcs_cldap_state *state)
DEBUG(4,("finddcs: performing CLDAP query on %s\n", state->netlogon->in.dest_address));
- subreq = cldap_netlogon_send(state, state->cldap, state->netlogon);
+ subreq = cldap_netlogon_send(state, state->ev,
+ state->cldap, state->netlogon);
if (tevent_req_nomem(subreq, state->req)) {
return;
}
@@ -306,7 +307,7 @@ static void finddcs_cldap_name_resolved(struct composite_context *ctx)
state->srv_address_index = 0;
- status = cldap_socket_init(state, state->ev, NULL, NULL, &state->cldap);
+ status = cldap_socket_init(state, NULL, NULL, &state->cldap);
if (tevent_req_nterror(state->req, status)) {
return;
}
@@ -337,7 +338,7 @@ static void finddcs_cldap_srv_resolved(struct composite_context *ctx)
state->srv_address_index = 0;
- status = cldap_socket_init(state, state->ev, NULL, NULL, &state->cldap);
+ status = cldap_socket_init(state, NULL, NULL, &state->cldap);
if (tevent_req_nterror(state->req, status)) {
return;
}
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index 34ca97c..f0f57d6 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -773,11 +773,11 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s)
if (!composite_is_ok(c)) return;
}
- c->status = cldap_socket_init(s, s->libnet->event_ctx,
- NULL, dest_address, &s->cldap.sock);
+ c->status = cldap_socket_init(s, NULL, dest_address, &s->cldap.sock);
if (!composite_is_ok(c)) return;
- req = cldap_netlogon_send(s, s->cldap.sock, &s->cldap.io);
+ req = cldap_netlogon_send(s, s->libnet->event_ctx,
+ s->cldap.sock, &s->cldap.io);
if (composite_nomem(req, c)) return;
tevent_req_set_callback(req, becomeDC_recv_cldap, s);
}
diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c
index a74dd59..288e13d 100644
--- a/source4/libnet/libnet_site.c
+++ b/source4/libnet/libnet_site.c
@@ -69,7 +69,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct li
}
/* we want to use non async calls, so we're not passing an event context */
- status = cldap_socket_init(tmp_ctx, NULL, NULL, dest_address, &cldap);
+ status = cldap_socket_init(tmp_ctx, NULL, dest_address, &cldap);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
r->out.error_string = NULL;
diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c
index 85d47a9..a46d143 100644
--- a/source4/libnet/libnet_unbecome_dc.c
+++ b/source4/libnet/libnet_unbecome_dc.c
--
Samba Shared Repository
More information about the samba-cvs
mailing list