The branch, master has been updated via 68d79eb s3-rpc_server: Fix sending of packets over named pipe proxy. via dd3a927 s3-smbd: Pass tevent context to smbd_server_connection_loop_once(). via bc3fae7 s3-rpc_server: Free the children of p->mem_ctx. from 020032e s3:lib/events: Fix a bug in run_poll_events().
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 68d79eb6efb32eb3bc416ffc3430f0e4b1eed691 Author: Andreas Schneider <a...@samba.org> Date: Wed Aug 3 23:44:21 2011 +0200 s3-rpc_server: Fix sending of packets over named pipe proxy. We need for named pipes we need to send each fragment on its own to be a message. Signed-off-by: Simo Sorce <i...@samba.org> Autobuild-User: Andreas Schneider <a...@cryptomilk.org> Autobuild-Date: Tue Aug 9 11:55:18 CEST 2011 on sn-devel-104 commit dd3a92795908e8e9e5456f985e17313b2a59a8cc Author: Andreas Schneider <a...@samba.org> Date: Mon Aug 8 18:39:56 2011 +0200 s3-smbd: Pass tevent context to smbd_server_connection_loop_once(). Signed-off-by: Simo Sorce <i...@samba.org> commit bc3fae70a27ced752844513996f29d0116a20079 Author: Andreas Schneider <a...@samba.org> Date: Tue Jul 26 12:07:20 2011 +0200 s3-rpc_server: Free the children of p->mem_ctx. Free the children of p->mem_ctx after processing a complete incoming and outgoing request. Signed-off-by: Simo Sorce <i...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/rpc_server/rpc_server.c | 55 ++++++++++++++++++++++---------------- source3/smbd/process.c | 24 ++++++++-------- source3/smbd/proto.h | 3 +- source3/smbd/server.c | 6 ++-- 4 files changed, 49 insertions(+), 39 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c index b03715c..9134b95 100644 --- a/source3/rpc_server/rpc_server.c +++ b/source3/rpc_server/rpc_server.c @@ -320,7 +320,7 @@ static void named_pipe_accept_function(struct tevent_context *ev_ctx, struct tevent_req *subreq; int ret; - npc = talloc_zero(NULL, struct named_pipe_client); + npc = talloc_zero(ev_ctx, struct named_pipe_client); if (!npc) { DEBUG(0, ("Out of memory!\n")); close(fd); @@ -446,6 +446,7 @@ static void named_pipe_packet_process(struct tevent_req *subreq) ssize_t data_used; char *data; uint32_t to_send; + size_t i; bool ok; status = dcerpc_read_ncacn_packet_recv(subreq, npc, &pkt, &recv_buffer); @@ -479,13 +480,6 @@ static void named_pipe_packet_process(struct tevent_req *subreq) to_send = out->frag.length - out->current_pdu_sent; if (to_send > 0) { - DEBUG(10, ("Current_pdu_len = %u, " - "current_pdu_sent = %u " - "Returning %u bytes\n", - (unsigned int)out->frag.length, - (unsigned int)out->current_pdu_sent, - (unsigned int)to_send)); - npc->iov = talloc_zero(npc, struct iovec); if (!npc->iov) { status = NT_STATUS_NO_MEMORY; @@ -522,11 +516,6 @@ static void named_pipe_packet_process(struct tevent_req *subreq) npc->iov[npc->count].iov_base = out->frag.data; npc->iov[npc->count].iov_len = out->frag.length; - DEBUG(10, ("PDU number: %d, PDU Length: %u\n", - (unsigned int)npc->count, - (unsigned int)npc->iov[npc->count].iov_len)); - dump_data(11, (const uint8_t *)npc->iov[npc->count].iov_base, - npc->iov[npc->count].iov_len); npc->count++; } @@ -544,19 +533,31 @@ static void named_pipe_packet_process(struct tevent_req *subreq) return; } - DEBUG(10, ("Sending a total of %u bytes\n", + DEBUG(10, ("Sending %u fragments in a total of %u bytes\n", + (unsigned int)npc->count, (unsigned int)npc->p->out_data.data_sent_length)); - subreq = tstream_writev_queue_send(npc, npc->ev, - npc->tstream, - npc->write_queue, - npc->iov, npc->count); - if (!subreq) { - DEBUG(2, ("Failed to send packet\n")); - status = NT_STATUS_NO_MEMORY; - goto fail; + for (i = 0; i < npc->count; i++) { + DEBUG(10, ("Sending PDU number: %d, PDU Length: %u\n", + (unsigned int)i, + (unsigned int)npc->iov[i].iov_len)); + dump_data(11, (const uint8_t *)npc->iov[i].iov_base, + npc->iov[i].iov_len); + + subreq = tstream_writev_queue_send(npc, + npc->ev, + npc->tstream, + npc->write_queue, + (npc->iov + i), + 1); + if (!subreq) { + DEBUG(2, ("Failed to send packet\n")); + status = NT_STATUS_NO_MEMORY; + goto fail; + } + tevent_req_set_callback(subreq, named_pipe_packet_done, npc); } - tevent_req_set_callback(subreq, named_pipe_packet_done, npc); + return; fail: @@ -582,6 +583,10 @@ static void named_pipe_packet_done(struct tevent_req *subreq) goto fail; } + if (tevent_queue_length(npc->write_queue) > 0) { + return; + } + /* clear out any data that may have been left around */ npc->count = 0; TALLOC_FREE(npc->iov); @@ -589,6 +594,8 @@ static void named_pipe_packet_done(struct tevent_req *subreq) data_blob_free(&npc->p->out_data.frag); data_blob_free(&npc->p->out_data.rdata); + talloc_free_children(npc->p->mem_ctx); + /* Wait for the next packet */ subreq = dcerpc_read_ncacn_packet_send(npc, npc->ev, npc->tstream); if (!subreq) { @@ -1287,6 +1294,8 @@ static void dcerpc_ncacn_packet_done(struct tevent_req *subreq) data_blob_free(&ncacn_conn->p->out_data.frag); data_blob_free(&ncacn_conn->p->out_data.rdata); + talloc_free_children(ncacn_conn->p->mem_ctx); + /* Wait for the next packet */ subreq = dcerpc_read_ncacn_packet_send(ncacn_conn, ncacn_conn->ev_ctx, diff --git a/source3/smbd/process.c b/source3/smbd/process.c index b105de7..fc6112c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -903,7 +903,8 @@ void smbd_setup_sig_hup_handler(struct tevent_context *ev, } } -static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn) +static NTSTATUS smbd_server_connection_loop_once(struct tevent_context *ev_ctx, + struct smbd_server_connection *conn) { int timeout; int num_pfds = 0; @@ -917,11 +918,10 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * * select for longer than it would take to wait for them. */ - event_add_to_poll_args(server_event_context(), conn, - &conn->pfds, &num_pfds, &timeout); + event_add_to_poll_args(ev_ctx, conn, &conn->pfds, &num_pfds, &timeout); /* Process a signal and timed events now... */ - if (run_events_poll(server_event_context(), 0, NULL, 0)) { + if (run_events_poll(ev_ctx, 0, NULL, 0)) { return NT_STATUS_RETRY; } @@ -943,8 +943,7 @@ static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection * return map_nt_error_from_unix(errno); } - retry = run_events_poll(server_event_context(), ret, conn->pfds, - num_pfds); + retry = run_events_poll(ev_ctx, ret, conn->pfds, num_pfds); if (retry) { return NT_STATUS_RETRY; } @@ -2960,7 +2959,8 @@ static NTSTATUS smbd_register_ips(struct smbd_server_connection *sconn, Process commands from the client ****************************************************************************/ -void smbd_process(struct smbd_server_connection *sconn) +void smbd_process(struct tevent_context *ev_ctx, + struct smbd_server_connection *sconn) { TALLOC_CTX *frame = talloc_stackframe(); struct sockaddr_storage ss; @@ -3128,7 +3128,7 @@ void smbd_process(struct smbd_server_connection *sconn) MSG_DEBUG, debug_message); if ((lp_keepalive() != 0) - && !(event_add_idle(server_event_context(), NULL, + && !(event_add_idle(ev_ctx, NULL, timeval_set(lp_keepalive(), 0), "keepalive", keepalive_fn, NULL))) { @@ -3136,14 +3136,14 @@ void smbd_process(struct smbd_server_connection *sconn) exit(1); } - if (!(event_add_idle(server_event_context(), NULL, + if (!(event_add_idle(ev_ctx, NULL, timeval_set(IDLE_CLOSED_TIMEOUT, 0), "deadtime", deadtime_fn, sconn))) { DEBUG(0, ("Could not add deadtime event\n")); exit(1); } - if (!(event_add_idle(server_event_context(), NULL, + if (!(event_add_idle(ev_ctx, NULL, timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0), "housekeeping", housekeeping_fn, sconn))) { DEBUG(0, ("Could not add housekeeping event\n")); @@ -3200,7 +3200,7 @@ void smbd_process(struct smbd_server_connection *sconn) exit_server("init_dptrs() failed"); } - sconn->smb1.fde = event_add_fd(server_event_context(), + sconn->smb1.fde = event_add_fd(ev_ctx, sconn, sconn->sock, EVENT_FD_READ, @@ -3219,7 +3219,7 @@ void smbd_process(struct smbd_server_connection *sconn) errno = 0; - status = smbd_server_connection_loop_once(sconn); + status = smbd_server_connection_loop_once(ev_ctx, sconn); if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY) && !NT_STATUS_IS_OK(status)) { DEBUG(3, ("smbd_server_connection_loop_once failed: %s," diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 92a1d38..d140813 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -793,7 +793,8 @@ void construct_reply_common_req(struct smb_request *req, char *outbuf); size_t req_wct_ofs(struct smb_request *req); void chain_reply(struct smb_request *req); bool req_is_in_chain(struct smb_request *req); -void smbd_process(struct smbd_server_connection *sconn); +void smbd_process(struct tevent_context *ev_ctx, + struct smbd_server_connection *sconn); bool fork_echo_handler(struct smbd_server_connection *sconn); /* The following definitions come from smbd/quotas.c */ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 8aa4f5f..9e17e07 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -393,7 +393,7 @@ static void smbd_accept_connection(struct tevent_context *ev, } if (s->parent->interactive) { - smbd_process(sconn); + smbd_process(ev, sconn); exit_server_cleanly("end of interactive mode"); return; } @@ -472,7 +472,7 @@ static void smbd_accept_connection(struct tevent_context *ev, "serverid.tdb"); } - smbd_process(smbd_server_conn); + smbd_process(ev, smbd_server_conn); exit: exit_server_cleanly("end of child"); return; @@ -1259,7 +1259,7 @@ extern void build_options(bool screen); /* Stop zombies */ smbd_setup_sig_chld_handler(ev_ctx); - smbd_process(smbd_server_conn); + smbd_process(ev_ctx, smbd_server_conn); exit_server_cleanly(NULL); return(0); -- Samba Shared Repository