1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

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>
This commit is contained in:
Volker Lendecke 2014-04-11 11:08:56 +00:00 committed by Jeremy Allison
parent 5ae7550ab4
commit 843f094628
2 changed files with 52 additions and 0 deletions

View File

@ -146,6 +146,8 @@ struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx,
int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
struct messaging_rec **presult);
bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg);
#include "librpc/gen_ndr/ndr_messaging.h"
#endif

View File

@ -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);
}
/** @} **/