Commit 08676eb4 authored by Howard Chu's avatar Howard Chu
Browse files

Add support for outbound connections in main listener.

Restructure syncrepl/persist to use outbound connection manager.
parent 645c2bcb
......@@ -2797,12 +2797,14 @@ add_syncrepl(
si->si_attrs[0] = NULL;
si->si_type = LDAP_SYNC_REFRESH_ONLY;
si->si_interval = 86400;
si->si_syncCookie = NULL;
si->si_syncCookie.bv_val = NULL;
si->si_syncCookie.bv_len = 0;
si->si_manageDSAit = 0;
si->si_tlimit = -1;
si->si_slimit = -1;
si->si_syncUUID = NULL;
si->si_syncUUID_ndn = NULL;
si->si_syncUUID_ndn.bv_val = NULL;
si->si_syncUUID_ndn.bv_len = 0;
si->si_sync_mode = LDAP_SYNC_STATE_MODE;
si->si_presentlist = NULL;
......@@ -3084,7 +3086,7 @@ parse_syncrepl_line(
COOKIESTR, sizeof( COOKIESTR ) - 1 ) )
{
val = cargv[ i ] + sizeof( COOKIESTR );
si->si_syncCookie = ber_str2bv( val, strlen( val ), 1, NULL );
ber_str2bv( val, 0, 1, &si->si_syncCookie );
} else if ( !strncasecmp( cargv[ i ],
MANAGEDSAITSTR, sizeof( MANAGEDSAITSTR ) - 1 ) )
{
......
......@@ -169,6 +169,12 @@ int connections_shutdown(void)
if( connections[i].c_struct_state != SLAP_C_USED ) {
continue;
}
/* give persistent clients a chance to cleanup */
if( connections[i].c_conn_state == SLAP_C_CLIENT ) {
ldap_pvt_thread_pool_submit( &connection_pool,
connections[i].c_clientfunc, connections[i].c_clientarg );
continue;
}
ldap_pvt_thread_mutex_lock( &connections[i].c_mutex );
......@@ -294,6 +300,7 @@ static Connection* connection_get( ber_socket_t s )
ldap_pvt_thread_mutex_unlock( &c->c_mutex );
return NULL;
}
if( c->c_conn_state == SLAP_C_CLIENT ) sd = 0;
#ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, RESULTS,
......@@ -332,7 +339,7 @@ long connection_init(
Listener *listener,
const char* dnsname,
const char* peername,
int tls_udp_option,
int flags,
slap_ssf_t ssf,
const char *authid )
{
......@@ -346,7 +353,7 @@ long connection_init(
assert( peername != NULL );
#ifndef HAVE_TLS
assert( tls_udp_option != 1 );
assert( flags != CONN_IS_TLS );
#endif
if( s == AC_SOCKET_INVALID ) {
......@@ -495,6 +502,16 @@ long connection_init(
assert( c->c_currentber == NULL );
c->c_listener = listener;
if ( flags == CONN_IS_CLIENT ) {
c->c_conn_state = SLAP_C_CLIENT;
c->c_struct_state = SLAP_C_USED;
ldap_pvt_thread_mutex_unlock( &c->c_mutex );
ldap_pvt_thread_mutex_unlock( &connections_mutex );
return 0;
}
ber_str2bv( dnsname, 0, 1, &c->c_peer_domain );
ber_str2bv( peername, 0, 1, &c->c_peer_name );
......@@ -520,7 +537,7 @@ long connection_init(
#ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0;
if( tls_udp_option == 2 ) {
if( flags == CONN_IS_UDP ) {
c->c_is_udp = 1;
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
......@@ -569,7 +586,7 @@ long connection_init(
c->c_tls_ssf = 0;
#ifdef HAVE_TLS
if ( tls_udp_option == 1 ) {
if ( flags == CONN_IS_TLS ) {
c->c_is_tls = 1;
c->c_needs_tls_accept = 1;
} else {
......@@ -1118,6 +1135,51 @@ no_co_op_free:
return NULL;
}
int connection_client_setup(
ber_socket_t s,
Listener *l,
ldap_pvt_thread_start_t *func,
void *arg )
{
Connection *c;
if ( connection_init( s, l, "", "", CONN_IS_CLIENT, 0, "" ) < 0 ) {
return -1;
}
c = connection_get( s );
c->c_clientfunc = func;
c->c_clientarg = arg;
connection_return( c );
slapd_add_internal( s );
slapd_set_read( s, 1 );
return 0;
}
void connection_client_enable(
ber_socket_t s
)
{
slapd_set_read( s, 1 );
}
void connection_client_stop(
ber_socket_t s
)
{
Connection *c;
/* get (locked) connection */
c = connection_get( s );
assert( c->c_conn_state == SLAP_C_CLIENT );
c->c_listener = NULL;
c->c_conn_state = SLAP_C_INVALID;
c->c_struct_state = SLAP_C_UNUSED;
connection_return( c );
}
int connection_read(ber_socket_t s)
{
int rc = 0;
......@@ -1162,6 +1224,15 @@ int connection_read(ber_socket_t s)
return 0;
}
if ( c->c_conn_state == SLAP_C_CLIENT ) {
slapd_clr_read( s, 0 );
ldap_pvt_thread_pool_submit( &connection_pool,
c->c_clientfunc, c->c_clientarg );
connection_return( c );
ldap_pvt_thread_mutex_unlock( &connections_mutex );
return 0;
}
#ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, DETAIL1,
"connection_read: conn %lu checking for input.\n",
......
......@@ -1503,7 +1503,7 @@ slapd_daemon_task(
id = connection_init(
slap_listeners[l]->sl_sd,
slap_listeners[l], "", "",
2, ssf, authid );
CONN_IS_UDP, ssf, authid );
slap_listeners[l]->sl_is_udp++;
}
continue;
......@@ -1733,7 +1733,7 @@ slapd_daemon_task(
dnsname != NULL ? dnsname : SLAP_STRING_UNKNOWN,
peername,
#ifdef HAVE_TLS
slap_listeners[l]->sl_is_tls,
slap_listeners[l]->sl_is_tls ? CONN_IS_TLS : 0,
#else
0,
#endif
......
......@@ -316,6 +316,15 @@ LDAP_SLAPD_F (int) connections_shutdown LDAP_P((void));
LDAP_SLAPD_F (int) connections_destroy LDAP_P((void));
LDAP_SLAPD_F (int) connections_timeout_idle LDAP_P((time_t));
LDAP_SLAPD_F (int) connection_client_setup LDAP_P((
ber_socket_t s,
Listener *l,
ldap_pvt_thread_start_t *func,
void *arg ));
LDAP_SLAPD_F (void) connection_client_enable LDAP_P(( ber_socket_t s ));
LDAP_SLAPD_F (void) connection_client_stop LDAP_P(( ber_socket_t s ));
LDAP_SLAPD_F (long) connection_init LDAP_P((
ber_socket_t s,
Listener* url,
......@@ -1183,13 +1192,13 @@ LDAP_SLAPD_V (struct runqueue_s) syncrepl_rq;
LDAP_SLAPD_F (void) init_syncrepl LDAP_P((syncinfo_t *));
LDAP_SLAPD_F (void*) do_syncrepl LDAP_P((void *, void *));
LDAP_SLAPD_F (Entry*) syncrepl_message_to_entry LDAP_P((
syncinfo_t *, LDAP *, Operation *, LDAPMessage *,
Modifications **, int*, struct berval *, struct berval * ));
syncinfo_t *, Operation *, LDAPMessage *,
Modifications **, int ));
LDAP_SLAPD_F (int) syncrepl_entry LDAP_P((
syncinfo_t *, LDAP *, Operation*, Entry*,
Modifications*,int, struct berval*, struct berval*, int ));
syncinfo_t *, Operation*, Entry*,
Modifications*,int, struct berval*, int ));
LDAP_SLAPD_F (void) syncrepl_updateCookie LDAP_P((
syncinfo_t *, LDAP *, Operation *, struct berval *,
syncinfo_t *, Operation *, struct berval *,
struct berval * ));
LDAP_SLAPD_F (void) syncrepl_add_glue LDAP_P((
Operation*, Entry* ));
......
......@@ -1293,44 +1293,41 @@ struct nonpresent_entry {
* syncinfo structure for syncrepl
*/
typedef struct syncinfo_s {
struct slap_conn *si_conn;
struct slap_backend_db *si_be;
struct slap_entry *si_e;
void *si_ctx;
unsigned int si_id;
char *si_provideruri;
BerVarray si_provideruri_bv;
#define SYNCINFO_TLS_OFF 0
#define SYNCINFO_TLS_ON 1
#define SYNCINFO_TLS_CRITICAL 2
int si_tls;
struct berval si_updatedn;
int si_bindmethod;
char *si_binddn;
char *si_passwd;
char *si_saslmech;
char *si_secprops;
char *si_realm;
char *si_authcId;
char *si_authzId;
int si_schemachecking;
Filter *si_filter;
struct berval si_filterstr;
struct berval si_base;
int si_scope;
int si_attrsonly;
char **si_attrs;
int si_type;
time_t si_interval;
struct berval *si_syncCookie;
int si_manageDSAit;
int si_slimit;
int si_tlimit;
struct berval *si_syncUUID;
struct berval *si_syncUUID_ndn;
Avlnode *si_presentlist;
int si_sync_mode;
LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
struct slap_backend_db *si_be;
unsigned int si_id;
char *si_provideruri;
BerVarray si_provideruri_bv;
#define SYNCINFO_TLS_OFF 0
#define SYNCINFO_TLS_ON 1
#define SYNCINFO_TLS_CRITICAL 2
int si_tls;
struct berval si_updatedn;
int si_bindmethod;
char *si_binddn;
char *si_passwd;
char *si_saslmech;
char *si_secprops;
char *si_realm;
char *si_authcId;
char *si_authzId;
int si_schemachecking;
Filter *si_filter;
struct berval si_filterstr;
struct berval si_base;
int si_scope;
int si_attrsonly;
char **si_attrs;
int si_type;
time_t si_interval;
struct berval si_syncCookie;
int si_manageDSAit;
int si_slimit;
int si_tlimit;
struct berval si_syncUUID_ndn;
Avlnode *si_presentlist;
int si_sync_mode;
LDAP *si_ld;
LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
} syncinfo_t;
struct slap_backend_db {
......@@ -2081,6 +2078,10 @@ typedef struct slap_conn {
BerElement *c_currentber; /* ber we're attempting to read */
int c_writewaiter; /* true if writer is waiting */
#define CONN_IS_TLS 1
#define CONN_IS_UDP 2
#define CONN_IS_CLIENT 3
#ifdef LDAP_CONNECTIONLESS
int c_is_udp; /* true if this is (C)LDAP over UDP */
#endif
......@@ -2109,6 +2110,12 @@ typedef struct slap_conn {
void *c_pb; /* Netscape plugin */
void *c_extensions; /* Netscape plugin */
/*
* Client connection handling
*/
ldap_pvt_thread_start_t *c_clientfunc;
void *c_clientarg;
/*
* These are the "callbacks" that are available for back-ends to
* supply data back to connected clients that are connected
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment