summaryrefslogtreecommitdiff
path: root/source3/rpc_server/rpc_server.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-04-25 17:24:15 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:03 +0200
commita1394fc934e91e5db31853a89e3ae9b67e5c76f6 (patch)
tree68e3fa3d44f01da1509b205358ab2024348b530e /source3/rpc_server/rpc_server.c
parentd67fc9c1ebd22dc275a790fc1e5e7a453b48ac7e (diff)
downloadsamba-a1394fc934e91e5db31853a89e3ae9b67e5c76f6.tar.gz
samba-a1394fc934e91e5db31853a89e3ae9b67e5c76f6.tar.bz2
samba-a1394fc934e91e5db31853a89e3ae9b67e5c76f6.zip
s3-rpc_server: add termination function
This way we can act when a client disconnects. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/rpc_server/rpc_server.c')
-rw-r--r--source3/rpc_server/rpc_server.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index e5e856b61f..fe78a1c629 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -281,7 +281,7 @@ static void named_pipe_listener(struct tevent_context *ev,
named_pipe_accept_function(state->ev_ctx,
state->msg_ctx,
state->ep.name,
- sd);
+ sd, NULL, 0);
}
@@ -314,13 +314,26 @@ struct named_pipe_client {
struct iovec *iov;
size_t count;
+
+ named_pipe_termination_fn *term_fn;
+ void *private_data;
};
+static int named_pipe_destructor(struct named_pipe_client *npc)
+{
+ if (npc->term_fn) {
+ npc->term_fn(npc->private_data);
+ }
+ return 0;
+}
+
static void named_pipe_accept_done(struct tevent_req *subreq);
void named_pipe_accept_function(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
- const char *pipe_name, int fd)
+ const char *pipe_name, int fd,
+ named_pipe_termination_fn *term_fn,
+ void *private_data)
{
struct named_pipe_client *npc;
struct tstream_context *plain;
@@ -343,6 +356,10 @@ void named_pipe_accept_function(struct tevent_context *ev_ctx,
}
npc->ev = ev_ctx;
npc->msg_ctx = msg_ctx;
+ npc->term_fn = term_fn;
+ npc->private_data = private_data;
+
+ talloc_set_destructor(npc, named_pipe_destructor);
/* make sure socket is in NON blocking state */
ret = set_blocking(fd, false);