1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 02:19:00 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2007-01-03 04:00:42 +08:00
|
|
|
* Copyright 1998-2007 The OpenLDAP Foundation.
|
2003-11-27 02:19:00 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2001-01-21 01:49:05 +08:00
|
|
|
*/
|
2003-11-27 02:19:00 +08:00
|
|
|
/* Portions Copyright (c) 1996 Regents of the University of Michigan.
|
1998-08-09 08:43:13 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that this notice is preserved and that due credit is given
|
|
|
|
* to the University of Michigan at Ann Arbor. The name of the University
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission. This software
|
|
|
|
* is provided ``as is'' without express or implied warranty.
|
|
|
|
*/
|
2003-11-27 02:19:00 +08:00
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was originally developed by the University of Michigan
|
|
|
|
* (as part of U-MICH LDAP).
|
|
|
|
*/
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* slurp.h - Standalone Ldap Update Replication Daemon (slurpd) */
|
|
|
|
|
|
|
|
#ifndef _SLURPD_H_
|
|
|
|
#define _SLURPD_H_
|
|
|
|
|
2002-05-16 18:51:45 +08:00
|
|
|
#if !defined(HAVE_WINSOCK) && !defined(LDAP_SYSLOG)
|
1998-12-21 05:56:44 +08:00
|
|
|
#define LDAP_SYSLOG 1
|
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#include <ac/errno.h>
|
1999-11-02 01:21:24 +08:00
|
|
|
#include <ac/param.h>
|
1998-12-22 09:34:31 +08:00
|
|
|
#include <ac/signal.h>
|
1998-12-22 09:34:01 +08:00
|
|
|
#include <ac/syslog.h>
|
1999-03-02 06:37:05 +08:00
|
|
|
#include <ac/time.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1999-03-02 06:37:05 +08:00
|
|
|
#include <sys/types.h>
|
1998-10-25 09:41:42 +08:00
|
|
|
|
1999-08-04 02:14:24 +08:00
|
|
|
#include <ldap.h>
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1999-08-08 23:18:38 +08:00
|
|
|
#undef ldap_debug
|
1998-12-22 09:34:01 +08:00
|
|
|
#define ldap_debug slurp_debug
|
1998-10-26 09:49:56 +08:00
|
|
|
#include "ldap_log.h"
|
1998-11-04 09:41:00 +08:00
|
|
|
|
1999-01-28 12:34:55 +08:00
|
|
|
#include "ldap_pvt_thread.h"
|
1999-06-17 11:54:25 +08:00
|
|
|
#include "ldap_defaults.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
#include "ldif.h"
|
|
|
|
|
2002-05-16 18:51:45 +08:00
|
|
|
#ifdef HAVE_WINSOCK
|
2003-10-13 06:00:17 +08:00
|
|
|
/* should be moved to portable.h.nt */
|
2002-05-16 18:51:45 +08:00
|
|
|
#define ftruncate(a,b) _chsize(a,b)
|
|
|
|
#define truncate(a,b) _lclose( _lcreat(a, 0))
|
2004-12-16 23:41:49 +08:00
|
|
|
#define mkdir(a,b) mkdir(a)
|
2002-05-16 18:51:45 +08:00
|
|
|
#define S_IRGRP 0
|
|
|
|
#define S_IWGRP 0
|
2006-09-14 16:06:08 +08:00
|
|
|
#ifndef F_OK
|
|
|
|
#define F_OK 0
|
|
|
|
#endif
|
|
|
|
#ifndef W_OK
|
|
|
|
#define W_OK 2
|
|
|
|
#endif
|
|
|
|
#ifndef R_OK
|
|
|
|
#define R_OK 4
|
|
|
|
#endif
|
|
|
|
#ifndef S_IRUSR
|
|
|
|
#define S_IRUSR S_IREAD
|
|
|
|
#endif
|
|
|
|
#ifndef S_IWUSR
|
|
|
|
#define S_IWUSR S_IWRITE
|
|
|
|
#endif
|
2002-05-16 18:51:45 +08:00
|
|
|
#endif
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2003-03-03 19:47:16 +08:00
|
|
|
#undef SERVICE_NAME
|
|
|
|
#define SERVICE_NAME OPENLDAP_PACKAGE "-slurpd"
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Default directory for slurpd's private copy of replication logs */
|
2000-08-10 10:52:01 +08:00
|
|
|
#define DEFAULT_SLURPD_REPLICA_DIR LDAP_RUNDIR LDAP_DIRSEP "openldap-slurp"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* Default name for slurpd's private copy of the replication log */
|
|
|
|
#define DEFAULT_SLURPD_REPLOGFILE "slurpd.replog"
|
|
|
|
|
|
|
|
/* Name of file which stores saved slurpd state info, for restarting */
|
|
|
|
#define DEFAULT_SLURPD_STATUS_FILE "slurpd.status"
|
|
|
|
|
|
|
|
/* slurpd dump file - contents of rq struct are written here (debugging) */
|
2000-08-10 10:52:01 +08:00
|
|
|
#define SLURPD_DUMPFILE LDAP_TMPDIR LDAP_DIRSEP "slurpd.dump"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* Amount of time to sleep if no more work to do */
|
|
|
|
#define DEFAULT_NO_WORK_INTERVAL 3
|
|
|
|
|
|
|
|
/* The time we wait between checks to see if the replog file needs trimming */
|
|
|
|
#define TRIMCHECK_INTERVAL ( 60 * 5 )
|
|
|
|
|
|
|
|
/* Only try to trim slurpd replica files larger than this size */
|
|
|
|
#define MIN_TRIM_FILESIZE ( 10L * 1024L )
|
|
|
|
|
|
|
|
/* Maximum line length we can read from replication log */
|
|
|
|
#define REPLBUFLEN 256
|
|
|
|
|
2000-09-16 07:41:07 +08:00
|
|
|
/* TLS flags */
|
|
|
|
#define TLS_OFF 0
|
|
|
|
#define TLS_ON 1
|
|
|
|
#define TLS_CRITICAL 2
|
|
|
|
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Rejection records are prefaced with this string */
|
|
|
|
#define ERROR_STR "ERROR"
|
|
|
|
|
|
|
|
/* Strings found in replication entries */
|
|
|
|
#define T_CHANGETYPESTR "changetype"
|
|
|
|
#define T_CHANGETYPE 1
|
|
|
|
#define T_TIMESTR "time"
|
|
|
|
#define T_TIME 2
|
|
|
|
#define T_DNSTR "dn"
|
|
|
|
#define T_DN 3
|
|
|
|
|
|
|
|
#define T_ADDCTSTR "add"
|
|
|
|
#define T_ADDCT 4
|
|
|
|
#define T_MODIFYCTSTR "modify"
|
|
|
|
#define T_MODIFYCT 5
|
|
|
|
#define T_DELETECTSTR "delete"
|
|
|
|
#define T_DELETECT 6
|
|
|
|
#define T_MODRDNCTSTR "modrdn"
|
1999-07-30 05:25:39 +08:00
|
|
|
#define T_MODDNCTSTR "moddn"
|
|
|
|
#define T_RENAMECTSTR "rename"
|
1998-08-09 08:43:13 +08:00
|
|
|
#define T_MODRDNCT 7
|
|
|
|
|
|
|
|
#define T_MODOPADDSTR "add"
|
|
|
|
#define T_MODOPADD 8
|
|
|
|
#define T_MODOPREPLACESTR "replace"
|
|
|
|
#define T_MODOPREPLACE 9
|
|
|
|
#define T_MODOPDELETESTR "delete"
|
|
|
|
#define T_MODOPDELETE 10
|
2003-08-08 00:42:40 +08:00
|
|
|
#define T_MODOPINCREMENTSTR "increment"
|
|
|
|
#define T_MODOPINCREMENT 11
|
1998-08-09 08:43:13 +08:00
|
|
|
#define T_MODSEPSTR "-"
|
2003-08-08 00:42:40 +08:00
|
|
|
#define T_MODSEP 12
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#define T_NEWRDNSTR "newrdn"
|
1999-07-30 05:25:39 +08:00
|
|
|
#define T_DELOLDRDNSTR "deleteoldrdn"
|
|
|
|
#define T_NEWSUPSTR "newsuperior"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#define T_ERR -1
|
|
|
|
|
|
|
|
/* Config file keywords */
|
|
|
|
#define HOSTSTR "host"
|
2003-06-14 08:06:36 +08:00
|
|
|
#define URISTR "uri"
|
2002-02-08 14:44:33 +08:00
|
|
|
#define ATTRSTR "attr"
|
2001-07-21 22:15:23 +08:00
|
|
|
#define SUFFIXSTR "suffix"
|
1998-08-09 08:43:13 +08:00
|
|
|
#define BINDDNSTR "binddn"
|
|
|
|
#define BINDMETHSTR "bindmethod"
|
|
|
|
#define SIMPLESTR "simple"
|
2000-08-18 00:30:37 +08:00
|
|
|
#define SASLSTR "sasl"
|
1998-08-09 08:43:13 +08:00
|
|
|
#define CREDSTR "credentials"
|
2000-08-18 00:30:37 +08:00
|
|
|
#define OLDAUTHCSTR "bindprincipal"
|
2000-09-16 07:41:07 +08:00
|
|
|
#define AUTHCSTR "authcID"
|
|
|
|
#define AUTHZSTR "authzID"
|
2000-08-18 00:30:37 +08:00
|
|
|
#define SASLMECHSTR "saslmech"
|
2000-09-16 07:41:07 +08:00
|
|
|
#define REALMSTR "realm"
|
|
|
|
#define SECPROPSSTR "secprops"
|
2003-06-11 02:32:36 +08:00
|
|
|
#define STARTTLSSTR "starttls"
|
2000-09-16 07:41:07 +08:00
|
|
|
#define TLSSTR "tls"
|
2003-06-11 02:32:36 +08:00
|
|
|
#define CRITICALSTR "critical"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#define REPLICA_SLEEP_TIME ( 10 )
|
|
|
|
|
|
|
|
/* Enumeration of various types of bind failures */
|
2000-09-16 07:41:07 +08:00
|
|
|
#define BIND_OK 0
|
|
|
|
#define BIND_ERR_BADLDP 1
|
|
|
|
#define BIND_ERR_OPEN 2
|
|
|
|
#define BIND_ERR_BAD_ATYPE 3
|
1998-08-09 08:43:13 +08:00
|
|
|
#define BIND_ERR_SIMPLE_FAILED 4
|
2000-09-16 07:41:07 +08:00
|
|
|
#define BIND_ERR_BADRI 6
|
|
|
|
#define BIND_ERR_VERSION 7
|
|
|
|
#define BIND_ERR_REFERRALS 8
|
|
|
|
#define BIND_ERR_MANAGEDSAIT 9
|
|
|
|
#define BIND_ERR_SASL_FAILED 10
|
|
|
|
#define BIND_ERR_TLS_FAILED 11
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* Return codes for do_ldap() */
|
|
|
|
#define DO_LDAP_OK 0
|
|
|
|
#define DO_LDAP_ERR_RETRYABLE 1
|
|
|
|
#define DO_LDAP_ERR_FATAL 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Types of counts one can request from the Rq rq_getcount()
|
|
|
|
* member function
|
|
|
|
*/
|
|
|
|
/* all elements */
|
|
|
|
#define RQ_COUNT_ALL 1
|
|
|
|
/* all elements with nonzero refcnt */
|
|
|
|
#define RQ_COUNT_NZRC 2
|
|
|
|
|
|
|
|
/* Amount of time, in seconds, for a thread to sleep when it encounters
|
|
|
|
* a retryable error in do_ldap().
|
|
|
|
*/
|
|
|
|
#define RETRY_SLEEP_TIME 60
|
|
|
|
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
LDAP_BEGIN_DECL
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ****************************************************************************
|
|
|
|
* Data types for replication queue and queue elements.
|
|
|
|
* ****************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Replica host information. An Ri struct will contain an array of these,
|
|
|
|
* with one entry for each replica. The end of the array is signaled
|
|
|
|
* by a NULL value in the rh_hostname field.
|
|
|
|
*/
|
|
|
|
typedef struct rh {
|
|
|
|
char *rh_hostname; /* replica hostname */
|
|
|
|
int rh_port; /* replica port */
|
|
|
|
} Rh;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-replica information.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* - Private data should not be manipulated expect by Ri member functions.
|
|
|
|
*/
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
typedef struct ri Ri;
|
|
|
|
struct ri {
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Private data */
|
|
|
|
char *ri_hostname; /* canonical hostname of replica */
|
|
|
|
int ri_port; /* port where slave slapd running */
|
2003-06-14 08:06:36 +08:00
|
|
|
char *ri_uri; /* e.g. "ldaps://ldap-1.example.com:636" */
|
1998-08-09 08:43:13 +08:00
|
|
|
LDAP *ri_ldp; /* LDAP struct for this replica */
|
2000-09-16 07:41:07 +08:00
|
|
|
int ri_tls; /* TLS: 0=no, 1=yes, 2=critical */
|
2007-01-10 07:55:13 +08:00
|
|
|
int ri_bind_method; /* AUTH_SIMPLE or AUTH_SASL */
|
1998-08-09 08:43:13 +08:00
|
|
|
char *ri_bind_dn; /* DN to bind as when replicating */
|
2000-09-16 07:41:07 +08:00
|
|
|
char *ri_password; /* Password for any method */
|
|
|
|
char *ri_secprops; /* SASL security properties */
|
|
|
|
char *ri_realm; /* realm for any mechanism */
|
2000-08-18 00:30:37 +08:00
|
|
|
char *ri_authcId; /* authentication ID for any mechanism */
|
2000-09-16 07:41:07 +08:00
|
|
|
char *ri_authzId; /* authorization ID for any mechanism */
|
2000-08-18 00:30:37 +08:00
|
|
|
char *ri_saslmech; /* SASL mechanism to use */
|
1998-08-09 08:43:13 +08:00
|
|
|
struct re *ri_curr; /* current repl entry being processed */
|
|
|
|
struct stel *ri_stel; /* pointer to Stel for this replica */
|
|
|
|
unsigned long
|
|
|
|
ri_seq; /* seq number of last repl */
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_t ri_tid; /* ID of thread for this replica */
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* Member functions */
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
int (*ri_process) LDAP_P(( Ri * )); /* process the next repl entry */
|
|
|
|
void (*ri_wake) LDAP_P(( Ri * )); /* wake up a sleeping thread */
|
|
|
|
};
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Information about one particular modification to make. This data should
|
|
|
|
* be considered private to routines in re.c, and to routines in ri.c.
|
|
|
|
*/
|
|
|
|
typedef struct mi {
|
|
|
|
/* Private data */
|
|
|
|
char *mi_type; /* attr or type */
|
|
|
|
char *mi_val; /* value */
|
|
|
|
int mi_len; /* length of mi_val */
|
|
|
|
} Mi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Information about one particular replication entry. Only routines in
|
|
|
|
* re.c and rq.c should touch the private data. Other routines should
|
|
|
|
* only use member functions.
|
|
|
|
*/
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
typedef struct re Re;
|
|
|
|
struct re {
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Private data */
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_mutex_t
|
1998-08-09 08:43:13 +08:00
|
|
|
re_mutex; /* mutex for this Re */
|
|
|
|
int re_refcnt; /* ref count, 0 = done */
|
2001-09-10 05:16:17 +08:00
|
|
|
time_t re_timestamp; /* timestamp of this re */
|
1998-08-09 08:43:13 +08:00
|
|
|
int re_seq; /* sequence number */
|
|
|
|
Rh *re_replicas; /* array of replica info */
|
|
|
|
char *re_dn; /* dn of entry being modified */
|
|
|
|
int re_changetype; /* type of modification */
|
|
|
|
Mi *re_mods; /* array of modifications to make */
|
|
|
|
struct re *re_next; /* pointer to next element */
|
|
|
|
|
|
|
|
/* Public functions */
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
int (*re_free) LDAP_P(( Re * )); /* free an re struct */
|
|
|
|
Re *(*re_getnext) LDAP_P(( Re * )); /* return next Re in linked list */
|
|
|
|
int (*re_parse) LDAP_P(( Re *, char * )); /* parse replication log entry */
|
|
|
|
int (*re_write) LDAP_P(( Ri *, Re *, FILE * )); /* write repl. log entry */
|
|
|
|
void (*re_dump) LDAP_P(( Re *, FILE * )); /* debugging - print contents */
|
|
|
|
int (*re_lock) LDAP_P(( Re * )); /* lock this re */
|
|
|
|
int (*re_unlock) LDAP_P(( Re * )); /* unlock this re */
|
|
|
|
int (*re_decrefcnt) LDAP_P(( Re * )); /* decrement the refcnt */
|
|
|
|
int (*re_getrefcnt) LDAP_P(( Re * )); /* get the refcnt */
|
|
|
|
};
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Definition for the queue of replica information. Private data is
|
|
|
|
* private to rq.c. Other routines should only touch public data or
|
|
|
|
* use member functions. Note that although we have a member function
|
|
|
|
* for locking the queue's mutex, we need to expose the rq_mutex
|
|
|
|
* variable so routines in ri.c can use it as a mutex for the
|
|
|
|
* rq_more condition variable.
|
|
|
|
*/
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
typedef struct rq Rq;
|
|
|
|
struct rq {
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/* Private data */
|
|
|
|
Re *rq_head; /* pointer to head */
|
|
|
|
Re *rq_tail; /* pointer to tail */
|
|
|
|
int rq_nre; /* total number of Re's in queue */
|
|
|
|
int rq_ndel; /* number of deleted Re's in queue */
|
|
|
|
time_t rq_lasttrim; /* Last time we trimmed file */
|
|
|
|
|
|
|
|
/* Public data */
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_mutex_t
|
1998-08-09 08:43:13 +08:00
|
|
|
rq_mutex; /* mutex for whole queue */
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_cond_t
|
1998-08-09 08:43:13 +08:00
|
|
|
rq_more; /* condition var - more work added */
|
|
|
|
|
|
|
|
/* Member functions */
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
Re * (*rq_gethead) LDAP_P(( Rq * )); /* get the element at head */
|
|
|
|
Re * (*rq_getnext) LDAP_P(( Re * )); /* get the next element */
|
|
|
|
int (*rq_delhead) LDAP_P(( Rq * )); /* delete the element at head */
|
|
|
|
int (*rq_add) LDAP_P(( Rq *, char * )); /* add at tail */
|
|
|
|
void (*rq_gc) LDAP_P(( Rq * )); /* garbage-collect queue */
|
|
|
|
int (*rq_lock) LDAP_P(( Rq * )); /* lock the queue */
|
|
|
|
int (*rq_unlock) LDAP_P(( Rq * )); /* unlock the queue */
|
|
|
|
int (*rq_needtrim) LDAP_P(( Rq * )); /* see if queue needs trimming */
|
|
|
|
int (*rq_write) LDAP_P(( Rq *, FILE * )); /*write Rq contents to file*/
|
|
|
|
int (*rq_getcount) LDAP_P(( Rq *, int )); /* return queue counts */
|
|
|
|
void (*rq_dump) LDAP_P(( Rq * )); /* debugging - print contents */
|
|
|
|
};
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An Stel (status element) contains information about one replica.
|
|
|
|
* Stel structs are associated with the St (status) struct, defined
|
|
|
|
* below.
|
|
|
|
*/
|
|
|
|
typedef struct stel {
|
|
|
|
char *hostname; /* host name of replica */
|
|
|
|
int port; /* port number of replica */
|
2001-09-10 05:16:17 +08:00
|
|
|
time_t last; /* timestamp of last successful repl */
|
1998-08-09 08:43:13 +08:00
|
|
|
int seq; /* Sequence number of last repl */
|
|
|
|
} Stel;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An St struct in an in-core structure which contains the current
|
|
|
|
* slurpd state. Most importantly, it contains an array of Stel
|
|
|
|
* structs which contain the timestamp and sequence number of the last
|
|
|
|
* successful replication for each replica. The st_write() member
|
|
|
|
* function is called periodically to flush status information to
|
|
|
|
* disk. At startup time, slurpd checks for the status file, and
|
|
|
|
* if present, uses the timestamps to avoid "replaying" replications
|
|
|
|
* which have already been sent to a given replica.
|
|
|
|
*/
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
typedef struct st St;
|
|
|
|
struct st {
|
1998-08-09 08:43:13 +08:00
|
|
|
/* Private data */
|
1999-01-28 12:34:55 +08:00
|
|
|
ldap_pvt_thread_mutex_t
|
1998-08-09 08:43:13 +08:00
|
|
|
st_mutex; /* mutex to serialize access */
|
|
|
|
Stel **st_data; /* array of pointers to Stel structs */
|
|
|
|
int st_nreplicas; /* number of repl hosts */
|
|
|
|
int st_err_logged; /* 1 if fopen err logged */
|
|
|
|
FILE *st_fp; /* st file kept open */
|
|
|
|
FILE *st_lfp; /* lockfile fp */
|
|
|
|
|
|
|
|
/* Public member functions */
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
int (*st_update) LDAP_P(( St *, Stel*, Re* ));/*update entry for a host*/
|
|
|
|
Stel*(*st_add) LDAP_P(( St *, Ri * )); /*add a new repl host*/
|
|
|
|
int (*st_write) LDAP_P(( St * )); /* write status to disk */
|
|
|
|
int (*st_read) LDAP_P(( St * )); /* read status info from disk */
|
|
|
|
int (*st_lock) LDAP_P(( St * )); /* read status info from disk */
|
|
|
|
int (*st_unlock) LDAP_P(( St * )); /* read status info from disk */
|
|
|
|
};
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
#if defined( HAVE_LWP )
|
1998-08-09 08:43:13 +08:00
|
|
|
typedef struct tl {
|
|
|
|
thread_t tl_tid; /* thread being managed */
|
|
|
|
time_t tl_wake; /* time thread should be resumed */
|
|
|
|
struct tl *tl_next; /* next node in list */
|
|
|
|
} tl_t;
|
|
|
|
|
|
|
|
typedef struct tsl {
|
|
|
|
tl_t *tsl_list;
|
|
|
|
mon_t tsl_mon;
|
|
|
|
} tsl_t;
|
1998-10-25 09:41:42 +08:00
|
|
|
#endif /* HAVE_LWP */
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Public functions used to instantiate and initialize queue objects.
|
|
|
|
*/
|
1998-10-25 09:41:42 +08:00
|
|
|
extern int Ri_init LDAP_P(( Ri **ri ));
|
|
|
|
extern int Rq_init LDAP_P(( Rq **rq ));
|
|
|
|
extern int Re_init LDAP_P(( Re **re ));
|
|
|
|
|
Protoized, moved extern definitions to .h files, fixed related bugs.
Most function and variable definitions are now preceded by its extern
definition, for error checking. Retyped a number of functions, usually
to return void. Fixed a number of printf format errors.
API changes (in ldap/include):
Added avl_dup_ok, avl_prefixapply, removed ber_fatten (probably typo
for ber_flatten), retyped ldap_sort_strcasecmp, grew lutil.h.
A number of `extern' declarations are left (some added by protoize), to
be cleaned away later. Mostly strdup(), strcasecmp(), mktemp(), optind,
optarg, errno.
1998-11-16 06:40:11 +08:00
|
|
|
#include "proto-slurp.h"
|
|
|
|
|
1998-10-25 09:41:42 +08:00
|
|
|
LDAP_END_DECL
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#endif /* _SLURPD_H_ */
|