summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-14 10:56:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:22 -0500
commit39f914d4e70356bdad9fcdbca379565c9a608988 (patch)
treedbe9494f29cef51e88692645e716c91e5d0dd64f /source4
parent2e51b42c2c4b543437fd7b9f7bc93380f7e2cf4e (diff)
downloadsamba-39f914d4e70356bdad9fcdbca379565c9a608988.tar.gz
samba-39f914d4e70356bdad9fcdbca379565c9a608988.tar.bz2
samba-39f914d4e70356bdad9fcdbca379565c9a608988.zip
r12230: prepare for a generic periodic processing scheduling of
pull,push,scavenging and reread-config events metze (This used to be commit 977117278c4b9fc1b7845b6aa6d5862e5a776651)
Diffstat (limited to 'source4')
-rw-r--r--source4/wrepl_server/config.mk3
-rw-r--r--source4/wrepl_server/wrepl_periodic.c82
-rw-r--r--source4/wrepl_server/wrepl_server.c12
-rw-r--r--source4/wrepl_server/wrepl_server.h18
4 files changed, 111 insertions, 4 deletions
diff --git a/source4/wrepl_server/config.mk b/source4/wrepl_server/config.mk
index cc4621ba45..6a6ce7185a 100644
--- a/source4/wrepl_server/config.mk
+++ b/source4/wrepl_server/config.mk
@@ -9,7 +9,8 @@ INIT_OBJ_FILES = \
wrepl_in_call.o \
wrepl_out_connection.o \
wrepl_out_helpers.o \
- wrepl_apply_records.o
+ wrepl_apply_records.o \
+ wrepl_periodic.o
REQUIRED_SUBSYSTEMS = \
LIBCLI_WREPL WINSDB
# End SUBSYSTEM WREPL_SRV
diff --git a/source4/wrepl_server/wrepl_periodic.c b/source4/wrepl_server/wrepl_periodic.c
new file mode 100644
index 0000000000..4ba047d3a0
--- /dev/null
+++ b/source4/wrepl_server/wrepl_periodic.c
@@ -0,0 +1,82 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ WINS Replication server
+
+ Copyright (C) Stefan Metzmacher 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "dlinklist.h"
+#include "lib/events/events.h"
+#include "lib/socket/socket.h"
+#include "smbd/service_task.h"
+#include "smbd/service_stream.h"
+#include "lib/messaging/irpc.h"
+#include "librpc/gen_ndr/ndr_winsrepl.h"
+#include "wrepl_server/wrepl_server.h"
+#include "nbt_server/wins/winsdb.h"
+#include "ldb/include/ldb.h"
+#include "libcli/composite/composite.h"
+#include "libcli/wrepl/winsrepl.h"
+#include "wrepl_server/wrepl_out_helpers.h"
+
+static uint32_t wreplsrv_periodic_run(struct wreplsrv_service *service, uint32_t next_interval)
+{
+ DEBUG(2,("wreplsrv_periodic_run: next in %u secs\n", next_interval));
+ return next_interval;
+}
+
+static void wreplsrv_periodic_handler_te(struct event_context *ev, struct timed_event *te,
+ struct timeval t, void *ptr)
+{
+ struct wreplsrv_service *service = talloc_get_type(ptr, struct wreplsrv_service);
+ uint32_t next_interval;
+
+ service->periodic.te = NULL;
+
+ next_interval = wreplsrv_periodic_run(service, service->config.periodic_interval);
+
+ service->periodic.next_event = timeval_current_ofs(next_interval, 0);
+ service->periodic.te = event_add_timed(service->task->event_ctx, service,
+ service->periodic.next_event,
+ wreplsrv_periodic_handler_te, service);
+ if (!service->periodic.te) {
+ task_server_terminate(service->task,"event_add_timed() failed! no memory!\n");
+ return;
+ }
+}
+
+NTSTATUS wreplsrv_setup_periodic(struct wreplsrv_service *service)
+{
+ NTSTATUS status;
+
+ /*
+ * TODO: this should go away, and we should do everything
+ * within the wreplsrv_periodic_run()
+ */
+ status = wreplsrv_setup_out_connections(service);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ service->periodic.next_event = timeval_current();
+ service->periodic.te = event_add_timed(service->task->event_ctx, service,
+ service->periodic.next_event,
+ wreplsrv_periodic_handler_te, service);
+ NT_STATUS_HAVE_NO_MEMORY(service->periodic.te);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c
index effd547260..5a7ad57f86 100644
--- a/source4/wrepl_server/wrepl_server.c
+++ b/source4/wrepl_server/wrepl_server.c
@@ -55,6 +55,9 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service)
/* the default verify interval is 24 days */
service->config.verify_interval = lp_parm_int(-1,"wreplsrv","verify_interval", 24*24*60*60);
+ /* the maximun interval to the next periodic processing event */
+ service->config.periodic_interval = lp_parm_int(-1,"wreplsrv","periodic_interval", 60);
+
return NT_STATUS_OK;
}
@@ -333,9 +336,6 @@ static NTSTATUS wreplsrv_setup_partners(struct wreplsrv_service *service)
status = wreplsrv_load_table(service);
NT_STATUS_NOT_OK_RETURN(status);
- status = wreplsrv_setup_out_connections(service);
- NT_STATUS_NOT_OK_RETURN(status);
-
return NT_STATUS_OK;
}
@@ -383,6 +383,12 @@ static void wreplsrv_task_init(struct task_server *task)
return;
}
+ status = wreplsrv_setup_periodic(service);
+ if (!NT_STATUS_IS_OK(status)) {
+ task_server_terminate(task, "wreplsrv_task_init: wreplsrv_setup_periodic() failed");
+ return;
+ }
+
irpc_add_name(task->msg_ctx, "wrepl_server");
}
diff --git a/source4/wrepl_server/wrepl_server.h b/source4/wrepl_server/wrepl_server.h
index 118686622e..0e0ed35e94 100644
--- a/source4/wrepl_server/wrepl_server.h
+++ b/source4/wrepl_server/wrepl_server.h
@@ -232,6 +232,12 @@ struct wreplsrv_service {
* with the owning wins server
*/
uint32_t verify_interval;
+
+ /*
+ * the interval (in secs) to the next periodic processing
+ * (this is the maximun interval)
+ */
+ uint32_t periodic_interval;
} config;
/* all incoming connections */
@@ -242,4 +248,16 @@ struct wreplsrv_service {
/* this is a list of each wins_owner we know about in our database */
struct wreplsrv_owner *table;
+
+ /* some stuff for periodic processing */
+ struct {
+ /*
+ * the timestamp for the current or next event,
+ * this is the timstamp passed to event_add_timed()
+ */
+ struct timeval next_event;
+
+ /* here we have a reference to the timed event the schedules the periodic stuff */
+ struct timed_event *te;
+ } periodic;
};