diff options
author | Volker Lendecke <vl@samba.org> | 2014-04-11 11:08:56 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-04-23 22:33:09 +0200 |
commit | 843f0946289343b6fcc6f41ad5ff5bd090a9399b (patch) | |
tree | cad18be6e19e62cc5eceef79f966e89cf553f460 /source3/lib | |
parent | 5ae7550ab41ac25e081f5b616865222e7e5558ae (diff) | |
download | samba-843f0946289343b6fcc6f41ad5ff5bd090a9399b.tar.gz samba-843f0946289343b6fcc6f41ad5ff5bd090a9399b.tar.xz samba-843f0946289343b6fcc6f41ad5ff5bd090a9399b.zip |
s3: messaging: Add infrastructure to clean up orphaned sockets every 15 minutes as a background task.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/messages.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index b4ed80754bd..b6fe4237bac 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -50,6 +50,7 @@ #include "serverid.h" #include "messages.h" #include "lib/util/tevent_unix.h" +#include "lib/background.h" struct messaging_callback { struct messaging_callback *prev, *next; @@ -586,4 +587,53 @@ void messaging_dispatch_rec(struct messaging_context *msg_ctx, return; } +static int mess_parent_dgm_cleanup(void *private_data); +static void mess_parent_dgm_cleanup_done(struct tevent_req *req); + +bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg) +{ + struct tevent_req *req; + + req = background_job_send( + msg, msg->event_ctx, msg, NULL, 0, + lp_parm_int(-1, "messaging", "messaging dgm cleanup interval", 60*15), + mess_parent_dgm_cleanup, msg); + if (req == NULL) { + return false; + } + tevent_req_set_callback(req, mess_parent_dgm_cleanup_done, msg); + return true; +} + +static int mess_parent_dgm_cleanup(void *private_data) +{ + struct messaging_context *msg_ctx = talloc_get_type_abort( + private_data, struct messaging_context); + NTSTATUS status; + + status = messaging_dgm_wipe(msg_ctx); + DEBUG(10, ("messaging_dgm_wipe returned %s\n", nt_errstr(status))); + return lp_parm_int(-1, "messaging", "messaging dgm cleanup interval", 60*15); +} + +static void mess_parent_dgm_cleanup_done(struct tevent_req *req) +{ + struct messaging_context *msg = tevent_req_callback_data( + req, struct messaging_context); + NTSTATUS status; + + status = background_job_recv(req); + TALLOC_FREE(req); + DEBUG(1, ("messaging dgm cleanup job ended with %s\n", nt_errstr(status))); + + req = background_job_send( + msg, msg->event_ctx, msg, NULL, 0, + lp_parm_int(-1, "messaging", "messaging dgm cleanup interval", 60*15), + mess_parent_dgm_cleanup, msg); + if (req == NULL) { + DEBUG(1, ("background_job_send failed\n")); + } + tevent_req_set_callback(req, mess_parent_dgm_cleanup_done, msg); +} + /** @} **/ |