svn commit: samba r12230 - in branches/SAMBA_4_0/source/wrepl_server: .

metze at samba.org metze at samba.org
Wed Dec 14 10:56:43 GMT 2005


Author: metze
Date: 2005-12-14 10:56:43 +0000 (Wed, 14 Dec 2005)
New Revision: 12230

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12230

Log:
prepare for a generic periodic processing scheduling of
pull,push,scavenging and reread-config events

metze
Added:
   branches/SAMBA_4_0/source/wrepl_server/wrepl_periodic.c
Modified:
   branches/SAMBA_4_0/source/wrepl_server/config.mk
   branches/SAMBA_4_0/source/wrepl_server/wrepl_server.c
   branches/SAMBA_4_0/source/wrepl_server/wrepl_server.h


Changeset:
Modified: branches/SAMBA_4_0/source/wrepl_server/config.mk
===================================================================
--- branches/SAMBA_4_0/source/wrepl_server/config.mk	2005-12-14 08:46:52 UTC (rev 12229)
+++ branches/SAMBA_4_0/source/wrepl_server/config.mk	2005-12-14 10:56:43 UTC (rev 12230)
@@ -9,7 +9,8 @@
 		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

Added: branches/SAMBA_4_0/source/wrepl_server/wrepl_periodic.c
===================================================================
--- branches/SAMBA_4_0/source/wrepl_server/wrepl_periodic.c	2005-12-14 08:46:52 UTC (rev 12229)
+++ branches/SAMBA_4_0/source/wrepl_server/wrepl_periodic.c	2005-12-14 10:56:43 UTC (rev 12230)
@@ -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;
+}

Modified: branches/SAMBA_4_0/source/wrepl_server/wrepl_server.c
===================================================================
--- branches/SAMBA_4_0/source/wrepl_server/wrepl_server.c	2005-12-14 08:46:52 UTC (rev 12229)
+++ branches/SAMBA_4_0/source/wrepl_server/wrepl_server.c	2005-12-14 10:56:43 UTC (rev 12230)
@@ -55,6 +55,9 @@
 	/* 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 @@
 	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 @@
 		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");
 }
 

Modified: branches/SAMBA_4_0/source/wrepl_server/wrepl_server.h
===================================================================
--- branches/SAMBA_4_0/source/wrepl_server/wrepl_server.h	2005-12-14 08:46:52 UTC (rev 12229)
+++ branches/SAMBA_4_0/source/wrepl_server/wrepl_server.h	2005-12-14 10:56:43 UTC (rev 12230)
@@ -232,6 +232,12 @@
 		 * 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 @@
 
 	/* 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;
 };



More information about the samba-cvs mailing list