mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
Clean ups and renames to coexist with slapd
This commit is contained in:
parent
c7e3437e1d
commit
8bc7650a7c
@ -25,13 +25,13 @@
|
||||
#include <event2/dns.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
static void
|
||||
upstream_connect_cb( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
PendingConnection *conn = arg;
|
||||
Backend *b = conn->backend;
|
||||
LloadPendingConnection *conn = arg;
|
||||
LloadBackend *b = conn->backend;
|
||||
int error = 0, rc = -1;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
@ -89,7 +89,7 @@ done:
|
||||
static void
|
||||
upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
|
||||
{
|
||||
Backend *b = arg;
|
||||
LloadBackend *b = arg;
|
||||
ber_socket_t s = AC_SOCKET_INVALID;
|
||||
int rc;
|
||||
|
||||
@ -123,7 +123,7 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
|
||||
}
|
||||
/* Asynchronous connect */
|
||||
if ( rc ) {
|
||||
PendingConnection *conn;
|
||||
LloadPendingConnection *conn;
|
||||
|
||||
if ( errno != EINPROGRESS && errno != EWOULDBLOCK ) {
|
||||
Debug( LDAP_DEBUG_ANY, "upstream_name_cb: "
|
||||
@ -133,12 +133,12 @@ upstream_name_cb( int result, struct evutil_addrinfo *res, void *arg )
|
||||
goto fail;
|
||||
}
|
||||
|
||||
conn = ch_calloc( 1, sizeof(PendingConnection) );
|
||||
conn = ch_calloc( 1, sizeof(LloadPendingConnection) );
|
||||
LDAP_LIST_ENTRY_INIT( conn, next );
|
||||
conn->backend = b;
|
||||
conn->fd = s;
|
||||
|
||||
conn->event = event_new( slap_get_base( s ), s, EV_WRITE|EV_PERSIST,
|
||||
conn->event = event_new( lload_get_base( s ), s, EV_WRITE|EV_PERSIST,
|
||||
upstream_connect_cb, conn );
|
||||
if ( !conn->event ) {
|
||||
Debug( LDAP_DEBUG_ANY, "upstream_name_cb: "
|
||||
@ -175,10 +175,10 @@ fail:
|
||||
}
|
||||
}
|
||||
|
||||
Connection *
|
||||
backend_select( Operation *op )
|
||||
LloadConnection *
|
||||
backend_select( LloadOperation *op )
|
||||
{
|
||||
Backend *b, *first, *next;
|
||||
LloadBackend *b, *first, *next;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &backend_mutex );
|
||||
first = b = current_backend;
|
||||
@ -191,8 +191,8 @@ backend_select( Operation *op )
|
||||
/* TODO: Two runs, one with trylock, then one actually locked if we don't
|
||||
* find anything? */
|
||||
do {
|
||||
struct ConnSt *head;
|
||||
Connection *c;
|
||||
lload_c_head *head;
|
||||
LloadConnection *c;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
next = LDAP_CIRCLEQ_LOOP_NEXT( &backend, b, b_next );
|
||||
@ -257,7 +257,7 @@ backend_select( Operation *op )
|
||||
}
|
||||
|
||||
void
|
||||
backend_retry( Backend *b )
|
||||
backend_retry( LloadBackend *b )
|
||||
{
|
||||
int rc, requested;
|
||||
|
||||
@ -314,7 +314,7 @@ void
|
||||
backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
struct evutil_addrinfo hints = {};
|
||||
Backend *b = arg;
|
||||
LloadBackend *b = arg;
|
||||
char *hostname;
|
||||
|
||||
if ( slapd_shutdown ) {
|
||||
@ -357,19 +357,19 @@ backend_connect( evutil_socket_t s, short what, void *arg )
|
||||
s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un) );
|
||||
/* Asynchronous connect */
|
||||
if ( rc ) {
|
||||
PendingConnection *conn;
|
||||
LloadPendingConnection *conn;
|
||||
|
||||
if ( errno != EINPROGRESS && errno != EWOULDBLOCK ) {
|
||||
evutil_closesocket( s );
|
||||
goto fail;
|
||||
}
|
||||
|
||||
conn = ch_calloc( 1, sizeof(PendingConnection) );
|
||||
conn = ch_calloc( 1, sizeof(LloadPendingConnection) );
|
||||
LDAP_LIST_ENTRY_INIT( conn, next );
|
||||
conn->backend = b;
|
||||
conn->fd = s;
|
||||
|
||||
conn->event = event_new( slap_get_base( s ), s,
|
||||
conn->event = event_new( lload_get_base( s ), s,
|
||||
EV_WRITE|EV_PERSIST, upstream_connect_cb, conn );
|
||||
if ( !conn->event ) {
|
||||
Debug( LDAP_DEBUG_ANY, "backend_connect: "
|
||||
@ -423,14 +423,15 @@ void
|
||||
backends_destroy( void )
|
||||
{
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &backend ) ) {
|
||||
Backend *b = LDAP_CIRCLEQ_FIRST( &backend );
|
||||
LloadBackend *b = LDAP_CIRCLEQ_FIRST( &backend );
|
||||
|
||||
Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
|
||||
"destroying backend uri='%s', numconns=%d, numbindconns=%d\n",
|
||||
b->b_uri.bv_val, b->b_numconns, b->b_numbindconns );
|
||||
|
||||
while ( !LDAP_LIST_EMPTY( &b->b_connecting ) ) {
|
||||
PendingConnection *pending = LDAP_LIST_FIRST( &b->b_connecting );
|
||||
LloadPendingConnection *pending =
|
||||
LDAP_LIST_FIRST( &b->b_connecting );
|
||||
|
||||
Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
|
||||
"destroying socket pending connect() fd=%d\n",
|
||||
@ -442,7 +443,7 @@ backends_destroy( void )
|
||||
ch_free( pending );
|
||||
}
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &b->b_preparing ) ) {
|
||||
Connection *c = LDAP_CIRCLEQ_FIRST( &b->b_preparing );
|
||||
LloadConnection *c = LDAP_CIRCLEQ_FIRST( &b->b_preparing );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
|
||||
@ -453,7 +454,7 @@ backends_destroy( void )
|
||||
CONNECTION_DESTROY(c);
|
||||
}
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &b->b_bindconns ) ) {
|
||||
Connection *c = LDAP_CIRCLEQ_FIRST( &b->b_bindconns );
|
||||
LloadConnection *c = LDAP_CIRCLEQ_FIRST( &b->b_bindconns );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
|
||||
@ -464,7 +465,7 @@ backends_destroy( void )
|
||||
CONNECTION_DESTROY(c);
|
||||
}
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &b->b_conns ) ) {
|
||||
Connection *c = LDAP_CIRCLEQ_FIRST( &b->b_conns );
|
||||
LloadConnection *c = LDAP_CIRCLEQ_FIRST( &b->b_conns );
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
Debug( LDAP_DEBUG_CONNS, "backends_destroy: "
|
||||
|
@ -22,16 +22,16 @@
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
/*
|
||||
* On entering the function, we've put a reference on both connections and hold
|
||||
* upstream's c_io_mutex.
|
||||
*/
|
||||
static int
|
||||
client_bind( Operation *op )
|
||||
client_bind( LloadOperation *op )
|
||||
{
|
||||
Connection *client = op->o_client, *upstream = op->o_upstream;
|
||||
LloadConnection *client = op->o_client, *upstream = op->o_upstream;
|
||||
BerElement *ber, *copy = NULL;
|
||||
BerValue binddn;
|
||||
ber_tag_t tag;
|
||||
@ -130,9 +130,9 @@ fail:
|
||||
* upstream's c_io_mutex.
|
||||
*/
|
||||
static int
|
||||
client_bind_as_vc( Operation *op )
|
||||
client_bind_as_vc( LloadOperation *op )
|
||||
{
|
||||
Connection *client = op->o_client, *upstream = op->o_upstream;
|
||||
LloadConnection *client = op->o_client, *upstream = op->o_upstream;
|
||||
BerElement *ber, *request, *copy = NULL;
|
||||
BerValue binddn, auth, mech;
|
||||
char *msg = "internal error";
|
||||
@ -260,9 +260,9 @@ fail:
|
||||
#endif /* LDAP_API_FEATURE_VERIFY_CREDENTIALS */
|
||||
|
||||
int
|
||||
request_bind( Connection *client, Operation *op )
|
||||
request_bind( LloadConnection *client, LloadOperation *op )
|
||||
{
|
||||
Connection *upstream;
|
||||
LloadConnection *upstream;
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
/* protect the Bind operation */
|
||||
@ -334,9 +334,9 @@ request_bind( Connection *client, Operation *op )
|
||||
}
|
||||
|
||||
int
|
||||
handle_bind_response( Operation *op, BerElement *ber )
|
||||
handle_bind_response( LloadOperation *op, BerElement *ber )
|
||||
{
|
||||
Connection *client = op->o_client, *upstream = op->o_upstream;
|
||||
LloadConnection *client = op->o_client, *upstream = op->o_upstream;
|
||||
BerValue response;
|
||||
BerElement *copy;
|
||||
ber_int_t result;
|
||||
@ -413,9 +413,9 @@ done:
|
||||
|
||||
#ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS
|
||||
int
|
||||
handle_vc_bind_response( Operation *op, BerElement *ber )
|
||||
handle_vc_bind_response( LloadOperation *op, BerElement *ber )
|
||||
{
|
||||
Connection *c = op->o_client;
|
||||
LloadConnection *c = op->o_client;
|
||||
BerElement *output;
|
||||
BerValue matched, diagmsg, creds = BER_BVNULL, controls = BER_BVNULL;
|
||||
ber_int_t result;
|
||||
@ -432,11 +432,11 @@ handle_vc_bind_response( Operation *op, BerElement *ber )
|
||||
|
||||
tag = ber_peek_tag( ber, &len );
|
||||
if ( result == LDAP_PROTOCOL_ERROR ) {
|
||||
Connection *upstream = op->o_upstream;
|
||||
Backend *b;
|
||||
LloadConnection *upstream = op->o_upstream;
|
||||
LloadBackend *b;
|
||||
|
||||
CONNECTION_LOCK(upstream);
|
||||
b = (Backend *)upstream->c_private;
|
||||
b = (LloadBackend *)upstream->c_private;
|
||||
Debug( LDAP_DEBUG_ANY, "handle_vc_bind_response: "
|
||||
"VC extended operation not supported on backend %s\n",
|
||||
b->b_uri.bv_val );
|
||||
|
@ -22,16 +22,16 @@
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
slap_c_head clients = LDAP_CIRCLEQ_HEAD_INITIALIZER( clients );
|
||||
lload_c_head clients = LDAP_CIRCLEQ_HEAD_INITIALIZER( clients );
|
||||
|
||||
ldap_pvt_thread_mutex_t clients_mutex;
|
||||
|
||||
int
|
||||
request_abandon( Connection *c, Operation *op )
|
||||
request_abandon( LloadConnection *c, LloadOperation *op )
|
||||
{
|
||||
Operation *request, needle = { .o_client_connid = c->c_connid };
|
||||
LloadOperation *request, needle = { .o_client_connid = c->c_connid };
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
if ( ber_decode_int( &op->o_request, &needle.o_client_msgid ) ) {
|
||||
@ -61,8 +61,8 @@ request_abandon( Connection *c, Operation *op )
|
||||
}
|
||||
Debug( LDAP_DEBUG_STATS, "request_abandon: "
|
||||
"connid=%lu msgid=%d abandoning %s msgid=%d\n",
|
||||
c->c_connid, op->o_client_msgid, slap_msgtype2str( request->o_tag ),
|
||||
needle.o_client_msgid );
|
||||
c->c_connid, op->o_client_msgid,
|
||||
lload_msgtype2str( request->o_tag ), needle.o_client_msgid );
|
||||
|
||||
if ( c->c_state == LLOAD_C_BINDING ) {
|
||||
/* We have found the request and we are binding, it must be a bind
|
||||
@ -81,10 +81,10 @@ done:
|
||||
}
|
||||
|
||||
int
|
||||
request_process( Connection *client, Operation *op )
|
||||
request_process( LloadConnection *client, LloadOperation *op )
|
||||
{
|
||||
BerElement *output;
|
||||
Connection *upstream;
|
||||
LloadConnection *upstream;
|
||||
ber_int_t msgid;
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
@ -120,7 +120,7 @@ request_process( Connection *client, Operation *op )
|
||||
Debug( LDAP_DEBUG_TRACE, "request_process: "
|
||||
"client connid=%lu added %s msgid=%d to upstream connid=%lu as "
|
||||
"msgid=%d\n",
|
||||
op->o_client_connid, slap_msgtype2str( op->o_tag ),
|
||||
op->o_client_connid, lload_msgtype2str( op->o_tag ),
|
||||
op->o_client_msgid, op->o_upstream_connid, op->o_upstream_msgid );
|
||||
assert( rc == LDAP_SUCCESS );
|
||||
|
||||
@ -163,12 +163,12 @@ request_process( Connection *client, Operation *op )
|
||||
|
||||
fail:
|
||||
if ( upstream ) {
|
||||
Backend *b;
|
||||
LloadBackend *b;
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
|
||||
CONNECTION_LOCK_DECREF(upstream);
|
||||
upstream->c_n_ops_executing--;
|
||||
b = (Backend *)upstream->c_private;
|
||||
b = (LloadBackend *)upstream->c_private;
|
||||
CONNECTION_UNLOCK_OR_DESTROY(upstream);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
@ -187,10 +187,10 @@ fail:
|
||||
}
|
||||
|
||||
int
|
||||
handle_one_request( Connection *c )
|
||||
handle_one_request( LloadConnection *c )
|
||||
{
|
||||
BerElement *ber;
|
||||
Operation *op = NULL;
|
||||
LloadOperation *op = NULL;
|
||||
RequestHandler handler = NULL;
|
||||
|
||||
ber = c->c_currentber;
|
||||
@ -244,7 +244,7 @@ handle_one_request( Connection *c )
|
||||
void
|
||||
client_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
LloadConnection *c = arg;
|
||||
int rc = 0;
|
||||
|
||||
CONNECTION_LOCK_DECREF(c);
|
||||
@ -283,7 +283,7 @@ client_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
|
||||
|
||||
rc = ldap_pvt_tls_accept( c->c_sb, slap_tls_ctx );
|
||||
rc = ldap_pvt_tls_accept( c->c_sb, lload_tls_ctx );
|
||||
if ( rc < 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
@ -332,22 +332,22 @@ fail:
|
||||
CONNECTION_DESTROY(c);
|
||||
}
|
||||
|
||||
Connection *
|
||||
LloadConnection *
|
||||
client_init(
|
||||
ber_socket_t s,
|
||||
Listener *listener,
|
||||
LloadListener *listener,
|
||||
const char *peername,
|
||||
struct event_base *base,
|
||||
int flags )
|
||||
{
|
||||
Connection *c;
|
||||
LloadConnection *c;
|
||||
struct event *event;
|
||||
event_callback_fn read_cb = connection_read_cb,
|
||||
write_cb = connection_write_cb;
|
||||
|
||||
assert( listener != NULL );
|
||||
|
||||
if ( (c = connection_init( s, peername, flags )) == NULL ) {
|
||||
if ( (c = lload_connection_init( s, peername, flags) ) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ client_init(
|
||||
|
||||
c->c_is_tls = LLOAD_LDAPS;
|
||||
|
||||
rc = ldap_pvt_tls_accept( c->c_sb, slap_tls_ctx );
|
||||
rc = ldap_pvt_tls_accept( c->c_sb, lload_tls_ctx );
|
||||
if ( rc < 0 ) {
|
||||
Debug( LDAP_DEBUG_CONNS, "client_init: "
|
||||
"connid=%lu failed initial TLS accept rc=%d\n",
|
||||
@ -426,7 +426,7 @@ fail:
|
||||
}
|
||||
|
||||
void
|
||||
client_reset( Connection *c )
|
||||
client_reset( LloadConnection *c )
|
||||
{
|
||||
TAvlnode *root;
|
||||
|
||||
@ -439,7 +439,7 @@ client_reset( Connection *c )
|
||||
if ( root ) {
|
||||
TAvlnode *node = tavl_end( root, TAVL_DIR_LEFT );
|
||||
do {
|
||||
Operation *op = node->avl_data;
|
||||
LloadOperation *op = node->avl_data;
|
||||
|
||||
/* make sure it's useable after we've unlocked the connection */
|
||||
op->o_client_refcnt++;
|
||||
@ -468,7 +468,7 @@ client_reset( Connection *c )
|
||||
}
|
||||
|
||||
void
|
||||
client_destroy( Connection *c )
|
||||
client_destroy( LloadConnection *c )
|
||||
{
|
||||
enum sc_state state;
|
||||
struct event *read_event, *write_event;
|
||||
@ -547,7 +547,7 @@ clients_destroy( void )
|
||||
{
|
||||
ldap_pvt_thread_mutex_lock( &clients_mutex );
|
||||
while ( !LDAP_CIRCLEQ_EMPTY( &clients ) ) {
|
||||
Connection *c = LDAP_CIRCLEQ_FIRST( &clients );
|
||||
LloadConnection *c = LDAP_CIRCLEQ_FIRST( &clients );
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &clients_mutex );
|
||||
CONNECTION_LOCK(c);
|
||||
|
@ -42,7 +42,7 @@
|
||||
#define S_ISREG(m) ( ((m) & _S_IFMT ) == _S_IFREG )
|
||||
#endif
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
#include "lutil.h"
|
||||
#include "lutil_ldap.h"
|
||||
#include "config.h"
|
||||
@ -77,7 +77,7 @@ lload_features_t lload_features;
|
||||
ber_len_t sockbuf_max_incoming_client = LLOAD_SB_MAX_INCOMING_CLIENT;
|
||||
ber_len_t sockbuf_max_incoming_upstream = LLOAD_SB_MAX_INCOMING_UPSTREAM;
|
||||
|
||||
int slap_conn_max_pdus_per_cycle = LLOAD_CONN_MAX_PDUS_PER_CYCLE_DEFAULT;
|
||||
int lload_conn_max_pdus_per_cycle = LLOAD_CONN_MAX_PDUS_PER_CYCLE_DEFAULT;
|
||||
|
||||
struct timeval *lload_timeout_api = NULL;
|
||||
struct timeval *lload_timeout_net = NULL;
|
||||
@ -120,9 +120,9 @@ static ConfigDriver config_tls_option;
|
||||
static ConfigDriver config_tls_config;
|
||||
#endif
|
||||
|
||||
slap_b_head backend = LDAP_CIRCLEQ_HEAD_INITIALIZER(backend);
|
||||
lload_b_head backend = LDAP_CIRCLEQ_HEAD_INITIALIZER(backend);
|
||||
ldap_pvt_thread_mutex_t backend_mutex;
|
||||
Backend *current_backend = NULL;
|
||||
LloadBackend *current_backend = NULL;
|
||||
|
||||
struct slap_bindconf bindconf = {};
|
||||
struct berval lloadd_identity = BER_BVNULL;
|
||||
@ -446,8 +446,8 @@ config_generic( ConfigArgs *c )
|
||||
mask <<= 1;
|
||||
mask |= 1;
|
||||
}
|
||||
slapd_daemon_mask = mask;
|
||||
slapd_daemon_threads = mask + 1;
|
||||
lload_daemon_mask = mask;
|
||||
lload_daemon_threads = mask + 1;
|
||||
} break;
|
||||
|
||||
case CFG_LOGFILE: {
|
||||
@ -464,7 +464,7 @@ config_generic( ConfigArgs *c )
|
||||
Debug( LDAP_DEBUG_ANY, "%s: %s\n", c->log, c->cr_msg );
|
||||
return 1;
|
||||
}
|
||||
slap_conn_max_pdus_per_cycle = c->value_int;
|
||||
lload_conn_max_pdus_per_cycle = c->value_int;
|
||||
break;
|
||||
|
||||
case CFG_IOTIMEOUT:
|
||||
@ -495,9 +495,9 @@ config_backend( ConfigArgs *c )
|
||||
{
|
||||
int i, tmp, rc = -1;
|
||||
LDAPURLDesc *lud = NULL;
|
||||
Backend *b;
|
||||
LloadBackend *b;
|
||||
|
||||
b = ch_calloc( 1, sizeof(Backend) );
|
||||
b = ch_calloc( 1, sizeof(LloadBackend) );
|
||||
|
||||
LDAP_CIRCLEQ_INIT( &b->b_conns );
|
||||
LDAP_CIRCLEQ_INIT( &b->b_bindconns );
|
||||
@ -509,7 +509,7 @@ config_backend( ConfigArgs *c )
|
||||
b->b_retry_timeout = 5000;
|
||||
|
||||
for ( i = 1; i < c->argc; i++ ) {
|
||||
if ( backend_parse( c->argv[i], b ) ) {
|
||||
if ( lload_backend_parse( c->argv[i], b ) ) {
|
||||
Debug( LDAP_DEBUG_ANY, "config_backend: "
|
||||
"error parsing backend configuration item '%s'\n",
|
||||
c->argv[i] );
|
||||
@ -631,7 +631,7 @@ config_bindconf( ConfigArgs *c )
|
||||
int i;
|
||||
|
||||
for ( i = 1; i < c->argc; i++ ) {
|
||||
if ( bindconf_parse( c->argv[i], &bindconf ) ) {
|
||||
if ( lload_bindconf_parse( c->argv[i], &bindconf ) ) {
|
||||
Debug( LDAP_DEBUG_ANY, "config_bindconf: "
|
||||
"error parsing backend configuration item '%s'\n",
|
||||
c->argv[i] );
|
||||
@ -689,7 +689,7 @@ config_bindconf( ConfigArgs *c )
|
||||
|
||||
#ifdef HAVE_TLS
|
||||
if ( bindconf.sb_tls_do_init ) {
|
||||
bindconf_tls_set( &bindconf, slap_tls_backend_ld );
|
||||
lload_bindconf_tls_set( &bindconf, lload_tls_backend_ld );
|
||||
}
|
||||
#endif /* HAVE_TLS */
|
||||
return 0;
|
||||
@ -719,7 +719,7 @@ tcp_buffer_parse(
|
||||
char **argv,
|
||||
int *size,
|
||||
int *rw,
|
||||
Listener **l )
|
||||
LloadListener **l )
|
||||
{
|
||||
int i, rc = LDAP_SUCCESS;
|
||||
LDAPURLDesc *lud = NULL;
|
||||
@ -743,7 +743,7 @@ tcp_buffer_parse(
|
||||
goto done;
|
||||
}
|
||||
|
||||
*l = config_check_my_url( url, lud );
|
||||
*l = lload_config_check_my_url( url, lud );
|
||||
if ( *l == NULL ) {
|
||||
rc = LDAP_NO_SUCH_ATTRIBUTE;
|
||||
goto done;
|
||||
@ -784,7 +784,7 @@ done:;
|
||||
}
|
||||
|
||||
static int
|
||||
tcp_buffer_unparse( int size, int rw, Listener *l, struct berval *val )
|
||||
tcp_buffer_unparse( int size, int rw, LloadListener *l, struct berval *val )
|
||||
{
|
||||
char buf[sizeof("2147483648")], *ptr;
|
||||
|
||||
@ -835,7 +835,7 @@ tcp_buffer_add_one( int argc, char **argv )
|
||||
{
|
||||
int rc = 0;
|
||||
int size = -1, rw = 0;
|
||||
Listener *l = NULL;
|
||||
LloadListener *l = NULL;
|
||||
|
||||
struct berval val;
|
||||
|
||||
@ -854,7 +854,7 @@ tcp_buffer_add_one( int argc, char **argv )
|
||||
/* use parsed values */
|
||||
if ( l != NULL ) {
|
||||
int i;
|
||||
Listener **ll = slapd_get_listeners();
|
||||
LloadListener **ll = lloadd_get_listeners();
|
||||
|
||||
for ( i = 0; ll[i] != NULL; i++ ) {
|
||||
if ( ll[i] == l ) break;
|
||||
@ -1130,7 +1130,8 @@ config_include( ConfigArgs *c )
|
||||
}
|
||||
cfn = cf;
|
||||
ber_str2bv( c->argv[1], 0, 1, &cf->c_file );
|
||||
rc = read_config_file( c->argv[1], c->depth + 1, c, config_back_cf_table );
|
||||
rc = lload_read_config_file(
|
||||
c->argv[1], c->depth + 1, c, config_back_cf_table );
|
||||
c->lineno = savelineno - 1;
|
||||
cfn = cfsave;
|
||||
if ( rc ) {
|
||||
@ -1175,19 +1176,19 @@ config_tls_cleanup( ConfigArgs *c )
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if ( slap_tls_ld ) {
|
||||
if ( lload_tls_ld ) {
|
||||
int opt = 1;
|
||||
|
||||
ldap_pvt_tls_ctx_free( slap_tls_ctx );
|
||||
slap_tls_ctx = NULL;
|
||||
ldap_pvt_tls_ctx_free( lload_tls_ctx );
|
||||
lload_tls_ctx = NULL;
|
||||
|
||||
/* Force new ctx to be created */
|
||||
rc = ldap_pvt_tls_set_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
|
||||
if ( rc == 0 ) {
|
||||
/* The ctx's refcount is bumped up here */
|
||||
ldap_pvt_tls_get_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_CTX, &lload_tls_ctx );
|
||||
} else {
|
||||
if ( rc == LDAP_NOT_SUPPORTED )
|
||||
rc = LDAP_UNWILLING_TO_PERFORM;
|
||||
@ -1203,7 +1204,7 @@ config_tls_option( ConfigArgs *c )
|
||||
{
|
||||
int flag, rc;
|
||||
int berval = 0;
|
||||
LDAP *ld = slap_tls_ld;
|
||||
LDAP *ld = lload_tls_ld;
|
||||
switch ( c->type ) {
|
||||
case CFG_TLS_RAND:
|
||||
flag = LDAP_OPT_X_TLS_RANDOM_FILE;
|
||||
@ -1290,11 +1291,11 @@ config_tls_config( ConfigArgs *c )
|
||||
return 1;
|
||||
}
|
||||
if ( c->op == SLAP_CONFIG_EMIT ) {
|
||||
return slap_tls_get_config( slap_tls_ld, flag, &c->value_string );
|
||||
return lload_tls_get_config( lload_tls_ld, flag, &c->value_string );
|
||||
} else if ( c->op == LDAP_MOD_DELETE ) {
|
||||
int i = 0;
|
||||
config_push_cleanup( c, config_tls_cleanup );
|
||||
return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
|
||||
return ldap_pvt_tls_set_option( lload_tls_ld, flag, &i );
|
||||
}
|
||||
ch_free( c->value_string );
|
||||
config_push_cleanup( c, config_tls_cleanup );
|
||||
@ -1306,22 +1307,22 @@ config_tls_config( ConfigArgs *c )
|
||||
c->log, c->argv[0], c->argv[1] );
|
||||
return 1;
|
||||
}
|
||||
return ldap_pvt_tls_set_option( slap_tls_ld, flag, &i );
|
||||
return ldap_pvt_tls_set_option( lload_tls_ld, flag, &i );
|
||||
} else {
|
||||
return ldap_pvt_tls_config( slap_tls_ld, flag, c->argv[1] );
|
||||
return ldap_pvt_tls_config( lload_tls_ld, flag, c->argv[1] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
init_config_argv( ConfigArgs *c )
|
||||
lload_init_config_argv( ConfigArgs *c )
|
||||
{
|
||||
c->argv = ch_calloc( ARGS_STEP + 1, sizeof(*c->argv) );
|
||||
c->argv_size = ARGS_STEP + 1;
|
||||
}
|
||||
|
||||
ConfigTable *
|
||||
config_find_keyword( ConfigTable *Conf, ConfigArgs *c )
|
||||
lload_config_find_keyword( ConfigTable *Conf, ConfigArgs *c )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -1348,7 +1349,7 @@ config_find_keyword( ConfigTable *Conf, ConfigArgs *c )
|
||||
}
|
||||
|
||||
int
|
||||
config_check_vals( ConfigTable *Conf, ConfigArgs *c, int check_only )
|
||||
lload_config_check_vals( ConfigTable *Conf, ConfigArgs *c, int check_only )
|
||||
{
|
||||
int arg_user, arg_type, arg_syn, iarg;
|
||||
unsigned uiarg;
|
||||
@ -1531,7 +1532,7 @@ config_check_vals( ConfigTable *Conf, ConfigArgs *c, int check_only )
|
||||
}
|
||||
|
||||
int
|
||||
config_set_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
lload_config_set_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
{
|
||||
int rc, arg_type;
|
||||
void *ptr = NULL;
|
||||
@ -1603,7 +1604,7 @@ config_set_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
}
|
||||
|
||||
int
|
||||
config_add_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
lload_config_add_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
{
|
||||
int rc, arg_type;
|
||||
|
||||
@ -1613,13 +1614,13 @@ config_add_vals( ConfigTable *Conf, ConfigArgs *c )
|
||||
c->log, Conf->name );
|
||||
return 0;
|
||||
}
|
||||
rc = config_check_vals( Conf, c, 0 );
|
||||
rc = lload_config_check_vals( Conf, c, 0 );
|
||||
if ( rc ) return rc;
|
||||
return config_set_vals( Conf, c );
|
||||
return lload_config_set_vals( Conf, c );
|
||||
}
|
||||
|
||||
int
|
||||
read_config_file(
|
||||
lload_read_config_file(
|
||||
const char *fname,
|
||||
int depth,
|
||||
ConfigArgs *cf,
|
||||
@ -1644,7 +1645,7 @@ read_config_file(
|
||||
|
||||
c->valx = -1;
|
||||
c->fname = fname;
|
||||
init_config_argv( c );
|
||||
lload_init_config_argv( c );
|
||||
|
||||
if ( stat( fname, &s ) != 0 ) {
|
||||
char ebuf[128];
|
||||
@ -1696,7 +1697,7 @@ read_config_file(
|
||||
|
||||
c->argc = 0;
|
||||
ch_free( c->tline );
|
||||
if ( config_fp_parse_line( c ) ) {
|
||||
if ( lload_config_fp_parse_line( c ) ) {
|
||||
rc = 1;
|
||||
goto done;
|
||||
}
|
||||
@ -1709,10 +1710,10 @@ read_config_file(
|
||||
|
||||
c->op = SLAP_CONFIG_ADD;
|
||||
|
||||
ct = config_find_keyword( cft, c );
|
||||
ct = lload_config_find_keyword( cft, c );
|
||||
if ( ct ) {
|
||||
c->table = Cft_Global;
|
||||
rc = config_add_vals( ct, c );
|
||||
rc = lload_config_add_vals( ct, c );
|
||||
if ( !rc ) continue;
|
||||
|
||||
if ( rc & ARGS_USERLAND ) {
|
||||
@ -1747,13 +1748,13 @@ done:
|
||||
}
|
||||
|
||||
int
|
||||
read_config( const char *fname, const char *dir )
|
||||
lload_read_config( const char *fname, const char *dir )
|
||||
{
|
||||
if ( !fname ) fname = LLOADD_DEFAULT_CONFIGFILE;
|
||||
|
||||
cfn = ch_calloc( 1, sizeof(ConfigFile) );
|
||||
|
||||
return read_config_file( fname, 0, NULL, config_back_cf_table );
|
||||
return lload_read_config_file( fname, 0, NULL, config_back_cf_table );
|
||||
}
|
||||
|
||||
/* restrictops, allows, disallows, requires, loglevel */
|
||||
@ -1890,7 +1891,7 @@ static slap_verbmasks methkey[] = {
|
||||
};
|
||||
|
||||
int
|
||||
slap_keepalive_parse(
|
||||
lload_keepalive_parse(
|
||||
struct berval *val,
|
||||
void *bc,
|
||||
slap_cf_aux_table *tab0,
|
||||
@ -1975,15 +1976,15 @@ slap_keepalive_parse(
|
||||
}
|
||||
|
||||
static slap_cf_aux_table backendkey[] = {
|
||||
{ BER_BVC("uri="), offsetof(Backend, b_uri), 'b', 1, NULL },
|
||||
{ BER_BVC("uri="), offsetof(LloadBackend, b_uri), 'b', 1, NULL },
|
||||
|
||||
{ BER_BVC("numconns="), offsetof(Backend, b_numconns), 'i', 0, NULL },
|
||||
{ BER_BVC("bindconns="), offsetof(Backend, b_numbindconns), 'i', 0, NULL },
|
||||
{ BER_BVC("retry="), offsetof(Backend, b_retry_timeout), 'i', 0, NULL },
|
||||
{ BER_BVC("numconns="), offsetof(LloadBackend, b_numconns), 'i', 0, NULL },
|
||||
{ BER_BVC("bindconns="), offsetof(LloadBackend, b_numbindconns), 'i', 0, NULL },
|
||||
{ BER_BVC("retry="), offsetof(LloadBackend, b_retry_timeout), 'i', 0, NULL },
|
||||
|
||||
{ BER_BVC("max-pending-ops="), offsetof(Backend, b_max_pending), 'i', 0, NULL },
|
||||
{ BER_BVC("conn-max-pending="), offsetof(Backend, b_max_conn_pending), 'i', 0, NULL },
|
||||
{ BER_BVC("starttls="), offsetof(Backend, b_tls), 'i', 0, tlskey },
|
||||
{ BER_BVC("max-pending-ops="), offsetof(LloadBackend, b_max_pending), 'i', 0, NULL },
|
||||
{ BER_BVC("conn-max-pending="), offsetof(LloadBackend, b_max_conn_pending), 'i', 0, NULL },
|
||||
{ BER_BVC("starttls="), offsetof(LloadBackend, b_tls), 'i', 0, tlskey },
|
||||
{ BER_BVNULL, 0, 0, 0, NULL }
|
||||
};
|
||||
|
||||
@ -1998,7 +1999,7 @@ static slap_cf_aux_table bindkey[] = {
|
||||
{ BER_BVC("realm="), offsetof(slap_bindconf, sb_realm), 'b', 0, NULL },
|
||||
{ BER_BVC("authcID="), offsetof(slap_bindconf, sb_authcId), 'b', 1, NULL },
|
||||
{ BER_BVC("authzID="), offsetof(slap_bindconf, sb_authzId), 'b', 1, NULL },
|
||||
{ BER_BVC("keepalive="), offsetof(slap_bindconf, sb_keepalive), 'x', 0, (slap_verbmasks *)slap_keepalive_parse },
|
||||
{ BER_BVC("keepalive="), offsetof(slap_bindconf, sb_keepalive), 'x', 0, (slap_verbmasks *)lload_keepalive_parse },
|
||||
#ifdef HAVE_TLS
|
||||
/* NOTE: replace "11" with the actual index
|
||||
* of the first TLS-related line */
|
||||
@ -2030,7 +2031,7 @@ static slap_cf_aux_table bindkey[] = {
|
||||
*/
|
||||
|
||||
int
|
||||
slap_cf_aux_table_parse(
|
||||
lload_cf_aux_table_parse(
|
||||
const char *word,
|
||||
void *dst,
|
||||
slap_cf_aux_table *tab0,
|
||||
@ -2106,8 +2107,8 @@ slap_cf_aux_table_parse(
|
||||
case 'x':
|
||||
if ( tab->aux != NULL ) {
|
||||
struct berval value;
|
||||
slap_cf_aux_table_parse_x *func =
|
||||
(slap_cf_aux_table_parse_x *)tab->aux;
|
||||
lload_cf_aux_table_parse_x *func =
|
||||
(lload_cf_aux_table_parse_x *)tab->aux;
|
||||
|
||||
ber_str2bv( val, 0, 1, &value );
|
||||
|
||||
@ -2132,7 +2133,7 @@ slap_cf_aux_table_parse(
|
||||
}
|
||||
|
||||
int
|
||||
slap_cf_aux_table_unparse(
|
||||
lload_cf_aux_table_unparse(
|
||||
void *src,
|
||||
struct berval *bv,
|
||||
slap_cf_aux_table *tab0 )
|
||||
@ -2221,8 +2222,8 @@ slap_cf_aux_table_unparse(
|
||||
if ( tab->quote ) *ptr++ = '"';
|
||||
if ( tab->aux != NULL ) {
|
||||
struct berval value;
|
||||
slap_cf_aux_table_parse_x *func =
|
||||
(slap_cf_aux_table_parse_x *)tab->aux;
|
||||
lload_cf_aux_table_parse_x *func =
|
||||
(lload_cf_aux_table_parse_x *)tab->aux;
|
||||
int rc;
|
||||
|
||||
value.bv_val = ptr;
|
||||
@ -2253,7 +2254,7 @@ slap_cf_aux_table_unparse(
|
||||
}
|
||||
|
||||
int
|
||||
slap_tls_get_config( LDAP *ld, int opt, char **val )
|
||||
lload_tls_get_config( LDAP *ld, int opt, char **val )
|
||||
{
|
||||
#ifdef HAVE_TLS
|
||||
slap_verbmasks *keys;
|
||||
@ -2305,7 +2306,7 @@ static struct {
|
||||
};
|
||||
|
||||
int
|
||||
bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
lload_bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
{
|
||||
int i, rc, newctx = 0, res = 0;
|
||||
char *ptr = (char *)bc, **word;
|
||||
@ -2316,7 +2317,7 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
if ( *word ) {
|
||||
rc = ldap_set_option( ld, bindtlsopts[i].opt, *word );
|
||||
if ( rc ) {
|
||||
Debug( LDAP_DEBUG_ANY, "bindconf_tls_set: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_bindconf_tls_set: "
|
||||
"failed to set %s to %s\n",
|
||||
bindtlsopts[i].key, *word );
|
||||
res = -1;
|
||||
@ -2328,7 +2329,7 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
rc = ldap_pvt_tls_config(
|
||||
ld, LDAP_OPT_X_TLS_REQUIRE_CERT, bc->sb_tls_reqcert );
|
||||
if ( rc ) {
|
||||
Debug( LDAP_DEBUG_ANY, "bindconf_tls_set: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_bindconf_tls_set: "
|
||||
"failed to set tls_reqcert to %s\n",
|
||||
bc->sb_tls_reqcert );
|
||||
res = -1;
|
||||
@ -2343,7 +2344,7 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
rc = ldap_pvt_tls_config(
|
||||
ld, LDAP_OPT_X_TLS_REQUIRE_SAN, bc->sb_tls_reqsan );
|
||||
if ( rc ) {
|
||||
Debug( LDAP_DEBUG_ANY, "bindconf_tls_set: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_bindconf_tls_set: "
|
||||
"failed to set tls_reqsan to %s\n",
|
||||
bc->sb_tls_reqsan );
|
||||
res = -1;
|
||||
@ -2358,7 +2359,7 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
rc = ldap_pvt_tls_config(
|
||||
ld, LDAP_OPT_X_TLS_PROTOCOL_MIN, bc->sb_tls_protocol_min );
|
||||
if ( rc ) {
|
||||
Debug( LDAP_DEBUG_ANY, "bindconf_tls_set: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_bindconf_tls_set: "
|
||||
"failed to set tls_protocol_min to %s\n",
|
||||
bc->sb_tls_protocol_min );
|
||||
res = -1;
|
||||
@ -2370,7 +2371,7 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
rc = ldap_pvt_tls_config(
|
||||
ld, LDAP_OPT_X_TLS_CRLCHECK, bc->sb_tls_crlcheck );
|
||||
if ( rc ) {
|
||||
Debug( LDAP_DEBUG_ANY, "bindconf_tls_set: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_bindconf_tls_set: "
|
||||
"failed to set tls_crlcheck to %s\n",
|
||||
bc->sb_tls_crlcheck );
|
||||
res = -1;
|
||||
@ -2410,10 +2411,10 @@ bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
|
||||
#endif
|
||||
|
||||
int
|
||||
bindconf_tls_parse( const char *word, slap_bindconf *bc )
|
||||
lload_bindconf_tls_parse( const char *word, slap_bindconf *bc )
|
||||
{
|
||||
#ifdef HAVE_TLS
|
||||
if ( slap_cf_aux_table_parse( word, bc, aux_TLS, "tls config" ) == 0 ) {
|
||||
if ( lload_cf_aux_table_parse( word, bc, aux_TLS, "tls config" ) == 0 ) {
|
||||
bc->sb_tls_do_init = 1;
|
||||
return 0;
|
||||
}
|
||||
@ -2422,31 +2423,31 @@ bindconf_tls_parse( const char *word, slap_bindconf *bc )
|
||||
}
|
||||
|
||||
int
|
||||
backend_parse( const char *word, Backend *b )
|
||||
lload_backend_parse( const char *word, LloadBackend *b )
|
||||
{
|
||||
return slap_cf_aux_table_parse( word, b, backendkey, "backend config" );
|
||||
return lload_cf_aux_table_parse( word, b, backendkey, "backend config" );
|
||||
}
|
||||
|
||||
int
|
||||
bindconf_parse( const char *word, slap_bindconf *bc )
|
||||
lload_bindconf_parse( const char *word, slap_bindconf *bc )
|
||||
{
|
||||
#ifdef HAVE_TLS
|
||||
/* Detect TLS config changes explicitly */
|
||||
if ( bindconf_tls_parse( word, bc ) == 0 ) {
|
||||
if ( lload_bindconf_tls_parse( word, bc ) == 0 ) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return slap_cf_aux_table_parse( word, bc, bindkey, "bind config" );
|
||||
return lload_cf_aux_table_parse( word, bc, bindkey, "bind config" );
|
||||
}
|
||||
|
||||
int
|
||||
bindconf_unparse( slap_bindconf *bc, struct berval *bv )
|
||||
lload_bindconf_unparse( slap_bindconf *bc, struct berval *bv )
|
||||
{
|
||||
return slap_cf_aux_table_unparse( bc, bv, bindkey );
|
||||
return lload_cf_aux_table_unparse( bc, bv, bindkey );
|
||||
}
|
||||
|
||||
void
|
||||
bindconf_free( slap_bindconf *bc )
|
||||
lload_bindconf_free( slap_bindconf *bc )
|
||||
{
|
||||
if ( !BER_BVISNULL( &bc->sb_uri ) ) {
|
||||
ch_free( bc->sb_uri.bv_val );
|
||||
@ -2523,29 +2524,29 @@ bindconf_free( slap_bindconf *bc )
|
||||
}
|
||||
|
||||
void
|
||||
bindconf_tls_defaults( slap_bindconf *bc )
|
||||
lload_bindconf_tls_defaults( slap_bindconf *bc )
|
||||
{
|
||||
#ifdef HAVE_TLS
|
||||
if ( bc->sb_tls_do_init ) {
|
||||
if ( !bc->sb_tls_cacert )
|
||||
ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CACERTFILE,
|
||||
ldap_pvt_tls_get_option( lload_tls_ld, LDAP_OPT_X_TLS_CACERTFILE,
|
||||
&bc->sb_tls_cacert );
|
||||
if ( !bc->sb_tls_cacertdir )
|
||||
ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CACERTDIR,
|
||||
ldap_pvt_tls_get_option( lload_tls_ld, LDAP_OPT_X_TLS_CACERTDIR,
|
||||
&bc->sb_tls_cacertdir );
|
||||
if ( !bc->sb_tls_cert )
|
||||
ldap_pvt_tls_get_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_CERTFILE, &bc->sb_tls_cert );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_CERTFILE, &bc->sb_tls_cert );
|
||||
if ( !bc->sb_tls_key )
|
||||
ldap_pvt_tls_get_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_KEYFILE, &bc->sb_tls_key );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_KEYFILE, &bc->sb_tls_key );
|
||||
if ( !bc->sb_tls_cipher_suite )
|
||||
ldap_pvt_tls_get_option( slap_tls_ld, LDAP_OPT_X_TLS_CIPHER_SUITE,
|
||||
ldap_pvt_tls_get_option( lload_tls_ld, LDAP_OPT_X_TLS_CIPHER_SUITE,
|
||||
&bc->sb_tls_cipher_suite );
|
||||
if ( !bc->sb_tls_reqcert ) bc->sb_tls_reqcert = ch_strdup( "demand" );
|
||||
#ifdef HAVE_OPENSSL_CRL
|
||||
if ( !bc->sb_tls_crlcheck )
|
||||
slap_tls_get_config( slap_tls_ld, LDAP_OPT_X_TLS_CRLCHECK,
|
||||
lload_tls_get_config( lload_tls_ld, LDAP_OPT_X_TLS_CRLCHECK,
|
||||
&bc->sb_tls_crlcheck );
|
||||
#endif
|
||||
}
|
||||
@ -2678,7 +2679,7 @@ fp_getline( FILE *fp, ConfigArgs *c )
|
||||
}
|
||||
|
||||
int
|
||||
config_fp_parse_line( ConfigArgs *c )
|
||||
lload_config_fp_parse_line( ConfigArgs *c )
|
||||
{
|
||||
char *token;
|
||||
static char *const hide[] = { "bindconf", NULL };
|
||||
@ -2728,7 +2729,7 @@ config_fp_parse_line( ConfigArgs *c )
|
||||
}
|
||||
|
||||
void
|
||||
config_destroy( void )
|
||||
lload_config_destroy( void )
|
||||
{
|
||||
free( line );
|
||||
if ( slapd_args_file ) free( slapd_args_file );
|
||||
@ -2738,15 +2739,15 @@ config_destroy( void )
|
||||
|
||||
/* See if the given URL (in plain and parsed form) matches
|
||||
* any of the server's listener addresses. Return matching
|
||||
* Listener or NULL for no match.
|
||||
* LloadListener or NULL for no match.
|
||||
*/
|
||||
Listener *
|
||||
config_check_my_url( const char *url, LDAPURLDesc *lud )
|
||||
LloadListener *
|
||||
lload_config_check_my_url( const char *url, LDAPURLDesc *lud )
|
||||
{
|
||||
Listener **l = slapd_get_listeners();
|
||||
LloadListener **l = lloadd_get_listeners();
|
||||
int i, isMe;
|
||||
|
||||
/* Try a straight compare with Listener strings */
|
||||
/* Try a straight compare with LloadListener strings */
|
||||
for ( i = 0; l && l[i]; i++ ) {
|
||||
if ( !strcasecmp( url, l[i]->sl_url.bv_val ) ) {
|
||||
return l[i];
|
||||
|
@ -128,19 +128,19 @@ typedef struct config_args_s {
|
||||
#define value_string values.v_string
|
||||
#define value_bv values.v_bv
|
||||
|
||||
int config_fp_parse_line( ConfigArgs *c );
|
||||
int lload_config_fp_parse_line( ConfigArgs *c );
|
||||
|
||||
int config_set_vals( ConfigTable *ct, ConfigArgs *c );
|
||||
int config_add_vals( ConfigTable *ct, ConfigArgs *c );
|
||||
int lload_config_get_vals( ConfigTable *ct, ConfigArgs *c );
|
||||
int lload_config_add_vals( ConfigTable *ct, ConfigArgs *c );
|
||||
|
||||
int config_push_cleanup( ConfigArgs *c, ConfigDriver *cleanup );
|
||||
|
||||
void init_config_argv( ConfigArgs *c );
|
||||
int read_config_file( const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft );
|
||||
void lload_init_config_argv( ConfigArgs *c );
|
||||
int lload_read_config_file( const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft );
|
||||
|
||||
ConfigTable *config_find_keyword( ConfigTable *ct, ConfigArgs *c );
|
||||
ConfigTable *lload_config_find_keyword( ConfigTable *ct, ConfigArgs *c );
|
||||
|
||||
Listener *config_check_my_url( const char *url, LDAPURLDesc *lud );
|
||||
LloadListener *lload_config_check_my_url( const char *url, LDAPURLDesc *lud );
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
|
@ -37,13 +37,13 @@
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
static ldap_pvt_thread_mutex_t conn_nextid_mutex;
|
||||
static unsigned long conn_nextid = 0;
|
||||
|
||||
static void
|
||||
connection_assign_nextid( Connection *conn )
|
||||
lload_connection_assign_nextid( LloadConnection *conn )
|
||||
{
|
||||
ldap_pvt_thread_mutex_lock( &conn_nextid_mutex );
|
||||
conn->c_connid = conn_nextid++;
|
||||
@ -55,7 +55,7 @@ connection_assign_nextid( Connection *conn )
|
||||
* received.
|
||||
*
|
||||
* We run c->c_pdu_cb for each pdu, stopping once we hit an error, have to wait
|
||||
* on reading or after we process slap_conn_max_pdus_per_cycle pdus so as to
|
||||
* on reading or after we process lload_conn_max_pdus_per_cycle pdus so as to
|
||||
* maintain fairness and not hog the worker thread forever.
|
||||
*
|
||||
* If we've run out of pdus immediately available from the stream or hit the
|
||||
@ -69,7 +69,7 @@ connection_assign_nextid( Connection *conn )
|
||||
static void *
|
||||
handle_pdus( void *ctx, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
LloadConnection *c = arg;
|
||||
int pdus_handled = 0;
|
||||
|
||||
CONNECTION_LOCK_DECREF(c);
|
||||
@ -87,7 +87,7 @@ handle_pdus( void *ctx, void *arg )
|
||||
}
|
||||
/* Otherwise, handle_one_request leaves the connection locked */
|
||||
|
||||
if ( ++pdus_handled >= slap_conn_max_pdus_per_cycle ) {
|
||||
if ( ++pdus_handled >= lload_conn_max_pdus_per_cycle ) {
|
||||
/* Do not read now, re-enable read event instead */
|
||||
break;
|
||||
}
|
||||
@ -146,7 +146,7 @@ handle_pdus( void *ctx, void *arg )
|
||||
void
|
||||
connection_read_cb( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
LloadConnection *c = arg;
|
||||
BerElement *ber;
|
||||
ber_tag_t tag;
|
||||
ber_len_t len;
|
||||
@ -219,7 +219,7 @@ connection_read_cb( evutil_socket_t s, short what, void *arg )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !slap_conn_max_pdus_per_cycle ||
|
||||
if ( !lload_conn_max_pdus_per_cycle ||
|
||||
ldap_pvt_thread_pool_submit( &connection_pool, handle_pdus, c ) ) {
|
||||
/* If we're overloaded or configured as such, process one and resume in
|
||||
* the next cycle.
|
||||
@ -247,7 +247,7 @@ connection_read_cb( evutil_socket_t s, short what, void *arg )
|
||||
void
|
||||
connection_write_cb( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
LloadConnection *c = arg;
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
if ( !c->c_live ) {
|
||||
@ -296,7 +296,7 @@ connection_write_cb( evutil_socket_t s, short what, void *arg )
|
||||
}
|
||||
|
||||
void
|
||||
connection_destroy( Connection *c )
|
||||
connection_destroy( LloadConnection *c )
|
||||
{
|
||||
assert( c );
|
||||
Debug( LDAP_DEBUG_CONNS, "connection_destroy: "
|
||||
@ -328,15 +328,15 @@ connection_destroy( Connection *c )
|
||||
listeners_reactivate();
|
||||
}
|
||||
|
||||
Connection *
|
||||
connection_init( ber_socket_t s, const char *peername, int flags )
|
||||
LloadConnection *
|
||||
lload_connection_init( ber_socket_t s, const char *peername, int flags )
|
||||
{
|
||||
Connection *c;
|
||||
LloadConnection *c;
|
||||
|
||||
assert( peername != NULL );
|
||||
|
||||
if ( s == AC_SOCKET_INVALID ) {
|
||||
Debug( LDAP_DEBUG_ANY, "connection_init: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_connection_init: "
|
||||
"init of socket fd=%ld invalid\n",
|
||||
(long)s );
|
||||
return NULL;
|
||||
@ -344,7 +344,7 @@ connection_init( ber_socket_t s, const char *peername, int flags )
|
||||
|
||||
assert( s >= 0 );
|
||||
|
||||
c = ch_calloc( 1, sizeof(Connection) );
|
||||
c = ch_calloc( 1, sizeof(LloadConnection) );
|
||||
|
||||
c->c_fd = s;
|
||||
c->c_sb = ber_sockbuf_alloc();
|
||||
@ -383,9 +383,9 @@ connection_init( ber_socket_t s, const char *peername, int flags )
|
||||
ldap_pvt_thread_mutex_init( &c->c_mutex );
|
||||
ldap_pvt_thread_mutex_init( &c->c_io_mutex );
|
||||
|
||||
connection_assign_nextid( c );
|
||||
lload_connection_assign_nextid( c );
|
||||
|
||||
Debug( LDAP_DEBUG_CONNS, "connection_init: "
|
||||
Debug( LDAP_DEBUG_CONNS, "lload_connection_init: "
|
||||
"connection connid=%lu allocated for socket fd=%d peername=%s\n",
|
||||
c->c_connid, s, peername );
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <event2/dns.h>
|
||||
#include <event2/listener.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
#include "ldap_pvt_thread.h"
|
||||
#include "lutil.h"
|
||||
|
||||
@ -69,8 +69,8 @@ struct runqueue_s slapd_rq;
|
||||
#ifndef SLAPD_MAX_DAEMON_THREADS
|
||||
#define SLAPD_MAX_DAEMON_THREADS 16
|
||||
#endif
|
||||
int slapd_daemon_threads = 1;
|
||||
int slapd_daemon_mask;
|
||||
int lload_daemon_threads = 1;
|
||||
int lload_daemon_mask;
|
||||
|
||||
#ifdef LDAP_TCP_BUFFER
|
||||
int slapd_tcp_rmem;
|
||||
@ -78,7 +78,7 @@ int slapd_tcp_wmem;
|
||||
#endif /* LDAP_TCP_BUFFER */
|
||||
|
||||
struct event_base *listener_base = NULL;
|
||||
Listener **slap_listeners = NULL;
|
||||
LloadListener **lload_listeners = NULL;
|
||||
static ldap_pvt_thread_t listener_tid, *daemon_tid;
|
||||
|
||||
struct evdns_base *dnsbase;
|
||||
@ -89,7 +89,7 @@ struct event *lload_timeout_event;
|
||||
#define SLAPD_LISTEN_BACKLOG 1024
|
||||
#endif /* ! SLAPD_LISTEN_BACKLOG */
|
||||
|
||||
#define DAEMON_ID(fd) ( fd & slapd_daemon_mask )
|
||||
#define DAEMON_ID(fd) ( fd & lload_daemon_mask )
|
||||
|
||||
static int emfile;
|
||||
|
||||
@ -97,7 +97,7 @@ static volatile int waking;
|
||||
#define WAKE_DAEMON( l, w ) \
|
||||
do { \
|
||||
if ( w ) { \
|
||||
event_active( slap_daemon[l].wakeup_event, EV_WRITE, 0 ); \
|
||||
event_active( lload_daemon[l].wakeup_event, EV_WRITE, 0 ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@ -123,28 +123,28 @@ typedef struct listener_item {
|
||||
ber_socket_t fd;
|
||||
} listener_item;
|
||||
|
||||
typedef struct slap_daemon_st {
|
||||
typedef struct lload_daemon_st {
|
||||
ldap_pvt_thread_mutex_t sd_mutex;
|
||||
|
||||
struct event_base *base;
|
||||
struct event *wakeup_event;
|
||||
} slap_daemon_st;
|
||||
} lload_daemon_st;
|
||||
|
||||
static slap_daemon_st slap_daemon[SLAPD_MAX_DAEMON_THREADS];
|
||||
static lload_daemon_st lload_daemon[SLAPD_MAX_DAEMON_THREADS];
|
||||
|
||||
static void daemon_wakeup_cb( evutil_socket_t sig, short what, void *arg );
|
||||
|
||||
static void
|
||||
slapd_close( ber_socket_t s )
|
||||
lloadd_close( ber_socket_t s )
|
||||
{
|
||||
Debug( LDAP_DEBUG_CONNS, "slapd_close: "
|
||||
Debug( LDAP_DEBUG_CONNS, "lloadd_close: "
|
||||
"closing fd=%ld\n",
|
||||
(long)s );
|
||||
tcp_close( s );
|
||||
}
|
||||
|
||||
static void
|
||||
slap_free_listener_addresses( struct sockaddr **sal )
|
||||
lload_free_listener_addresses( struct sockaddr **sal )
|
||||
{
|
||||
struct sockaddr **sap;
|
||||
if ( sal == NULL ) return;
|
||||
@ -230,7 +230,7 @@ get_url_perms( char **exts, mode_t *perms, int *crit )
|
||||
|
||||
/* port = 0 indicates AF_LOCAL */
|
||||
static int
|
||||
slap_get_listener_addresses(
|
||||
lload_get_listener_addresses(
|
||||
const char *host,
|
||||
unsigned short port,
|
||||
struct sockaddr ***sal )
|
||||
@ -246,7 +246,7 @@ slap_get_listener_addresses(
|
||||
|
||||
if ( strlen( host ) >
|
||||
( sizeof( ((struct sockaddr_un *)*sap)->sun_path ) - 1 ) ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_get_listener_addresses: "
|
||||
"domain socket path (%s) too long in URL\n",
|
||||
host );
|
||||
goto errexit;
|
||||
@ -269,7 +269,7 @@ slap_get_listener_addresses(
|
||||
snprintf( serv, sizeof(serv), "%d", port );
|
||||
|
||||
if ( (err = getaddrinfo( host, serv, &hints, &res )) ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_get_listener_addresses: "
|
||||
"getaddrinfo() failed: %s\n",
|
||||
AC_GAI_STRERROR(err) );
|
||||
return -1;
|
||||
@ -285,7 +285,7 @@ slap_get_listener_addresses(
|
||||
|
||||
for ( sai = res; sai; sai = sai->ai_next ) {
|
||||
if ( sai->ai_addr == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_get_listener_addresses: "
|
||||
"getaddrinfo ai_addr is NULL?\n" );
|
||||
freeaddrinfo( res );
|
||||
goto errexit;
|
||||
@ -329,7 +329,7 @@ slap_get_listener_addresses(
|
||||
} else if ( !inet_aton( host, &in ) ) {
|
||||
he = gethostbyname( host );
|
||||
if ( he == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_get_listener_addresses: "
|
||||
"invalid host %s\n",
|
||||
host );
|
||||
return -1;
|
||||
@ -354,16 +354,16 @@ slap_get_listener_addresses(
|
||||
return 0;
|
||||
|
||||
errexit:
|
||||
slap_free_listener_addresses(*sal);
|
||||
lload_free_listener_addresses(*sal);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
lload_open_listener( const char *url, int *listeners, int *cur )
|
||||
{
|
||||
int num, tmp, rc;
|
||||
Listener l;
|
||||
Listener *li;
|
||||
LloadListener l;
|
||||
LloadListener *li;
|
||||
LDAPURLDesc *lud;
|
||||
unsigned short port;
|
||||
int err, addrlen = 0;
|
||||
@ -382,7 +382,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
rc = ldap_url_parse( url, &lud );
|
||||
|
||||
if ( rc != LDAP_URL_SUCCESS ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"listen URL \"%s\" parse error=%d\n",
|
||||
url, rc );
|
||||
return rc;
|
||||
@ -394,7 +394,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
|
||||
#ifndef HAVE_TLS
|
||||
if ( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"TLS not supported (%s)\n",
|
||||
url );
|
||||
ldap_free_urldesc( lud );
|
||||
@ -422,13 +422,13 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
if ( tmp == LDAP_PROTO_IPC ) {
|
||||
#ifdef LDAP_PF_LOCAL
|
||||
if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ) {
|
||||
err = slap_get_listener_addresses( LDAPI_SOCK, 0, &sal );
|
||||
err = lload_get_listener_addresses( LDAPI_SOCK, 0, &sal );
|
||||
} else {
|
||||
err = slap_get_listener_addresses( lud->lud_host, 0, &sal );
|
||||
err = lload_get_listener_addresses( lud->lud_host, 0, &sal );
|
||||
}
|
||||
#else /* ! LDAP_PF_LOCAL */
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"URL scheme not supported: %s\n",
|
||||
url );
|
||||
ldap_free_urldesc( lud );
|
||||
@ -437,9 +437,9 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
} else {
|
||||
if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ||
|
||||
strcmp( lud->lud_host, "*" ) == 0 ) {
|
||||
err = slap_get_listener_addresses( NULL, port, &sal );
|
||||
err = lload_get_listener_addresses( NULL, port, &sal );
|
||||
} else {
|
||||
err = slap_get_listener_addresses( lud->lud_host, port, &sal );
|
||||
err = lload_get_listener_addresses( lud->lud_host, port, &sal );
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,18 +453,18 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
|
||||
ldap_free_urldesc( lud );
|
||||
if ( err ) {
|
||||
slap_free_listener_addresses( sal );
|
||||
lload_free_listener_addresses( sal );
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we got more than one address returned, we need to make space
|
||||
* for it in the slap_listeners array.
|
||||
* for it in the lload_listeners array.
|
||||
*/
|
||||
for ( num = 0; sal[num]; num++ ) /* empty */;
|
||||
if ( num > 1 ) {
|
||||
*listeners += num - 1;
|
||||
slap_listeners = ch_realloc(
|
||||
slap_listeners, ( *listeners + 1 ) * sizeof(Listener *) );
|
||||
lload_listeners = ch_realloc( lload_listeners,
|
||||
( *listeners + 1 ) * sizeof(LloadListener *) );
|
||||
}
|
||||
|
||||
psal = sal;
|
||||
@ -492,7 +492,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
s = socket( (*sal)->sa_family, socktype, 0 );
|
||||
if ( s == AC_SOCKET_INVALID ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"%s socket() failed errno=%d (%s)\n",
|
||||
af, err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
sal++;
|
||||
@ -514,7 +514,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
s, SOL_SOCKET, SO_REUSEADDR, (char *)&tmp, sizeof(tmp) );
|
||||
if ( rc == AC_SOCKET_ERROR ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener(%ld): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener(%ld): "
|
||||
"setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
|
||||
(long)l.sl_sd, err,
|
||||
sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
@ -535,7 +535,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
sizeof(tmp) );
|
||||
if ( rc == AC_SOCKET_ERROR ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener(%ld): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener(%ld): "
|
||||
"setsockopt(IPV6_V6ONLY) failed errno=%d (%s)\n",
|
||||
(long)l.sl_sd, err,
|
||||
sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
@ -583,7 +583,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
#endif /* LDAP_PF_LOCAL */
|
||||
if ( rc ) {
|
||||
err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"bind(%ld) failed errno=%d (%s)\n",
|
||||
(long)l.sl_sd, err,
|
||||
sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
@ -641,7 +641,7 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
#endif /* LDAP_PF_INET6 */
|
||||
|
||||
default:
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"unsupported address family (%d)\n",
|
||||
(int)(*sal)->sa_family );
|
||||
break;
|
||||
@ -649,23 +649,23 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
|
||||
AC_MEMCPY( &l.sl_sa, *sal, addrlen );
|
||||
ber_str2bv( url, 0, 1, &l.sl_url );
|
||||
li = ch_malloc( sizeof(Listener) );
|
||||
li = ch_malloc( sizeof(LloadListener) );
|
||||
*li = l;
|
||||
slap_listeners[*cur] = li;
|
||||
lload_listeners[*cur] = li;
|
||||
(*cur)++;
|
||||
sal++;
|
||||
}
|
||||
|
||||
slap_free_listener_addresses( psal );
|
||||
lload_free_listener_addresses( psal );
|
||||
|
||||
if ( l.sl_url.bv_val == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_open_listener: "
|
||||
"failed on %s\n",
|
||||
url );
|
||||
return -1;
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "slap_open_listener: "
|
||||
Debug( LDAP_DEBUG_TRACE, "lload_open_listener: "
|
||||
"listener initialized %s\n",
|
||||
l.sl_url.bv_val );
|
||||
|
||||
@ -675,12 +675,12 @@ slap_open_listener( const char *url, int *listeners, int *cur )
|
||||
int lloadd_inited = 0;
|
||||
|
||||
int
|
||||
slapd_daemon_init( const char *urls )
|
||||
lloadd_daemon_init( const char *urls )
|
||||
{
|
||||
int i, j, n;
|
||||
char **u;
|
||||
|
||||
Debug( LDAP_DEBUG_ARGS, "slapd_daemon_init: %s\n",
|
||||
Debug( LDAP_DEBUG_ARGS, "lloadd_daemon_init: %s\n",
|
||||
urls ? urls : "<null>" );
|
||||
|
||||
#ifdef HAVE_TCPD
|
||||
@ -692,7 +692,7 @@ slapd_daemon_init( const char *urls )
|
||||
u = ldap_str2charray( urls, " " );
|
||||
|
||||
if ( u == NULL || u[0] == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_daemon_init: "
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd_daemon_init: "
|
||||
"no urls (%s) provided\n",
|
||||
urls );
|
||||
if ( u ) ldap_charray_free( u );
|
||||
@ -700,33 +700,33 @@ slapd_daemon_init( const char *urls )
|
||||
}
|
||||
|
||||
for ( i = 0; u[i] != NULL; i++ ) {
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd_daemon_init: "
|
||||
Debug( LDAP_DEBUG_TRACE, "lloadd_daemon_init: "
|
||||
"listen on %s\n",
|
||||
u[i] );
|
||||
}
|
||||
|
||||
if ( i == 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_daemon_init: "
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd_daemon_init: "
|
||||
"no listeners to open (%s)\n",
|
||||
urls );
|
||||
ldap_charray_free( u );
|
||||
return -1;
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd_daemon_init: "
|
||||
Debug( LDAP_DEBUG_TRACE, "lloadd_daemon_init: "
|
||||
"%d listeners to open...\n",
|
||||
i );
|
||||
slap_listeners = ch_malloc( ( i + 1 ) * sizeof(Listener *) );
|
||||
lload_listeners = ch_malloc( ( i + 1 ) * sizeof(LloadListener *) );
|
||||
|
||||
for ( n = 0, j = 0; u[n]; n++ ) {
|
||||
if ( slap_open_listener( u[n], &i, &j ) ) {
|
||||
if ( lload_open_listener( u[n], &i, &j ) ) {
|
||||
ldap_charray_free( u );
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
slap_listeners[j] = NULL;
|
||||
lload_listeners[j] = NULL;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd_daemon_init: "
|
||||
Debug( LDAP_DEBUG_TRACE, "lloadd_daemon_init: "
|
||||
"%d listeners opened\n",
|
||||
i );
|
||||
|
||||
@ -736,18 +736,18 @@ slapd_daemon_init( const char *urls )
|
||||
}
|
||||
|
||||
int
|
||||
slapd_daemon_destroy( void )
|
||||
lloadd_daemon_destroy( void )
|
||||
{
|
||||
if ( lloadd_inited ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < slapd_daemon_threads; i++ ) {
|
||||
ldap_pvt_thread_mutex_destroy( &slap_daemon[i].sd_mutex );
|
||||
if ( slap_daemon[i].wakeup_event ) {
|
||||
event_free( slap_daemon[i].wakeup_event );
|
||||
for ( i = 0; i < lload_daemon_threads; i++ ) {
|
||||
ldap_pvt_thread_mutex_destroy( &lload_daemon[i].sd_mutex );
|
||||
if ( lload_daemon[i].wakeup_event ) {
|
||||
event_free( lload_daemon[i].wakeup_event );
|
||||
}
|
||||
if ( slap_daemon[i].base ) {
|
||||
event_base_free( slap_daemon[i].base );
|
||||
if ( lload_daemon[i].base ) {
|
||||
event_base_free( lload_daemon[i].base );
|
||||
}
|
||||
}
|
||||
lloadd_inited = 0;
|
||||
@ -762,7 +762,7 @@ slapd_daemon_destroy( void )
|
||||
static void
|
||||
destroy_listeners( void )
|
||||
{
|
||||
Listener *lr, **ll = slap_listeners;
|
||||
LloadListener *lr, **ll = lload_listeners;
|
||||
|
||||
if ( ll == NULL ) return;
|
||||
|
||||
@ -788,8 +788,8 @@ destroy_listeners( void )
|
||||
free( lr );
|
||||
}
|
||||
|
||||
free( slap_listeners );
|
||||
slap_listeners = NULL;
|
||||
free( lload_listeners );
|
||||
lload_listeners = NULL;
|
||||
|
||||
if ( listener_base ) {
|
||||
event_base_free( listener_base );
|
||||
@ -797,15 +797,15 @@ destroy_listeners( void )
|
||||
}
|
||||
|
||||
static void
|
||||
slap_listener(
|
||||
lload_listener(
|
||||
struct evconnlistener *listener,
|
||||
ber_socket_t s,
|
||||
struct sockaddr *a,
|
||||
int len,
|
||||
void *arg )
|
||||
{
|
||||
Listener *sl = arg;
|
||||
Connection *c;
|
||||
LloadListener *sl = arg;
|
||||
LloadConnection *c;
|
||||
Sockaddr *from = (Sockaddr *)a;
|
||||
#ifdef SLAPD_RLOOKUPS
|
||||
char hbuf[NI_MAXHOST];
|
||||
@ -829,7 +829,7 @@ slap_listener(
|
||||
int tid;
|
||||
char ebuf[128];
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, ">>> slap_listener(%s)\n", sl->sl_url.bv_val );
|
||||
Debug( LDAP_DEBUG_TRACE, ">>> lload_listener(%s)\n", sl->sl_url.bv_val );
|
||||
|
||||
peername[0] = '\0';
|
||||
|
||||
@ -840,7 +840,7 @@ slap_listener(
|
||||
|
||||
tid = DAEMON_ID(s);
|
||||
|
||||
Debug( LDAP_DEBUG_CONNS, "slap_listener: "
|
||||
Debug( LDAP_DEBUG_CONNS, "lload_listener: "
|
||||
"listen=%ld, new connection fd=%ld\n",
|
||||
(long)sl->sl_sd, (long)s );
|
||||
|
||||
@ -859,7 +859,7 @@ slap_listener(
|
||||
s, SOL_SOCKET, SO_KEEPALIVE, (char *)&tmp, sizeof(tmp) );
|
||||
if ( rc == AC_SOCKET_ERROR ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener(%ld): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener(%ld): "
|
||||
"setsockopt(SO_KEEPALIVE) failed errno=%d (%s)\n",
|
||||
(long)s, err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
@ -871,7 +871,7 @@ slap_listener(
|
||||
s, IPPROTO_TCP, TCP_NODELAY, (char *)&tmp, sizeof(tmp) );
|
||||
if ( rc == AC_SOCKET_ERROR ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener(%ld): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener(%ld): "
|
||||
"setsockopt(TCP_NODELAY) failed errno=%d (%s)\n",
|
||||
(long)s, err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
@ -928,30 +928,30 @@ slap_listener(
|
||||
} break;
|
||||
|
||||
default:
|
||||
slapd_close( s );
|
||||
lloadd_close( s );
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TLS
|
||||
if ( sl->sl_is_tls ) cflag |= CONN_IS_TLS;
|
||||
#endif
|
||||
c = client_init( s, sl, peername, slap_daemon[tid].base, cflag );
|
||||
c = client_init( s, sl, peername, lload_daemon[tid].base, cflag );
|
||||
|
||||
if ( !c ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener: "
|
||||
"client_init(%ld, %s, %s) failed\n",
|
||||
(long)s, peername, sl->sl_name.bv_val );
|
||||
slapd_close( s );
|
||||
lloadd_close( s );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void *
|
||||
slap_listener_thread( void *ctx )
|
||||
lload_listener_thread( void *ctx )
|
||||
{
|
||||
int rc = event_base_dispatch( listener_base );
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener_thread: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_thread: "
|
||||
"event loop finished: rc=%d\n",
|
||||
rc );
|
||||
|
||||
@ -961,7 +961,7 @@ slap_listener_thread( void *ctx )
|
||||
static void
|
||||
listener_error_cb( struct evconnlistener *lev, void *arg )
|
||||
{
|
||||
Listener *l = arg;
|
||||
LloadListener *l = arg;
|
||||
int err = EVUTIL_SOCKET_ERROR();
|
||||
|
||||
assert( l->listener == lev );
|
||||
@ -973,12 +973,12 @@ listener_error_cb( struct evconnlistener *lev, void *arg )
|
||||
err == ENFILE ||
|
||||
#endif /* ENFILE */
|
||||
0 ) {
|
||||
ldap_pvt_thread_mutex_lock( &slap_daemon[0].sd_mutex );
|
||||
ldap_pvt_thread_mutex_lock( &lload_daemon[0].sd_mutex );
|
||||
emfile++;
|
||||
/* Stop listening until an existing session closes */
|
||||
l->sl_mute = 1;
|
||||
evconnlistener_disable( lev );
|
||||
ldap_pvt_thread_mutex_unlock( &slap_daemon[0].sd_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_daemon[0].sd_mutex );
|
||||
Debug( LDAP_DEBUG_ANY, "listener_error_cb: "
|
||||
"too many open files, cannot accept new connections on "
|
||||
"url=%s\n",
|
||||
@ -997,9 +997,9 @@ listeners_reactivate( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &slap_daemon[0].sd_mutex );
|
||||
for ( i = 0; emfile && slap_listeners[i] != NULL; i++ ) {
|
||||
Listener *lr = slap_listeners[i];
|
||||
ldap_pvt_thread_mutex_lock( &lload_daemon[0].sd_mutex );
|
||||
for ( i = 0; emfile && lload_listeners[i] != NULL; i++ ) {
|
||||
LloadListener *lr = lload_listeners[i];
|
||||
|
||||
if ( lr->sl_sd == AC_SOCKET_INVALID ) continue;
|
||||
if ( lr->sl_mute ) {
|
||||
@ -1011,16 +1011,16 @@ listeners_reactivate( void )
|
||||
lr->sl_url.bv_val );
|
||||
}
|
||||
}
|
||||
if ( emfile && slap_listeners[i] == NULL ) {
|
||||
if ( emfile && lload_listeners[i] == NULL ) {
|
||||
/* Walked the entire list without enabling anything; emfile
|
||||
* counter is stale. Reset it. */
|
||||
emfile = 0;
|
||||
}
|
||||
ldap_pvt_thread_mutex_unlock( &slap_daemon[0].sd_mutex );
|
||||
ldap_pvt_thread_mutex_unlock( &lload_daemon[0].sd_mutex );
|
||||
}
|
||||
|
||||
static int
|
||||
slap_listener_activate( void )
|
||||
lload_listener_activate( void )
|
||||
{
|
||||
struct evconnlistener *listener;
|
||||
int l, rc;
|
||||
@ -1029,8 +1029,8 @@ slap_listener_activate( void )
|
||||
listener_base = event_base_new();
|
||||
if ( !listener_base ) return -1;
|
||||
|
||||
for ( l = 0; slap_listeners[l] != NULL; l++ ) {
|
||||
if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID ) continue;
|
||||
for ( l = 0; lload_listeners[l] != NULL; l++ ) {
|
||||
if ( lload_listeners[l]->sl_sd == AC_SOCKET_INVALID ) continue;
|
||||
|
||||
/* FIXME: TCP-only! */
|
||||
#ifdef LDAP_TCP_BUFFER
|
||||
@ -1039,107 +1039,107 @@ slap_listener_activate( void )
|
||||
socklen_t optlen;
|
||||
|
||||
size = 0;
|
||||
if ( slap_listeners[l]->sl_tcp_rmem > 0 ) {
|
||||
size = slap_listeners[l]->sl_tcp_rmem;
|
||||
if ( lload_listeners[l]->sl_tcp_rmem > 0 ) {
|
||||
size = lload_listeners[l]->sl_tcp_rmem;
|
||||
} else if ( slapd_tcp_rmem > 0 ) {
|
||||
size = slapd_tcp_rmem;
|
||||
}
|
||||
|
||||
if ( size > 0 ) {
|
||||
optlen = sizeof(origsize);
|
||||
rc = getsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = getsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_RCVBUF, (void *)&origsize, &optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"getsockopt(SO_RCVBUF) failed errno=%d (%s)\n",
|
||||
err, AC_STRERROR_R( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
optlen = sizeof(size);
|
||||
rc = setsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = setsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_RCVBUF, (const void *)&size, optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"setsockopt(SO_RCVBUF) failed errno=%d (%s)\n",
|
||||
err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
optlen = sizeof(realsize);
|
||||
rc = getsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = getsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_RCVBUF, (void *)&realsize, &optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"getsockopt(SO_RCVBUF) failed errno=%d (%s)\n",
|
||||
err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"url=%s (#%d) RCVBUF original size=%d requested "
|
||||
"size=%d real size=%d\n",
|
||||
slap_listeners[l]->sl_url.bv_val, l, origsize, size,
|
||||
lload_listeners[l]->sl_url.bv_val, l, origsize, size,
|
||||
realsize );
|
||||
}
|
||||
|
||||
size = 0;
|
||||
if ( slap_listeners[l]->sl_tcp_wmem > 0 ) {
|
||||
size = slap_listeners[l]->sl_tcp_wmem;
|
||||
if ( lload_listeners[l]->sl_tcp_wmem > 0 ) {
|
||||
size = lload_listeners[l]->sl_tcp_wmem;
|
||||
} else if ( slapd_tcp_wmem > 0 ) {
|
||||
size = slapd_tcp_wmem;
|
||||
}
|
||||
|
||||
if ( size > 0 ) {
|
||||
optlen = sizeof(origsize);
|
||||
rc = getsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = getsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_SNDBUF, (void *)&origsize, &optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"getsockopt(SO_SNDBUF) failed errno=%d (%s)\n",
|
||||
err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
optlen = sizeof(size);
|
||||
rc = setsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = setsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_SNDBUF, (const void *)&size, optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"setsockopt(SO_SNDBUF) failed errno=%d (%s)\n",
|
||||
err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
optlen = sizeof(realsize);
|
||||
rc = getsockopt( slap_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
rc = getsockopt( lload_listeners[l]->sl_sd, SOL_SOCKET,
|
||||
SO_SNDBUF, (void *)&realsize, &optlen );
|
||||
|
||||
if ( rc ) {
|
||||
int err = sock_errno();
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"getsockopt(SO_SNDBUF) failed errno=%d (%s)\n",
|
||||
err, sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
}
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"url=%s (#%d) SNDBUF original size=%d requested "
|
||||
"size=%d real size=%d\n",
|
||||
slap_listeners[l]->sl_url.bv_val, l, origsize, size,
|
||||
lload_listeners[l]->sl_url.bv_val, l, origsize, size,
|
||||
realsize );
|
||||
}
|
||||
}
|
||||
#endif /* LDAP_TCP_BUFFER */
|
||||
|
||||
slap_listeners[l]->sl_busy = 1;
|
||||
listener = evconnlistener_new( listener_base, slap_listener,
|
||||
slap_listeners[l], LEV_OPT_THREADSAFE, SLAPD_LISTEN_BACKLOG,
|
||||
slap_listeners[l]->sl_sd );
|
||||
lload_listeners[l]->sl_busy = 1;
|
||||
listener = evconnlistener_new( listener_base, lload_listener,
|
||||
lload_listeners[l], LEV_OPT_THREADSAFE, SLAPD_LISTEN_BACKLOG,
|
||||
lload_listeners[l]->sl_sd );
|
||||
if ( !listener ) {
|
||||
int err = sock_errno();
|
||||
|
||||
@ -1150,13 +1150,13 @@ slap_listener_activate( void )
|
||||
*/
|
||||
if ( err == EADDRINUSE ) {
|
||||
int i;
|
||||
struct sockaddr_in sa = slap_listeners[l]->sl_sa.sa_in_addr;
|
||||
struct sockaddr_in sa = lload_listeners[l]->sl_sa.sa_in_addr;
|
||||
struct sockaddr_in6 sa6;
|
||||
|
||||
if ( sa.sin_family == AF_INET &&
|
||||
sa.sin_addr.s_addr == htonl( INADDR_ANY ) ) {
|
||||
for ( i = 0; i < l; i++ ) {
|
||||
sa6 = slap_listeners[i]->sl_sa.sa_in6_addr;
|
||||
sa6 = lload_listeners[i]->sl_sa.sa_in6_addr;
|
||||
if ( sa6.sin6_family == AF_INET6 &&
|
||||
!memcmp( &sa6.sin6_addr, &in6addr_any,
|
||||
sizeof(struct in6_addr) ) ) {
|
||||
@ -1166,60 +1166,60 @@ slap_listener_activate( void )
|
||||
|
||||
if ( i < l ) {
|
||||
/* We are already listening to in6addr_any */
|
||||
Debug( LDAP_DEBUG_CONNS, "slap_listener_activate: "
|
||||
Debug( LDAP_DEBUG_CONNS, "lload_listener_activate: "
|
||||
"Attempt to listen to 0.0.0.0 failed, "
|
||||
"already listening on ::, assuming IPv4 "
|
||||
"included\n" );
|
||||
slapd_close( slap_listeners[l]->sl_sd );
|
||||
slap_listeners[l]->sl_sd = AC_SOCKET_INVALID;
|
||||
lloadd_close( lload_listeners[l]->sl_sd );
|
||||
lload_listeners[l]->sl_sd = AC_SOCKET_INVALID;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LDAP_PF_INET6 */
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener_activate: "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate: "
|
||||
"listen(%s, 5) failed errno=%d (%s)\n",
|
||||
slap_listeners[l]->sl_url.bv_val, err,
|
||||
lload_listeners[l]->sl_url.bv_val, err,
|
||||
sock_errstr( err, ebuf, sizeof(ebuf) ) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
slap_listeners[l]->base = listener_base;
|
||||
slap_listeners[l]->listener = listener;
|
||||
lload_listeners[l]->base = listener_base;
|
||||
lload_listeners[l]->listener = listener;
|
||||
evconnlistener_set_error_cb( listener, listener_error_cb );
|
||||
}
|
||||
|
||||
rc = ldap_pvt_thread_create(
|
||||
&listener_tid, 0, slap_listener_thread, slap_listeners[l] );
|
||||
&listener_tid, 0, lload_listener_thread, lload_listeners[l] );
|
||||
|
||||
if ( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slap_listener_activate(%d): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_listener_activate(%d): "
|
||||
"submit failed (%d)\n",
|
||||
slap_listeners[l]->sl_sd, rc );
|
||||
lload_listeners[l]->sl_sd, rc );
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void *
|
||||
slapd_daemon_task( void *ptr )
|
||||
lloadd_io_task( void *ptr )
|
||||
{
|
||||
int rc;
|
||||
int tid = (ldap_pvt_thread_t *)ptr - daemon_tid;
|
||||
struct event_base *base = slap_daemon[tid].base;
|
||||
struct event_base *base = lload_daemon[tid].base;
|
||||
struct event *event;
|
||||
|
||||
event = event_new( base, -1, EV_WRITE, daemon_wakeup_cb, ptr );
|
||||
if ( !event ) {
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_daemon_task: "
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd_io_task: "
|
||||
"failed to set up the wakeup event\n" );
|
||||
return (void *)-1;
|
||||
}
|
||||
event_add( event, NULL );
|
||||
slap_daemon[tid].wakeup_event = event;
|
||||
lload_daemon[tid].wakeup_event = event;
|
||||
|
||||
/* run */
|
||||
rc = event_base_dispatch( base );
|
||||
Debug( LDAP_DEBUG_ANY, "slapd_daemon_task: "
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd_io_task: "
|
||||
"Daemon %d, event loop finished: rc=%d\n",
|
||||
tid, rc );
|
||||
|
||||
@ -1231,10 +1231,10 @@ slapd_daemon_task( void *ptr )
|
||||
}
|
||||
|
||||
int
|
||||
slapd_daemon( struct event_base *daemon_base )
|
||||
lloadd_daemon( struct event_base *daemon_base )
|
||||
{
|
||||
int i, rc;
|
||||
Backend *b;
|
||||
LloadBackend *b;
|
||||
struct event_base *base;
|
||||
struct event *event;
|
||||
|
||||
@ -1249,25 +1249,25 @@ slapd_daemon( struct event_base *daemon_base )
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( slapd_daemon_threads > SLAPD_MAX_DAEMON_THREADS )
|
||||
slapd_daemon_threads = SLAPD_MAX_DAEMON_THREADS;
|
||||
if ( lload_daemon_threads > SLAPD_MAX_DAEMON_THREADS )
|
||||
lload_daemon_threads = SLAPD_MAX_DAEMON_THREADS;
|
||||
|
||||
daemon_tid =
|
||||
ch_malloc( slapd_daemon_threads * sizeof(ldap_pvt_thread_t) );
|
||||
ch_malloc( lload_daemon_threads * sizeof(ldap_pvt_thread_t) );
|
||||
|
||||
for ( i = 0; i < slapd_daemon_threads; i++ ) {
|
||||
for ( i = 0; i < lload_daemon_threads; i++ ) {
|
||||
base = event_base_new();
|
||||
if ( !base ) {
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd startup: "
|
||||
"failed to acquire event base for an I/O thread\n" );
|
||||
return -1;
|
||||
}
|
||||
slap_daemon[i].base = base;
|
||||
lload_daemon[i].base = base;
|
||||
|
||||
ldap_pvt_thread_mutex_init( &slap_daemon[i].sd_mutex );
|
||||
ldap_pvt_thread_mutex_init( &lload_daemon[i].sd_mutex );
|
||||
/* threads that handle client and upstream sockets */
|
||||
rc = ldap_pvt_thread_create(
|
||||
&daemon_tid[i], 0, slapd_daemon_task, &daemon_tid[i] );
|
||||
&daemon_tid[i], 0, lloadd_io_task, &daemon_tid[i] );
|
||||
|
||||
if ( rc != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "lloadd startup: "
|
||||
@ -1277,7 +1277,7 @@ slapd_daemon( struct event_base *daemon_base )
|
||||
}
|
||||
}
|
||||
|
||||
if ( (rc = slap_listener_activate()) != 0 ) {
|
||||
if ( (rc = lload_listener_activate()) != 0 ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1320,7 +1320,7 @@ slapd_daemon( struct event_base *daemon_base )
|
||||
/* wait for the listener threads to complete */
|
||||
destroy_listeners();
|
||||
|
||||
for ( i = 0; i < slapd_daemon_threads; i++ )
|
||||
for ( i = 0; i < lload_daemon_threads; i++ )
|
||||
ldap_pvt_thread_join( daemon_tid[i], (void *)NULL );
|
||||
|
||||
if ( LogTest( LDAP_DEBUG_ANY ) ) {
|
||||
@ -1332,13 +1332,13 @@ slapd_daemon( struct event_base *daemon_base )
|
||||
ldap_pvt_thread_pool_close( &connection_pool, 1 );
|
||||
backends_destroy();
|
||||
clients_destroy();
|
||||
bindconf_free( &bindconf );
|
||||
lload_bindconf_free( &bindconf );
|
||||
evdns_base_free( dnsbase, 0 );
|
||||
|
||||
ch_free( daemon_tid );
|
||||
daemon_tid = NULL;
|
||||
|
||||
slapd_daemon_destroy();
|
||||
lloadd_daemon_destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1352,12 +1352,12 @@ daemon_wakeup_cb( evutil_socket_t sig, short what, void *arg )
|
||||
"Daemon thread %d woken up\n",
|
||||
tid );
|
||||
if ( slapd_shutdown ) {
|
||||
event_base_loopexit( slap_daemon[tid].base, NULL );
|
||||
event_base_loopexit( lload_daemon[tid].base, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
slap_sig_shutdown( evutil_socket_t sig, short what, void *arg )
|
||||
lload_sig_shutdown( evutil_socket_t sig, short what, void *arg )
|
||||
{
|
||||
struct event_base *daemon_base = arg;
|
||||
int save_errno = errno;
|
||||
@ -1383,7 +1383,7 @@ slap_sig_shutdown( evutil_socket_t sig, short what, void *arg )
|
||||
slapd_shutdown = 1;
|
||||
}
|
||||
|
||||
for ( i = 0; i < slapd_daemon_threads; i++ ) {
|
||||
for ( i = 0; i < lload_daemon_threads; i++ ) {
|
||||
WAKE_DAEMON( i, 1 );
|
||||
}
|
||||
event_base_loopexit( daemon_base, NULL );
|
||||
@ -1392,42 +1392,42 @@ slap_sig_shutdown( evutil_socket_t sig, short what, void *arg )
|
||||
}
|
||||
|
||||
struct event_base *
|
||||
slap_get_base( ber_socket_t s )
|
||||
lload_get_base( ber_socket_t s )
|
||||
{
|
||||
int tid = DAEMON_ID(s);
|
||||
return slap_daemon[tid].base;
|
||||
return lload_daemon[tid].base;
|
||||
}
|
||||
|
||||
Listener **
|
||||
slapd_get_listeners( void )
|
||||
LloadListener **
|
||||
lloadd_get_listeners( void )
|
||||
{
|
||||
/* Could return array with no listeners if !listening, but current
|
||||
* callers mostly look at the URLs. E.g. syncrepl uses this to
|
||||
* identify the server, which means it wants the startup arguments.
|
||||
*/
|
||||
return slap_listeners;
|
||||
return lload_listeners;
|
||||
}
|
||||
|
||||
/* Reject all incoming requests */
|
||||
void
|
||||
slap_suspend_listeners( void )
|
||||
lload_suspend_listeners( void )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; slap_listeners[i]; i++ ) {
|
||||
slap_listeners[i]->sl_mute = 1;
|
||||
evconnlistener_disable( slap_listeners[i]->listener );
|
||||
listen( slap_listeners[i]->sl_sd, 0 );
|
||||
for ( i = 0; lload_listeners[i]; i++ ) {
|
||||
lload_listeners[i]->sl_mute = 1;
|
||||
evconnlistener_disable( lload_listeners[i]->listener );
|
||||
listen( lload_listeners[i]->sl_sd, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Resume after a suspend */
|
||||
void
|
||||
slap_resume_listeners( void )
|
||||
lload_resume_listeners( void )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; slap_listeners[i]; i++ ) {
|
||||
slap_listeners[i]->sl_mute = 0;
|
||||
listen( slap_listeners[i]->sl_sd, SLAPD_LISTEN_BACKLOG );
|
||||
evconnlistener_enable( slap_listeners[i]->listener );
|
||||
for ( i = 0; lload_listeners[i]; i++ ) {
|
||||
lload_listeners[i]->sl_mute = 0;
|
||||
listen( lload_listeners[i]->sl_sd, SLAPD_LISTEN_BACKLOG );
|
||||
evconnlistener_enable( lload_listeners[i]->listener );
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,15 @@
|
||||
#include <ac/string.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
Avlnode *lload_exop_handlers = NULL;
|
||||
|
||||
void *lload_tls_ctx;
|
||||
LDAP *lload_tls_ld, *lload_tls_backend_ld;
|
||||
|
||||
int
|
||||
handle_starttls( Connection *c, Operation *op )
|
||||
handle_starttls( LloadConnection *c, LloadOperation *op )
|
||||
{
|
||||
struct event_base *base = event_get_base( c->c_read_event );
|
||||
BerElement *output;
|
||||
@ -41,7 +44,7 @@ handle_starttls( Connection *c, Operation *op )
|
||||
} else if ( c->c_ops ) {
|
||||
rc = LDAP_OPERATIONS_ERROR;
|
||||
msg = "cannot start TLS when operations are outstanding";
|
||||
} else if ( !slap_tls_ctx ) {
|
||||
} else if ( !lload_tls_ctx ) {
|
||||
rc = LDAP_UNAVAILABLE;
|
||||
msg = "Could not initialize TLS";
|
||||
}
|
||||
@ -100,7 +103,7 @@ handle_starttls( Connection *c, Operation *op )
|
||||
}
|
||||
|
||||
int
|
||||
request_extended( Connection *c, Operation *op )
|
||||
request_extended( LloadConnection *c, LloadOperation *op )
|
||||
{
|
||||
ExopHandler *handler, needle = {};
|
||||
BerElement *copy;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
#include "lber_pvt.h"
|
||||
|
||||
#include "ldap_rq.h"
|
||||
@ -61,11 +61,11 @@ int connection_pool_max = SLAP_MAX_WORKER_THREADS;
|
||||
int connection_pool_queues = 1;
|
||||
int slap_tool_thread_max = 1;
|
||||
|
||||
static const char *slap_name = NULL;
|
||||
static const char *lload_name = NULL;
|
||||
int slapMode = SLAP_UNDEFINED_MODE;
|
||||
|
||||
int
|
||||
slap_init( int mode, const char *name )
|
||||
lload_init( int mode, const char *name )
|
||||
{
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
@ -89,7 +89,7 @@ slap_init( int mode, const char *name )
|
||||
"initiated server.\n",
|
||||
name );
|
||||
|
||||
slap_name = name;
|
||||
lload_name = name;
|
||||
|
||||
ldap_pvt_thread_pool_init_q( &connection_pool, connection_pool_max,
|
||||
0, connection_pool_queues );
|
||||
@ -119,13 +119,13 @@ slap_init( int mode, const char *name )
|
||||
}
|
||||
|
||||
int
|
||||
slap_destroy( void )
|
||||
lload_destroy( void )
|
||||
{
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "%s destroy: "
|
||||
"freeing system resources.\n",
|
||||
slap_name );
|
||||
lload_name );
|
||||
|
||||
ldap_pvt_thread_pool_free( &connection_pool );
|
||||
|
||||
@ -134,7 +134,7 @@ slap_destroy( void )
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug( LDAP_DEBUG_ANY, "slap_destroy(): "
|
||||
Debug( LDAP_DEBUG_ANY, "lload_destroy(): "
|
||||
"undefined mode (%d).\n",
|
||||
slapMode );
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <event2/event.h>
|
||||
#include <event2/thread.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
#include "ldap_pvt_thread.h"
|
||||
|
||||
static void *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* slap.h - stand alone ldap server include file */
|
||||
/* lload.h - load balancer include file */
|
||||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
@ -24,8 +24,8 @@
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef _SLAP_H_
|
||||
#define _SLAP_H_
|
||||
#ifndef _LLOAD_H_
|
||||
#define _LLOAD_H_
|
||||
|
||||
#include "ldap_defaults.h"
|
||||
|
||||
@ -42,6 +42,8 @@
|
||||
|
||||
#include "avl.h"
|
||||
|
||||
#include "../servers/slapd/slap.h"
|
||||
|
||||
#ifndef ldap_debug
|
||||
#define ldap_debug slap_debug
|
||||
#endif
|
||||
@ -60,179 +62,42 @@
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
/*
|
||||
* SLAPD Memory allocation macros
|
||||
*
|
||||
* Unlike ch_*() routines, these routines do not assert() upon
|
||||
* allocation error. They are intended to be used instead of
|
||||
* ch_*() routines where the caller has implemented proper
|
||||
* checking for and handling of allocation errors.
|
||||
*
|
||||
* Patches to convert ch_*() calls to SLAP_*() calls welcomed.
|
||||
*/
|
||||
#define SLAP_MALLOC(s) ber_memalloc( ( s ) )
|
||||
#define SLAP_CALLOC(n, s) ber_memcalloc( ( n ), ( s ) )
|
||||
#define SLAP_REALLOC(p, s) ber_memrealloc( ( p ), ( s ) )
|
||||
#define SLAP_FREE(p) ber_memfree( ( p ) )
|
||||
#define SLAP_VFREE(v) ber_memvfree( (void **)( v ) )
|
||||
#define SLAP_STRDUP(s) ber_strdup( ( s ) )
|
||||
#define SLAP_STRNDUP(s, l) ber_strndup( ( s ), ( l ) )
|
||||
#ifdef SERVICE_NAME
|
||||
#undef SERVICE_NAME
|
||||
#endif
|
||||
|
||||
#define SERVICE_NAME OPENLDAP_PACKAGE "-lloadd"
|
||||
#define SLAPD_ANONYMOUS ""
|
||||
#define SLAP_STRING_UNKNOWN "unknown"
|
||||
|
||||
#define SLAP_MAX_WORKER_THREADS ( 16 )
|
||||
|
||||
#define LLOAD_SB_MAX_INCOMING_CLIENT ( ( 1 << 18 ) - 1 )
|
||||
#define LLOAD_SB_MAX_INCOMING_CLIENT ( ( 1 << 24 ) - 1 )
|
||||
#define LLOAD_SB_MAX_INCOMING_UPSTREAM ( ( 1 << 24 ) - 1 )
|
||||
|
||||
#define LLOAD_CONN_MAX_PDUS_PER_CYCLE_DEFAULT 10
|
||||
|
||||
#define SLAP_TEXT_BUFLEN ( 256 )
|
||||
|
||||
/* unknown config file directive */
|
||||
#define SLAP_CONF_UNKNOWN ( -1026 )
|
||||
|
||||
#define BER_BV_OPTIONAL( bv ) ( BER_BVISNULL( bv ) ? NULL : ( bv ) )
|
||||
|
||||
LDAP_SLAPD_V (int) slap_debug;
|
||||
|
||||
typedef unsigned long slap_mask_t;
|
||||
|
||||
typedef struct Backend Backend;
|
||||
typedef struct PendingConnection PendingConnection;
|
||||
typedef struct Connection Connection;
|
||||
typedef struct Operation Operation;
|
||||
typedef struct LloadBackend LloadBackend;
|
||||
typedef struct LloadPendingConnection LloadPendingConnection;
|
||||
typedef struct LloadConnection LloadConnection;
|
||||
typedef struct LloadOperation LloadOperation;
|
||||
/* end of forward declarations */
|
||||
|
||||
typedef union Sockaddr {
|
||||
struct sockaddr sa_addr;
|
||||
struct sockaddr_in sa_in_addr;
|
||||
#ifdef LDAP_PF_INET6
|
||||
struct sockaddr_storage sa_storage;
|
||||
struct sockaddr_in6 sa_in6_addr;
|
||||
#endif
|
||||
#ifdef LDAP_PF_LOCAL
|
||||
struct sockaddr_un sa_un_addr;
|
||||
#endif
|
||||
} Sockaddr;
|
||||
typedef LDAP_CIRCLEQ_HEAD(BeSt, LloadBackend) lload_b_head;
|
||||
typedef LDAP_CIRCLEQ_HEAD(ConnSt, LloadConnection) lload_c_head;
|
||||
|
||||
#ifdef LDAP_PF_INET6
|
||||
extern int slap_inet4or6;
|
||||
#endif
|
||||
|
||||
typedef LDAP_CIRCLEQ_HEAD(BeSt, Backend) slap_b_head;
|
||||
typedef LDAP_CIRCLEQ_HEAD(ClientSt, Connection) slap_c_head;
|
||||
|
||||
LDAP_SLAPD_V (slap_b_head) backend;
|
||||
LDAP_SLAPD_V (slap_c_head) clients;
|
||||
LDAP_SLAPD_V (lload_b_head) backend;
|
||||
LDAP_SLAPD_V (lload_c_head) clients;
|
||||
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) backend_mutex;
|
||||
LDAP_SLAPD_V (Backend *) current_backend;
|
||||
LDAP_SLAPD_V (LloadBackend *) current_backend;
|
||||
LDAP_SLAPD_V (struct slap_bindconf) bindconf;
|
||||
LDAP_SLAPD_V (struct berval) lloadd_identity;
|
||||
|
||||
LDAP_SLAPD_V (int) slapMode;
|
||||
#define SLAP_UNDEFINED_MODE 0x0000
|
||||
#define SLAP_SERVER_MODE 0x0001
|
||||
#define SLAP_TOOL_MODE 0x0002
|
||||
#define SLAP_MODE 0x0003
|
||||
|
||||
#define SLAP_SERVER_RUNNING 0x8000
|
||||
|
||||
#define SB_TLS_DEFAULT ( -1 )
|
||||
#define SB_TLS_OFF 0
|
||||
#define SB_TLS_ON 1
|
||||
#define SB_TLS_CRITICAL 2
|
||||
|
||||
typedef struct slap_keepalive {
|
||||
int sk_idle;
|
||||
int sk_probes;
|
||||
int sk_interval;
|
||||
} slap_keepalive;
|
||||
|
||||
typedef struct slap_bindconf {
|
||||
struct berval sb_uri;
|
||||
int sb_version;
|
||||
int sb_tls;
|
||||
int sb_method;
|
||||
int sb_timeout_api;
|
||||
int sb_timeout_net;
|
||||
struct berval sb_binddn;
|
||||
struct berval sb_cred;
|
||||
struct berval sb_saslmech;
|
||||
char *sb_secprops;
|
||||
struct berval sb_realm;
|
||||
struct berval sb_authcId;
|
||||
struct berval sb_authzId;
|
||||
slap_keepalive sb_keepalive;
|
||||
#ifdef HAVE_TLS
|
||||
void *sb_tls_ctx;
|
||||
char *sb_tls_cert;
|
||||
char *sb_tls_key;
|
||||
char *sb_tls_cacert;
|
||||
char *sb_tls_cacertdir;
|
||||
char *sb_tls_reqcert;
|
||||
char *sb_tls_reqsan;
|
||||
char *sb_tls_cipher_suite;
|
||||
char *sb_tls_protocol_min;
|
||||
char *sb_tls_ecname;
|
||||
#ifdef HAVE_OPENSSL
|
||||
char *sb_tls_crlcheck;
|
||||
#endif
|
||||
int sb_tls_int_reqcert;
|
||||
int sb_tls_int_reqsan;
|
||||
int sb_tls_do_init;
|
||||
#endif
|
||||
} slap_bindconf;
|
||||
|
||||
typedef struct slap_verbmasks {
|
||||
struct berval word;
|
||||
const slap_mask_t mask;
|
||||
} slap_verbmasks;
|
||||
|
||||
typedef struct slap_cf_aux_table {
|
||||
struct berval key;
|
||||
int off;
|
||||
char type;
|
||||
char quote;
|
||||
void *aux;
|
||||
} slap_cf_aux_table;
|
||||
|
||||
typedef int slap_cf_aux_table_parse_x( struct berval *val,
|
||||
typedef int lload_cf_aux_table_parse_x( struct berval *val,
|
||||
void *bc,
|
||||
slap_cf_aux_table *tab0,
|
||||
const char *tabmsg,
|
||||
int unparse );
|
||||
|
||||
#define SLAP_RESTRICT_OP_ADD 0x0001U
|
||||
#define SLAP_RESTRICT_OP_BIND 0x0002U
|
||||
#define SLAP_RESTRICT_OP_COMPARE 0x0004U
|
||||
#define SLAP_RESTRICT_OP_DELETE 0x0008U
|
||||
#define SLAP_RESTRICT_OP_EXTENDED 0x0010U
|
||||
#define SLAP_RESTRICT_OP_MODIFY 0x0020U
|
||||
#define SLAP_RESTRICT_OP_RENAME 0x0040U
|
||||
#define SLAP_RESTRICT_OP_SEARCH 0x0080U
|
||||
#define SLAP_RESTRICT_OP_MASK 0x00FFU
|
||||
|
||||
#define SLAP_RESTRICT_READONLY 0x80000000U
|
||||
|
||||
#define SLAP_RESTRICT_EXOP_START_TLS 0x0100U
|
||||
#define SLAP_RESTRICT_EXOP_MODIFY_PASSWD 0x0200U
|
||||
#define SLAP_RESTRICT_EXOP_WHOAMI 0x0400U
|
||||
#define SLAP_RESTRICT_EXOP_CANCEL 0x0800U
|
||||
#define SLAP_RESTRICT_EXOP_MASK 0xFF00U
|
||||
|
||||
#define SLAP_RESTRICT_OP_READS \
|
||||
( SLAP_RESTRICT_OP_COMPARE | SLAP_RESTRICT_OP_SEARCH )
|
||||
#define SLAP_RESTRICT_OP_WRITES \
|
||||
( SLAP_RESTRICT_OP_ADD | SLAP_RESTRICT_OP_DELETE | SLAP_RESTRICT_OP_MODIFY | SLAP_RESTRICT_OP_RENAME )
|
||||
#define SLAP_RESTRICT_OP_ALL \
|
||||
( SLAP_RESTRICT_OP_READS | SLAP_RESTRICT_OP_WRITES | SLAP_RESTRICT_OP_BIND | SLAP_RESTRICT_OP_EXTENDED )
|
||||
|
||||
typedef struct config_reply_s ConfigReply; /* config.h */
|
||||
|
||||
typedef struct Listener Listener;
|
||||
typedef struct LloadListener LloadListener;
|
||||
|
||||
typedef enum {
|
||||
#ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS
|
||||
@ -249,17 +114,17 @@ enum lload_tls_type {
|
||||
LLOAD_TLS_ESTABLISHED,
|
||||
};
|
||||
|
||||
struct PendingConnection {
|
||||
Backend *backend;
|
||||
struct LloadPendingConnection {
|
||||
LloadBackend *backend;
|
||||
|
||||
struct event *event;
|
||||
ber_socket_t fd;
|
||||
|
||||
LDAP_LIST_ENTRY(PendingConnection) next;
|
||||
LDAP_LIST_ENTRY(LloadPendingConnection) next;
|
||||
};
|
||||
|
||||
/* Can hold mutex when locking a linked connection */
|
||||
struct Backend {
|
||||
struct LloadBackend {
|
||||
ldap_pvt_thread_mutex_t b_mutex;
|
||||
|
||||
struct berval b_uri;
|
||||
@ -273,25 +138,25 @@ struct Backend {
|
||||
|
||||
int b_numconns, b_numbindconns;
|
||||
int b_bindavail, b_active, b_opening;
|
||||
LDAP_CIRCLEQ_HEAD(ConnSt, Connection) b_conns, b_bindconns, b_preparing;
|
||||
LDAP_LIST_HEAD(ConnectingSt, PendingConnection) b_connecting;
|
||||
Connection *b_last_conn, *b_last_bindconn;
|
||||
lload_c_head b_conns, b_bindconns, b_preparing;
|
||||
LDAP_LIST_HEAD(ConnectingSt, LloadPendingConnection) b_connecting;
|
||||
LloadConnection *b_last_conn, *b_last_bindconn;
|
||||
|
||||
long b_max_pending, b_max_conn_pending;
|
||||
long b_n_ops_executing;
|
||||
|
||||
LDAP_CIRCLEQ_ENTRY(Backend) b_next;
|
||||
LDAP_CIRCLEQ_ENTRY(LloadBackend) b_next;
|
||||
};
|
||||
|
||||
typedef int (*OperationHandler)( Operation *op, BerElement *ber );
|
||||
typedef int (*RequestHandler)( Connection *c, Operation *op );
|
||||
typedef int (*LloadOperationHandler)( LloadOperation *op, BerElement *ber );
|
||||
typedef int (*RequestHandler)( LloadConnection *c, LloadOperation *op );
|
||||
typedef struct lload_exop_handlers_t {
|
||||
struct berval oid;
|
||||
RequestHandler func;
|
||||
} ExopHandler;
|
||||
|
||||
typedef int (*CONNECTION_PDU_CB)( Connection *c );
|
||||
typedef void (*CONNECTION_DESTROY_CB)( Connection *c );
|
||||
typedef int (*CONNECTION_PDU_CB)( LloadConnection *c );
|
||||
typedef void (*CONNECTION_DESTROY_CB)( LloadConnection *c );
|
||||
|
||||
/* connection state (protected by c_mutex) */
|
||||
enum sc_state {
|
||||
@ -310,16 +175,16 @@ enum sc_type {
|
||||
/*
|
||||
* represents a connection from an ldap client/to ldap server
|
||||
*/
|
||||
struct Connection {
|
||||
struct LloadConnection {
|
||||
enum sc_state c_state; /* connection state */
|
||||
enum sc_type c_type;
|
||||
ber_socket_t c_fd;
|
||||
|
||||
/*
|
||||
* Connection reference counting:
|
||||
* LloadConnection reference counting:
|
||||
* - connection has a reference counter in c_refcnt
|
||||
* - also a liveness/validity token is added to c_refcnt during
|
||||
* connection_init, its existence is tracked in c_live and is usually the
|
||||
* lload_connection_init, its existence is tracked in c_live and is usually the
|
||||
* only one that prevents it from being destroyed
|
||||
* - anyone who needs to be able to lock the connection after unlocking it has
|
||||
* to use CONNECTION_UNLOCK_INCREF, they are then responsible that
|
||||
@ -403,10 +268,6 @@ struct Connection {
|
||||
|
||||
TAvlnode *c_ops; /* Operations pending on the connection */
|
||||
|
||||
#define CONN_IS_TLS 1
|
||||
#define CONN_IS_BIND 4
|
||||
#define CONN_IS_IPC 8
|
||||
|
||||
#ifdef HAVE_TLS
|
||||
enum lload_tls_type c_is_tls; /* true if this LDAP over raw TLS */
|
||||
#endif
|
||||
@ -419,7 +280,7 @@ struct Connection {
|
||||
* - Client: clients_mutex
|
||||
* - Upstream: b->b_mutex
|
||||
*/
|
||||
LDAP_CIRCLEQ_ENTRY(Connection) c_next;
|
||||
LDAP_CIRCLEQ_ENTRY(LloadConnection) c_next;
|
||||
|
||||
void *c_private;
|
||||
};
|
||||
@ -436,13 +297,13 @@ enum op_state {
|
||||
#define LLOAD_OP_DETACHING_MASK \
|
||||
( LLOAD_OP_DETACHING_UPSTREAM | LLOAD_OP_DETACHING_CLIENT )
|
||||
|
||||
struct Operation {
|
||||
Connection *o_client;
|
||||
struct LloadOperation {
|
||||
LloadConnection *o_client;
|
||||
unsigned long o_client_connid;
|
||||
int o_client_live, o_client_refcnt;
|
||||
ber_int_t o_client_msgid;
|
||||
|
||||
Connection *o_upstream;
|
||||
LloadConnection *o_upstream;
|
||||
unsigned long o_upstream_connid;
|
||||
int o_upstream_live, o_upstream_refcnt;
|
||||
ber_int_t o_upstream_msgid;
|
||||
@ -463,34 +324,10 @@ struct Operation {
|
||||
BerValue o_request, o_ctrls;
|
||||
};
|
||||
|
||||
#ifdef LDAP_DEBUG
|
||||
#ifdef LDAP_SYSLOG
|
||||
#ifdef LOG_LOCAL4
|
||||
#define SLAP_DEFAULT_SYSLOG_USER LOG_LOCAL4
|
||||
#endif /* LOG_LOCAL4 */
|
||||
|
||||
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
|
||||
Log( (level), ldap_syslog_level, (fmt), (connid), (opid), \
|
||||
( arg1 ), ( arg2 ), ( arg3 ) )
|
||||
#define StatslogTest( level ) ( ( ldap_debug | ldap_syslog ) & ( level ) )
|
||||
#else /* !LDAP_SYSLOG */
|
||||
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
|
||||
do { \
|
||||
if ( ldap_debug & (level) ) \
|
||||
lutil_debug( ldap_debug, (level), (fmt), (connid), (opid), \
|
||||
( arg1 ), ( arg2 ), ( arg3 ) ); \
|
||||
} while (0)
|
||||
#define StatslogTest( level ) ( ldap_debug & ( level ) )
|
||||
#endif /* !LDAP_SYSLOG */
|
||||
#else /* !LDAP_DEBUG */
|
||||
#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) ( (void)0 )
|
||||
#define StatslogTest( level ) ( 0 )
|
||||
#endif /* !LDAP_DEBUG */
|
||||
|
||||
/*
|
||||
* listener; need to access it from monitor backend
|
||||
*/
|
||||
struct Listener {
|
||||
struct LloadListener {
|
||||
struct berval sl_url;
|
||||
struct berval sl_name;
|
||||
mode_t sl_perms;
|
||||
@ -513,6 +350,5 @@ struct Listener {
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#include "proto-slap.h"
|
||||
|
||||
#endif /* _SLAP_H_ */
|
||||
#include "proto-lload.h"
|
||||
#endif /* _LLOAD_H_ */
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include <event2/event.h>
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
#include "lutil.h"
|
||||
#include "ldif.h"
|
||||
|
||||
@ -71,25 +71,25 @@ struct signal_handler {
|
||||
event_callback_fn handler;
|
||||
struct event *event;
|
||||
} signal_handlers[] = {
|
||||
{ LDAP_SIGUSR2, slap_sig_shutdown },
|
||||
{ LDAP_SIGUSR2, lload_sig_shutdown },
|
||||
|
||||
#ifdef SIGPIPE
|
||||
{ SIGPIPE, sigpipe },
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
{ SIGHUP, slap_sig_shutdown },
|
||||
{ SIGHUP, lload_sig_shutdown },
|
||||
#endif
|
||||
{ SIGINT, slap_sig_shutdown },
|
||||
{ SIGTERM, slap_sig_shutdown },
|
||||
{ SIGINT, lload_sig_shutdown },
|
||||
{ SIGTERM, lload_sig_shutdown },
|
||||
#ifdef SIGTRAP
|
||||
{ SIGTRAP, slap_sig_shutdown },
|
||||
{ SIGTRAP, lload_sig_shutdown },
|
||||
#endif
|
||||
#ifdef LDAP_SIGCHLD
|
||||
{ LDAP_SIGCHLD, wait4child },
|
||||
#endif
|
||||
#ifdef SIGBREAK
|
||||
/* SIGBREAK is generated when Ctrl-Break is pressed. */
|
||||
{ SIGBREAK, slap_sig_shutdown },
|
||||
{ SIGBREAK, lload_sig_shutdown },
|
||||
#endif
|
||||
{ 0, NULL }
|
||||
};
|
||||
@ -110,9 +110,6 @@ const char Versionstr[] = OPENLDAP_PACKAGE
|
||||
static int check = CHECK_NONE;
|
||||
static int version = 0;
|
||||
|
||||
void *slap_tls_ctx;
|
||||
LDAP *slap_tls_ld, *slap_tls_backend_ld;
|
||||
|
||||
static int
|
||||
slapd_opt_slp( const char *val, void *arg )
|
||||
{
|
||||
@ -394,7 +391,7 @@ main( int argc, char **argv )
|
||||
char *regService = NULL;
|
||||
|
||||
if ( is_NT_Service ) {
|
||||
lutil_CommenceStartupProcessing( serverName, slap_sig_shutdown );
|
||||
lutil_CommenceStartupProcessing( serverName, lload_sig_shutdown );
|
||||
if ( strcmp( serverName, SERVICE_NAME ) ) regService = serverName;
|
||||
}
|
||||
|
||||
@ -636,7 +633,7 @@ unhandled_option:;
|
||||
|
||||
global_host = ldap_pvt_get_fqdn( NULL );
|
||||
|
||||
if ( check == CHECK_NONE && slapd_daemon_init( urls ) != 0 ) {
|
||||
if ( check == CHECK_NONE && lloadd_daemon_init( urls ) != 0 ) {
|
||||
rc = 1;
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
|
||||
goto stop;
|
||||
@ -669,12 +666,12 @@ unhandled_option:;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TLS
|
||||
rc = ldap_create( &slap_tls_backend_ld );
|
||||
rc = ldap_create( &lload_tls_backend_ld );
|
||||
if ( rc ) {
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
|
||||
goto destroy;
|
||||
}
|
||||
rc = ldap_create( &slap_tls_ld );
|
||||
rc = ldap_create( &lload_tls_ld );
|
||||
if ( rc ) {
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 20 );
|
||||
goto destroy;
|
||||
@ -686,16 +683,16 @@ unhandled_option:;
|
||||
*/
|
||||
rc = LDAP_OPT_X_TLS_NEVER;
|
||||
(void)ldap_pvt_tls_set_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
|
||||
#endif
|
||||
|
||||
rc = slap_init( serverMode, serverName );
|
||||
rc = lload_init( serverMode, serverName );
|
||||
if ( rc ) {
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 18 );
|
||||
goto destroy;
|
||||
}
|
||||
|
||||
if ( read_config( configfile, configdir ) != 0 ) {
|
||||
if ( lload_read_config( configfile, configdir ) != 0 ) {
|
||||
rc = 1;
|
||||
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
|
||||
|
||||
@ -750,11 +747,11 @@ unhandled_option:;
|
||||
|
||||
/* Force new ctx to be created */
|
||||
rc = ldap_pvt_tls_set_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_NEWCTX, &opt );
|
||||
if ( rc == 0 ) {
|
||||
/* The ctx's refcount is bumped up here */
|
||||
ldap_pvt_tls_get_option(
|
||||
slap_tls_ld, LDAP_OPT_X_TLS_CTX, &slap_tls_ctx );
|
||||
lload_tls_ld, LDAP_OPT_X_TLS_CTX, &lload_tls_ctx );
|
||||
} else if ( rc != LDAP_NOT_SUPPORTED ) {
|
||||
Debug( LDAP_DEBUG_ANY, "main: "
|
||||
"TLS init def ctx failed: %d\n",
|
||||
@ -862,7 +859,7 @@ unhandled_option:;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: moved here from slapd_daemon_task()
|
||||
* FIXME: moved here from lloadd_daemon_task()
|
||||
* because back-monitor db_open() needs it
|
||||
*/
|
||||
time( &starttime );
|
||||
@ -882,7 +879,7 @@ unhandled_option:;
|
||||
configfile ? configfile : LLOADD_DEFAULT_CONFIGFILE, urls );
|
||||
#endif
|
||||
|
||||
rc = slapd_daemon( daemon_base );
|
||||
rc = lloadd_daemon( daemon_base );
|
||||
|
||||
#ifdef HAVE_NT_SERVICE_MANAGER
|
||||
/* Throw away the event that we used during the startup process. */
|
||||
@ -904,7 +901,7 @@ destroy:
|
||||
(void)loglevel_print( stdout );
|
||||
}
|
||||
/* remember an error during destroy */
|
||||
rc |= slap_destroy();
|
||||
rc |= lload_destroy();
|
||||
|
||||
stop:
|
||||
#ifdef HAVE_NT_EVENT_LOG
|
||||
@ -920,12 +917,12 @@ stop:
|
||||
#ifdef LOG_DEBUG
|
||||
closelog();
|
||||
#endif
|
||||
slapd_daemon_destroy();
|
||||
lloadd_daemon_destroy();
|
||||
|
||||
#ifdef HAVE_TLS
|
||||
if ( slap_tls_ld ) {
|
||||
ldap_pvt_tls_ctx_free( slap_tls_ctx );
|
||||
ldap_unbind_ext( slap_tls_ld, NULL, NULL );
|
||||
if ( lload_tls_ld ) {
|
||||
ldap_pvt_tls_ctx_free( lload_tls_ctx );
|
||||
ldap_unbind_ext( lload_tls_ld, NULL, NULL );
|
||||
}
|
||||
ldap_pvt_tls_destroy();
|
||||
#endif
|
||||
@ -937,7 +934,7 @@ stop:
|
||||
unlink( slapd_args_file );
|
||||
}
|
||||
|
||||
config_destroy();
|
||||
lload_config_destroy();
|
||||
|
||||
if ( configfile ) ch_free( configfile );
|
||||
if ( configdir ) ch_free( configdir );
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "portable.h"
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
ber_tag_t
|
||||
slap_req2res( ber_tag_t tag )
|
||||
@ -52,7 +52,7 @@ slap_req2res( ber_tag_t tag )
|
||||
}
|
||||
|
||||
const char *
|
||||
slap_msgtype2str( ber_tag_t tag )
|
||||
lload_msgtype2str( ber_tag_t tag )
|
||||
{
|
||||
switch ( tag ) {
|
||||
case LDAP_REQ_ABANDON: return "abandon request";
|
||||
@ -84,7 +84,7 @@ slap_msgtype2str( ber_tag_t tag )
|
||||
int
|
||||
operation_client_cmp( const void *left, const void *right )
|
||||
{
|
||||
const Operation *l = left, *r = right;
|
||||
const LloadOperation *l = left, *r = right;
|
||||
|
||||
assert( l->o_client_connid == r->o_client_connid );
|
||||
return ( l->o_client_msgid < r->o_client_msgid ) ?
|
||||
@ -95,7 +95,7 @@ operation_client_cmp( const void *left, const void *right )
|
||||
int
|
||||
operation_upstream_cmp( const void *left, const void *right )
|
||||
{
|
||||
const Operation *l = left, *r = right;
|
||||
const LloadOperation *l = left, *r = right;
|
||||
|
||||
assert( l->o_upstream_connid == r->o_upstream_connid );
|
||||
return ( l->o_upstream_msgid < r->o_upstream_msgid ) ?
|
||||
@ -136,10 +136,10 @@ operation_upstream_cmp( const void *left, const void *right )
|
||||
* issues with maintaining so many mutex ordering restrictions.
|
||||
*/
|
||||
void
|
||||
operation_destroy_from_client( Operation *op )
|
||||
operation_destroy_from_client( LloadOperation *op )
|
||||
{
|
||||
Connection *upstream = NULL, *client = op->o_client;
|
||||
Backend *b = NULL;
|
||||
LloadConnection *upstream = NULL, *client = op->o_client;
|
||||
LloadBackend *b = NULL;
|
||||
int race_state, detach_client = !client->c_live;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "operation_destroy_from_client: "
|
||||
@ -268,7 +268,7 @@ operation_destroy_from_client( Operation *op )
|
||||
if ( upstream ) {
|
||||
if ( tavl_delete( &upstream->c_ops, op, operation_upstream_cmp ) ) {
|
||||
upstream->c_n_ops_executing--;
|
||||
b = (Backend *)upstream->c_private;
|
||||
b = (LloadBackend *)upstream->c_private;
|
||||
}
|
||||
CONNECTION_UNLOCK_OR_DESTROY(upstream);
|
||||
|
||||
@ -296,10 +296,10 @@ operation_destroy_from_client( Operation *op )
|
||||
* See operation_destroy_from_client.
|
||||
*/
|
||||
void
|
||||
operation_destroy_from_upstream( Operation *op )
|
||||
operation_destroy_from_upstream( LloadOperation *op )
|
||||
{
|
||||
Connection *client = NULL, *upstream = op->o_upstream;
|
||||
Backend *b = NULL;
|
||||
LloadConnection *client = NULL, *upstream = op->o_upstream;
|
||||
LloadBackend *b = NULL;
|
||||
int race_state, detach_upstream = !upstream->c_live;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "operation_destroy_from_upstream: "
|
||||
@ -321,7 +321,7 @@ operation_destroy_from_upstream( Operation *op )
|
||||
/* 2. Remove from the operation map and adjust the pending op count */
|
||||
if ( tavl_delete( &upstream->c_ops, op, operation_upstream_cmp ) ) {
|
||||
upstream->c_n_ops_executing--;
|
||||
b = (Backend *)upstream->c_private;
|
||||
b = (LloadBackend *)upstream->c_private;
|
||||
}
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_mutex );
|
||||
@ -453,15 +453,15 @@ operation_destroy_from_upstream( Operation *op )
|
||||
/*
|
||||
* Entered holding c_mutex for now.
|
||||
*/
|
||||
Operation *
|
||||
operation_init( Connection *c, BerElement *ber )
|
||||
LloadOperation *
|
||||
operation_init( LloadConnection *c, BerElement *ber )
|
||||
{
|
||||
Operation *op;
|
||||
LloadOperation *op;
|
||||
ber_tag_t tag;
|
||||
ber_len_t len;
|
||||
int rc;
|
||||
|
||||
op = ch_calloc( 1, sizeof(Operation) );
|
||||
op = ch_calloc( 1, sizeof(LloadOperation) );
|
||||
op->o_client = c;
|
||||
op->o_client_connid = c->c_connid;
|
||||
op->o_ber = ber;
|
||||
@ -506,7 +506,7 @@ operation_init( Connection *c, BerElement *ber )
|
||||
Debug( LDAP_DEBUG_STATS, "operation_init: "
|
||||
"received a new operation, %s with msgid=%d for client "
|
||||
"connid=%lu\n",
|
||||
slap_msgtype2str( op->o_tag ), op->o_client_msgid,
|
||||
lload_msgtype2str( op->o_tag ), op->o_client_msgid,
|
||||
op->o_client_connid );
|
||||
|
||||
c->c_n_ops_executing++;
|
||||
@ -518,9 +518,9 @@ fail:
|
||||
}
|
||||
|
||||
int
|
||||
operation_send_abandon( Operation *op )
|
||||
operation_send_abandon( LloadOperation *op )
|
||||
{
|
||||
Connection *upstream = op->o_upstream;
|
||||
LloadConnection *upstream = op->o_upstream;
|
||||
BerElement *ber;
|
||||
int rc = -1;
|
||||
|
||||
@ -557,10 +557,10 @@ done:
|
||||
* - op->o_client_refcnt > 0 (and it follows that op->o_client != NULL)
|
||||
*/
|
||||
void
|
||||
operation_abandon( Operation *op )
|
||||
operation_abandon( LloadOperation *op )
|
||||
{
|
||||
Connection *c;
|
||||
Backend *b;
|
||||
LloadConnection *c;
|
||||
LloadBackend *b;
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
@ -580,7 +580,7 @@ operation_abandon( Operation *op )
|
||||
c->c_state = LLOAD_C_READY;
|
||||
}
|
||||
c->c_n_ops_executing--;
|
||||
b = (Backend *)c->c_private;
|
||||
b = (LloadBackend *)c->c_private;
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
@ -627,18 +627,18 @@ done:
|
||||
*/
|
||||
int
|
||||
operation_send_reject_locked(
|
||||
Operation *op,
|
||||
LloadOperation *op,
|
||||
int result,
|
||||
const char *msg,
|
||||
int send_anyway )
|
||||
{
|
||||
Connection *c = op->o_client;
|
||||
LloadConnection *c = op->o_client;
|
||||
BerElement *ber;
|
||||
int found;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "operation_send_reject_locked: "
|
||||
"rejecting %s from client connid=%lu with message: \"%s\"\n",
|
||||
slap_msgtype2str( op->o_tag ), c->c_connid, msg );
|
||||
lload_msgtype2str( op->o_tag ), c->c_connid, msg );
|
||||
|
||||
found = ( tavl_delete( &c->c_ops, op, operation_client_cmp ) == op );
|
||||
if ( !found && !send_anyway ) {
|
||||
@ -681,12 +681,12 @@ done:
|
||||
|
||||
void
|
||||
operation_send_reject(
|
||||
Operation *op,
|
||||
LloadOperation *op,
|
||||
int result,
|
||||
const char *msg,
|
||||
int send_anyway )
|
||||
{
|
||||
Connection *c;
|
||||
LloadConnection *c;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
|
||||
c = op->o_client;
|
||||
@ -723,9 +723,9 @@ operation_send_reject(
|
||||
* Only called from upstream_destroy.
|
||||
*/
|
||||
void
|
||||
operation_lost_upstream( Operation *op )
|
||||
operation_lost_upstream( LloadOperation *op )
|
||||
{
|
||||
Connection *c = op->o_upstream;
|
||||
LloadConnection *c = op->o_upstream;
|
||||
CONNECTION_LOCK(c);
|
||||
op->o_upstream_refcnt++;
|
||||
/* Matching the op reference on the connection as well */
|
||||
@ -741,17 +741,18 @@ operation_lost_upstream( Operation *op )
|
||||
}
|
||||
|
||||
void
|
||||
connection_timeout( Connection *upstream, time_t threshold )
|
||||
connection_timeout( LloadConnection *upstream, time_t threshold )
|
||||
{
|
||||
Operation *op;
|
||||
LloadOperation *op;
|
||||
TAvlnode *ops = NULL, *node;
|
||||
Backend *b = upstream->c_private;
|
||||
LloadBackend *b = upstream->c_private;
|
||||
int rc, nops = 0;
|
||||
|
||||
for ( node = tavl_end( upstream->c_ops, TAVL_DIR_LEFT ); node &&
|
||||
((Operation *)node->avl_data)->o_start < threshold; /* shortcut */
|
||||
((LloadOperation *)node->avl_data)->o_start <
|
||||
threshold; /* shortcut */
|
||||
node = tavl_next( node, TAVL_DIR_RIGHT ) ) {
|
||||
Operation *found_op;
|
||||
LloadOperation *found_op;
|
||||
|
||||
op = node->avl_data;
|
||||
|
||||
@ -770,7 +771,7 @@ connection_timeout( Connection *upstream, time_t threshold )
|
||||
Debug( LDAP_DEBUG_STATS2, "connection_timeout: "
|
||||
"timing out %s from connid=%lu msgid=%d sent to connid=%lu as "
|
||||
"msgid=%d\n",
|
||||
slap_msgtype2str( op->o_tag ), op->o_client_connid,
|
||||
lload_msgtype2str( op->o_tag ), op->o_client_connid,
|
||||
op->o_client_msgid, op->o_upstream_connid,
|
||||
op->o_upstream_msgid );
|
||||
nops++;
|
||||
@ -791,7 +792,7 @@ connection_timeout( Connection *upstream, time_t threshold )
|
||||
|
||||
for ( node = tavl_end( ops, TAVL_DIR_LEFT ); node;
|
||||
node = tavl_next( node, TAVL_DIR_RIGHT ) ) {
|
||||
Connection *client;
|
||||
LloadConnection *client;
|
||||
|
||||
op = node->avl_data;
|
||||
|
||||
@ -835,12 +836,12 @@ connection_timeout( Connection *upstream, time_t threshold )
|
||||
|
||||
static void
|
||||
backend_timeout(
|
||||
Backend *b,
|
||||
struct ConnSt *cq,
|
||||
Connection **lastp,
|
||||
LloadBackend *b,
|
||||
lload_c_head *cq,
|
||||
LloadConnection **lastp,
|
||||
time_t threshold )
|
||||
{
|
||||
Connection *c, *old;
|
||||
LloadConnection *c, *old;
|
||||
unsigned long last_connid;
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &b->b_mutex );
|
||||
@ -899,7 +900,7 @@ void
|
||||
operations_timeout( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
struct event *self = arg;
|
||||
Backend *b;
|
||||
LloadBackend *b;
|
||||
time_t threshold;
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "operations_timeout: "
|
||||
|
183
servers/lloadd/proto-lload.h
Normal file
183
servers/lloadd/proto-lload.h
Normal file
@ -0,0 +1,183 @@
|
||||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
* Copyright 1998-2015 The OpenLDAP Foundation.
|
||||
* 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 the file LICENSE in the
|
||||
* top-level directory of the distribution or, alternatively, at
|
||||
* <http://www.OpenLDAP.org/license.html>.
|
||||
*/
|
||||
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PROTO_LLOAD_H
|
||||
#define PROTO_LLOAD_H
|
||||
|
||||
#include <ldap_cdefs.h>
|
||||
#include "ldap_pvt.h"
|
||||
|
||||
#include <event2/event.h>
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
struct config_args_s; /* config.h */
|
||||
struct config_reply_s; /* config.h */
|
||||
|
||||
/*
|
||||
* backend.c
|
||||
*/
|
||||
|
||||
LDAP_SLAPD_F (void) backend_connect( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (void *) backend_connect_task( void *ctx, void *arg );
|
||||
LDAP_SLAPD_F (void) backend_retry( LloadBackend *b );
|
||||
LDAP_SLAPD_F (LloadConnection *) backend_select( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) backends_destroy( void );
|
||||
|
||||
/*
|
||||
* bind.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) request_bind( LloadConnection *c, LloadOperation *op );
|
||||
LDAP_SLAPD_F (int) handle_bind_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) handle_vc_bind_response( LloadOperation *op, BerElement *ber );
|
||||
|
||||
/*
|
||||
* client.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) request_abandon( LloadConnection *c, LloadOperation *op );
|
||||
LDAP_SLAPD_F (int) request_process( LloadConnection *c, LloadOperation *op );
|
||||
LDAP_SLAPD_F (int) handle_one_request( LloadConnection *c );
|
||||
LDAP_SLAPD_F (void) client_tls_handshake_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (LloadConnection *) client_init( ber_socket_t s, LloadListener *url, const char *peername, struct event_base *base, int use_tls );
|
||||
LDAP_SLAPD_F (void) client_reset( LloadConnection *c );
|
||||
LDAP_SLAPD_F (void) client_destroy( LloadConnection *c );
|
||||
LDAP_SLAPD_F (void) clients_destroy( void );
|
||||
|
||||
/*
|
||||
* config.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) lload_read_config( const char *fname, const char *dir );
|
||||
LDAP_SLAPD_F (void) lload_config_destroy( void );
|
||||
LDAP_SLAPD_F (int) verb_to_mask( const char *word, slap_verbmasks *v );
|
||||
LDAP_SLAPD_F (int) lload_tls_get_config( LDAP *ld, int opt, char **val );
|
||||
LDAP_SLAPD_F (void) lload_bindconf_tls_defaults( slap_bindconf *bc );
|
||||
LDAP_SLAPD_F (int) lload_backend_parse( const char *word, LloadBackend *b );
|
||||
LDAP_SLAPD_F (int) lload_bindconf_parse( const char *word, slap_bindconf *bc );
|
||||
LDAP_SLAPD_F (int) lload_bindconf_unparse( slap_bindconf *bc, struct berval *bv );
|
||||
LDAP_SLAPD_F (int) lload_bindconf_tls_set( slap_bindconf *bc, LDAP *ld );
|
||||
LDAP_SLAPD_F (void) lload_bindconf_free( slap_bindconf *bc );
|
||||
|
||||
/*
|
||||
* connection.c
|
||||
*/
|
||||
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) clients_mutex;
|
||||
LDAP_SLAPD_F (void) connection_write_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (void) connection_read_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (LloadConnection *) lload_connection_init( ber_socket_t s, const char *peername, int use_tls );
|
||||
LDAP_SLAPD_F (void) connection_destroy( LloadConnection *c );
|
||||
|
||||
/*
|
||||
* daemon.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) lloadd_daemon_init( const char *urls );
|
||||
LDAP_SLAPD_F (int) lloadd_daemon_destroy( void );
|
||||
LDAP_SLAPD_F (int) lloadd_daemon( struct event_base *daemon_base );
|
||||
LDAP_SLAPD_F (LloadListener **) lloadd_get_listeners( void );
|
||||
LDAP_SLAPD_F (void) listeners_reactivate( void );
|
||||
LDAP_SLAPD_F (struct event_base *) lload_get_base( ber_socket_t s );
|
||||
LDAP_SLAPD_V (int) lload_daemon_threads;
|
||||
LDAP_SLAPD_V (int) lload_daemon_mask;
|
||||
|
||||
LDAP_SLAPD_F (void) lload_sig_shutdown( evutil_socket_t sig, short what, void *arg );
|
||||
|
||||
LDAP_SLAPD_V (struct evdns_base *) dnsbase;
|
||||
LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown;
|
||||
LDAP_SLAPD_V (int) lloadd_inited;
|
||||
|
||||
LDAP_SLAPD_V (struct event *) lload_timeout_event;
|
||||
|
||||
LDAP_SLAPD_V (LDAP *) lload_tls_backend_ld;
|
||||
LDAP_SLAPD_V (LDAP *) lload_tls_ld;
|
||||
LDAP_SLAPD_V (void *) lload_tls_ctx;
|
||||
|
||||
/*
|
||||
* extended.c
|
||||
*/
|
||||
LDAP_SLAPD_V (Avlnode *) lload_exop_handlers;
|
||||
LDAP_SLAPD_F (int) exop_handler_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (int) request_extended( LloadConnection *c, LloadOperation *op );
|
||||
LDAP_SLAPD_F (int) lload_exop_init( void );
|
||||
|
||||
/*
|
||||
* init.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) lload_init( int mode, const char *name );
|
||||
LDAP_SLAPD_F (int) lload_destroy( void );
|
||||
|
||||
/*
|
||||
* libevent_support.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) lload_libevent_init( void );
|
||||
LDAP_SLAPD_F (void) lload_libevent_destroy( void );
|
||||
|
||||
/*
|
||||
* operation.c
|
||||
*/
|
||||
LDAP_SLAPD_F (const char *) lload_msgtype2str( ber_tag_t tag );
|
||||
LDAP_SLAPD_F (int) operation_upstream_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (int) operation_client_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (LloadOperation *) operation_init( LloadConnection *c, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) operation_send_abandon( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) operation_abandon( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) operation_send_reject( LloadOperation *op, int result, const char *msg, int send_anyway );
|
||||
LDAP_SLAPD_F (int) operation_send_reject_locked( LloadOperation *op, int result, const char *msg, int send_anyway );
|
||||
LDAP_SLAPD_F (void) operation_lost_upstream( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) operation_destroy_from_client( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) operation_destroy_from_upstream( LloadOperation *op );
|
||||
LDAP_SLAPD_F (void) operations_timeout( evutil_socket_t s, short what, void *arg );
|
||||
|
||||
/*
|
||||
* upstream.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) forward_final_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) forward_response( LloadOperation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (LloadConnection *) upstream_init( ber_socket_t s, LloadBackend *b );
|
||||
LDAP_SLAPD_F (void) upstream_destroy( LloadConnection *c );
|
||||
|
||||
LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_client;
|
||||
LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_upstream;
|
||||
LDAP_SLAPD_V (int) lload_conn_max_pdus_per_cycle;
|
||||
|
||||
LDAP_SLAPD_V (lload_features_t) lload_features;
|
||||
|
||||
LDAP_SLAPD_V (slap_mask_t) global_allows;
|
||||
LDAP_SLAPD_V (slap_mask_t) global_disallows;
|
||||
|
||||
LDAP_SLAPD_V (const char) Versionstr[];
|
||||
|
||||
LDAP_SLAPD_V (int) global_gentlehup;
|
||||
LDAP_SLAPD_V (int) global_idletimeout;
|
||||
|
||||
LDAP_SLAPD_V (struct timeval *) lload_timeout_api;
|
||||
LDAP_SLAPD_V (struct timeval *) lload_timeout_net;
|
||||
LDAP_SLAPD_V (struct timeval *) lload_write_timeout;
|
||||
|
||||
LDAP_SLAPD_V (char *) global_host;
|
||||
LDAP_SLAPD_V (int) lber_debug;
|
||||
LDAP_SLAPD_V (int) ldap_syslog;
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif /* PROTO_LLOAD_H */
|
@ -1,347 +0,0 @@
|
||||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
* Copyright 1998-2015 The OpenLDAP Foundation.
|
||||
* 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 the file LICENSE in the
|
||||
* top-level directory of the distribution or, alternatively, at
|
||||
* <http://www.OpenLDAP.org/license.html>.
|
||||
*/
|
||||
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PROTO_SLAP_H
|
||||
#define PROTO_SLAP_H
|
||||
|
||||
#include <ldap_cdefs.h>
|
||||
#include "ldap_pvt.h"
|
||||
|
||||
#include <event2/event.h>
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
struct config_args_s; /* config.h */
|
||||
struct config_reply_s; /* config.h */
|
||||
|
||||
/*
|
||||
* backend.c
|
||||
*/
|
||||
|
||||
LDAP_SLAPD_F (void) backend_connect( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (void *) backend_connect_task( void *ctx, void *arg );
|
||||
LDAP_SLAPD_F (void) backend_retry( Backend *b );
|
||||
LDAP_SLAPD_F (Connection *) backend_select( Operation *op );
|
||||
LDAP_SLAPD_F (void) backends_destroy( void );
|
||||
|
||||
/*
|
||||
* ch_malloc.c
|
||||
*/
|
||||
LDAP_SLAPD_V (BerMemoryFunctions) ch_mfuncs;
|
||||
LDAP_SLAPD_F (void *) ch_malloc( ber_len_t size );
|
||||
LDAP_SLAPD_F (void *) ch_realloc( void *block, ber_len_t size );
|
||||
LDAP_SLAPD_F (void *) ch_calloc( ber_len_t nelem, ber_len_t size );
|
||||
LDAP_SLAPD_F (char *) ch_strdup( const char *string );
|
||||
LDAP_SLAPD_F (void) ch_free( void * );
|
||||
|
||||
#ifndef CH_FREE
|
||||
#undef free
|
||||
#define free ch_free
|
||||
#endif
|
||||
|
||||
/*
|
||||
* bind.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) request_bind( Connection *c, Operation *op );
|
||||
LDAP_SLAPD_F (int) handle_bind_response( Operation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) handle_vc_bind_response( Operation *op, BerElement *ber );
|
||||
|
||||
/*
|
||||
* client.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) request_abandon( Connection *c, Operation *op );
|
||||
LDAP_SLAPD_F (int) request_process( Connection *c, Operation *op );
|
||||
LDAP_SLAPD_F (int) handle_one_request( Connection *c );
|
||||
LDAP_SLAPD_F (void) client_tls_handshake_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (Connection *) client_init( ber_socket_t s, Listener *url, const char *peername, struct event_base *base, int use_tls );
|
||||
LDAP_SLAPD_F (void) client_reset( Connection *c );
|
||||
LDAP_SLAPD_F (void) client_destroy( Connection *c );
|
||||
LDAP_SLAPD_F (void) clients_destroy( void );
|
||||
|
||||
/*
|
||||
* config.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) read_config( const char *fname, const char *dir );
|
||||
LDAP_SLAPD_F (void) config_destroy( void );
|
||||
LDAP_SLAPD_F (int) verb_to_mask( const char *word, slap_verbmasks *v );
|
||||
LDAP_SLAPD_F (int) str2loglevel( const char *s, int *l );
|
||||
LDAP_SLAPD_F (void) bindconf_tls_defaults( slap_bindconf *bc );
|
||||
LDAP_SLAPD_F (void) bindconf_free( slap_bindconf *bc );
|
||||
|
||||
/*
|
||||
* connection.c
|
||||
*/
|
||||
LDAP_SLAPD_V (ldap_pvt_thread_mutex_t) clients_mutex;
|
||||
LDAP_SLAPD_F (void) connection_write_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (void) connection_read_cb( evutil_socket_t s, short what, void *arg );
|
||||
LDAP_SLAPD_F (Connection *) connection_init( ber_socket_t s, const char *peername, int use_tls );
|
||||
LDAP_SLAPD_F (void) connection_destroy( Connection *c );
|
||||
|
||||
/*
|
||||
* daemon.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) slapd_daemon_init( const char *urls );
|
||||
LDAP_SLAPD_F (int) slapd_daemon_destroy( void );
|
||||
LDAP_SLAPD_F (int) slapd_daemon( struct event_base *daemon_base );
|
||||
LDAP_SLAPD_F (Listener **) slapd_get_listeners( void );
|
||||
LDAP_SLAPD_F (void) listeners_reactivate( void );
|
||||
LDAP_SLAPD_F (struct event_base *) slap_get_base( ber_socket_t s );
|
||||
|
||||
LDAP_SLAPD_F (void) slap_sig_shutdown( evutil_socket_t sig, short what, void *arg );
|
||||
|
||||
LDAP_SLAPD_V (struct evdns_base *) dnsbase;
|
||||
LDAP_SLAPD_V (volatile sig_atomic_t) slapd_shutdown;
|
||||
LDAP_SLAPD_V (int) lloadd_inited;
|
||||
LDAP_SLAPD_V (struct runqueue_s) slapd_rq;
|
||||
LDAP_SLAPD_V (int) slapd_daemon_threads;
|
||||
LDAP_SLAPD_V (int) slapd_daemon_mask;
|
||||
#ifdef LDAP_TCP_BUFFER
|
||||
LDAP_SLAPD_V (int) slapd_tcp_rmem;
|
||||
LDAP_SLAPD_V (int) slapd_tcp_wmem;
|
||||
#endif /* LDAP_TCP_BUFFER */
|
||||
|
||||
LDAP_SLAPD_V (struct event *) lload_timeout_event;
|
||||
|
||||
#define bvmatch( bv1, bv2 ) \
|
||||
( ( (bv1)->bv_len == (bv2)->bv_len ) && \
|
||||
( memcmp( (bv1)->bv_val, (bv2)->bv_val, (bv1)->bv_len ) == 0 ) )
|
||||
|
||||
/*
|
||||
* extended.c
|
||||
*/
|
||||
LDAP_SLAPD_V (Avlnode *) lload_exop_handlers;
|
||||
LDAP_SLAPD_F (int) exop_handler_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (int) request_extended( Connection *c, Operation *op );
|
||||
LDAP_SLAPD_F (int) lload_exop_init( void );
|
||||
|
||||
/*
|
||||
* globals.c
|
||||
*/
|
||||
LDAP_SLAPD_V (const struct berval) slap_empty_bv;
|
||||
LDAP_SLAPD_V (const struct berval) slap_unknown_bv;
|
||||
LDAP_SLAPD_V (const struct berval) slap_true_bv;
|
||||
LDAP_SLAPD_V (const struct berval) slap_false_bv;
|
||||
LDAP_SLAPD_V (struct slap_sync_cookie_s) slap_sync_cookie;
|
||||
LDAP_SLAPD_V (void *) slap_tls_ctx;
|
||||
LDAP_SLAPD_V (LDAP *) slap_tls_ld;
|
||||
LDAP_SLAPD_V (LDAP *) slap_tls_backend_ld;
|
||||
|
||||
/*
|
||||
* init.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) slap_init( int mode, const char *name );
|
||||
LDAP_SLAPD_F (int) slap_destroy( void );
|
||||
|
||||
/*
|
||||
* libevent_support.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) lload_libevent_init( void );
|
||||
LDAP_SLAPD_F (void) lload_libevent_destroy( void );
|
||||
|
||||
/*
|
||||
* main.c
|
||||
*/
|
||||
LDAP_SLAPD_V (int) slapd_register_slp;
|
||||
LDAP_SLAPD_V (const char *) slapd_slp_attrs;
|
||||
|
||||
/*
|
||||
* operation.c
|
||||
*/
|
||||
LDAP_SLAPD_F (const char *) slap_msgtype2str( ber_tag_t tag );
|
||||
LDAP_SLAPD_F (int) operation_upstream_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (int) operation_client_cmp( const void *l, const void *r );
|
||||
LDAP_SLAPD_F (Operation *) operation_init( Connection *c, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) operation_send_abandon( Operation *op );
|
||||
LDAP_SLAPD_F (void) operation_abandon( Operation *op );
|
||||
LDAP_SLAPD_F (void) operation_send_reject( Operation *op, int result, const char *msg, int send_anyway );
|
||||
LDAP_SLAPD_F (int) operation_send_reject_locked( Operation *op, int result, const char *msg, int send_anyway );
|
||||
LDAP_SLAPD_F (void) operation_lost_upstream( Operation *op );
|
||||
LDAP_SLAPD_F (void) operation_destroy_from_client( Operation *op );
|
||||
LDAP_SLAPD_F (void) operation_destroy_from_upstream( Operation *op );
|
||||
LDAP_SLAPD_F (void) operations_timeout( evutil_socket_t s, short what, void *arg );
|
||||
|
||||
/*
|
||||
* sl_malloc.c
|
||||
*/
|
||||
LDAP_SLAPD_F (void *) slap_sl_malloc( ber_len_t size, void *ctx );
|
||||
LDAP_SLAPD_F (void *) slap_sl_realloc( void *block, ber_len_t size, void *ctx );
|
||||
LDAP_SLAPD_F (void *) slap_sl_calloc( ber_len_t nelem, ber_len_t size, void *ctx );
|
||||
LDAP_SLAPD_F (void) slap_sl_free( void *, void *ctx );
|
||||
|
||||
LDAP_SLAPD_V (BerMemoryFunctions) slap_sl_mfuncs;
|
||||
|
||||
LDAP_SLAPD_F (void) slap_sl_mem_init( void );
|
||||
LDAP_SLAPD_F (void *) slap_sl_mem_create( ber_len_t size, int stack, void *ctx, int flag );
|
||||
LDAP_SLAPD_F (void) slap_sl_mem_setctx( void *ctx, void *memctx );
|
||||
LDAP_SLAPD_F (void) slap_sl_mem_destroy( void *key, void *data );
|
||||
LDAP_SLAPD_F (void *) slap_sl_context( void *ptr );
|
||||
|
||||
/* assumes (x) > (y) returns 1 if true, 0 otherwise */
|
||||
#define SLAP_PTRCMP(x, y) ( (x) < (y) ? -1 : (x) > (y) )
|
||||
|
||||
/*
|
||||
* upstream.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) forward_final_response( Operation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (int) forward_response( Operation *op, BerElement *ber );
|
||||
LDAP_SLAPD_F (Connection *) upstream_init( ber_socket_t s, Backend *b );
|
||||
LDAP_SLAPD_F (void) upstream_destroy( Connection *c );
|
||||
|
||||
/*
|
||||
* user.c
|
||||
*/
|
||||
#if defined(HAVE_PWD_H) && defined(HAVE_GRP_H)
|
||||
LDAP_SLAPD_F (void) slap_init_user( char *username, char *groupname );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* value.c
|
||||
*/
|
||||
LDAP_SLAPD_F (int) value_add_one( BerVarray *vals, struct berval *addval );
|
||||
|
||||
#ifdef SLAP_ZONE_ALLOC
|
||||
/*
|
||||
* zn_malloc.c
|
||||
*/
|
||||
LDAP_SLAPD_F (void *) slap_zn_malloc( ber_len_t, void * );
|
||||
LDAP_SLAPD_F (void *) slap_zn_realloc( void *, ber_len_t, void * );
|
||||
LDAP_SLAPD_F (void *) slap_zn_calloc( ber_len_t, ber_len_t, void * );
|
||||
LDAP_SLAPD_F (void) slap_zn_free( void *, void * );
|
||||
|
||||
LDAP_SLAPD_F (void *) slap_zn_mem_create( ber_len_t, ber_len_t, ber_len_t, ber_len_t );
|
||||
LDAP_SLAPD_F (void) slap_zn_mem_destroy( void * );
|
||||
LDAP_SLAPD_F (int) slap_zn_validate( void *, void *, int );
|
||||
LDAP_SLAPD_F (int) slap_zn_invalidate( void *, void * );
|
||||
LDAP_SLAPD_F (int) slap_zh_rlock( void * );
|
||||
LDAP_SLAPD_F (int) slap_zh_runlock( void * );
|
||||
LDAP_SLAPD_F (int) slap_zh_wlock( void * );
|
||||
LDAP_SLAPD_F (int) slap_zh_wunlock( void * );
|
||||
LDAP_SLAPD_F (int) slap_zn_rlock( void *, void * );
|
||||
LDAP_SLAPD_F (int) slap_zn_runlock( void *, void * );
|
||||
LDAP_SLAPD_F (int) slap_zn_wlock( void *, void * );
|
||||
LDAP_SLAPD_F (int) slap_zn_wunlock( void *, void * );
|
||||
#endif
|
||||
|
||||
LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_client;
|
||||
LDAP_SLAPD_V (ber_len_t) sockbuf_max_incoming_upstream;
|
||||
LDAP_SLAPD_V (int) slap_conn_max_pdus_per_cycle;
|
||||
|
||||
LDAP_SLAPD_V (lload_features_t) lload_features;
|
||||
|
||||
LDAP_SLAPD_V (slap_mask_t) global_allows;
|
||||
LDAP_SLAPD_V (slap_mask_t) global_disallows;
|
||||
|
||||
LDAP_SLAPD_V (const char) Versionstr[];
|
||||
|
||||
LDAP_SLAPD_V (int) global_gentlehup;
|
||||
LDAP_SLAPD_V (int) global_idletimeout;
|
||||
|
||||
LDAP_SLAPD_V (struct timeval *) lload_timeout_api;
|
||||
LDAP_SLAPD_V (struct timeval *) lload_timeout_net;
|
||||
LDAP_SLAPD_V (struct timeval *) lload_write_timeout;
|
||||
|
||||
LDAP_SLAPD_V (char *) global_host;
|
||||
LDAP_SLAPD_V (int) lber_debug;
|
||||
LDAP_SLAPD_V (int) ldap_syslog;
|
||||
|
||||
LDAP_SLAPD_V (char *) slapd_pid_file;
|
||||
LDAP_SLAPD_V (char *) slapd_args_file;
|
||||
LDAP_SLAPD_V (time_t) starttime;
|
||||
|
||||
/* use time(3) -- no mutex */
|
||||
#define slap_get_time() time( NULL )
|
||||
|
||||
LDAP_SLAPD_V (ldap_pvt_thread_pool_t) connection_pool;
|
||||
LDAP_SLAPD_V (int) connection_pool_max;
|
||||
LDAP_SLAPD_V (int) connection_pool_queues;
|
||||
LDAP_SLAPD_V (int) slap_tool_thread_max;
|
||||
|
||||
#ifdef USE_MP_BIGNUM
|
||||
#define UI2BVX( bv, ui, ctx ) \
|
||||
do { \
|
||||
char *val; \
|
||||
ber_len_t len; \
|
||||
val = BN_bn2dec( ui ); \
|
||||
if (val) { \
|
||||
len = strlen( val ); \
|
||||
if ( len > (bv)->bv_len ) { \
|
||||
(bv)->bv_val = ber_memrealloc_x( (bv)->bv_val, len + 1, (ctx) ); \
|
||||
} \
|
||||
AC_MEMCPY( (bv)->bv_val, val, len + 1 ); \
|
||||
(bv)->bv_len = len; \
|
||||
OPENSSL_free( val ); \
|
||||
} else { \
|
||||
ber_memfree_x( (bv)->bv_val, (ctx) ); \
|
||||
BER_BVZERO( (bv) ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#elif defined(USE_MP_GMP)
|
||||
/* NOTE: according to the documentation, the result
|
||||
* of mpz_sizeinbase() can exceed the length of the
|
||||
* string representation of the number by 1
|
||||
*/
|
||||
#define UI2BVX( bv, ui, ctx ) \
|
||||
do { \
|
||||
ber_len_t len = mpz_sizeinbase( (ui), 10 ); \
|
||||
if ( len > (bv)->bv_len ) { \
|
||||
(bv)->bv_val = ber_memrealloc_x( (bv)->bv_val, len + 1, (ctx) ); \
|
||||
} \
|
||||
(void)mpz_get_str( (bv)->bv_val, 10, (ui) ); \
|
||||
if ( (bv)->bv_val[len - 1] == '\0' ) { \
|
||||
len--; \
|
||||
} \
|
||||
(bv)->bv_len = len; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#ifdef USE_MP_LONG_LONG
|
||||
#define UI2BV_FORMAT "%llu"
|
||||
#elif defined USE_MP_LONG
|
||||
#define UI2BV_FORMAT "%lu"
|
||||
#elif defined HAVE_LONG_LONG
|
||||
#define UI2BV_FORMAT "%llu"
|
||||
#else
|
||||
#define UI2BV_FORMAT "%lu"
|
||||
#endif
|
||||
|
||||
#define UI2BVX( bv, ui, ctx ) \
|
||||
do { \
|
||||
char buf[LDAP_PVT_INTTYPE_CHARS(long)]; \
|
||||
ber_len_t len; \
|
||||
len = snprintf( buf, sizeof( buf ), UI2BV_FORMAT, (ui) ); \
|
||||
if ( len > (bv)->bv_len ) { \
|
||||
(bv)->bv_val = ber_memrealloc_x( (bv)->bv_val, len + 1, (ctx) ); \
|
||||
} \
|
||||
(bv)->bv_len = len; \
|
||||
AC_MEMCPY( (bv)->bv_val, buf, len + 1 ); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define UI2BV( bv, ui ) UI2BVX( bv, ui, NULL )
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif /* PROTO_SLAP_H */
|
@ -22,12 +22,12 @@
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#include "lutil.h"
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
int
|
||||
forward_response( Operation *op, BerElement *ber )
|
||||
forward_response( LloadOperation *op, BerElement *ber )
|
||||
{
|
||||
Connection *c = op->o_client;
|
||||
LloadConnection *c = op->o_client;
|
||||
BerElement *output;
|
||||
BerValue response, controls = BER_BVNULL;
|
||||
ber_tag_t tag, response_tag;
|
||||
@ -42,7 +42,7 @@ forward_response( Operation *op, BerElement *ber )
|
||||
|
||||
Debug( LDAP_DEBUG_TRACE, "forward_response: "
|
||||
"%s to client connid=%lu request msgid=%d\n",
|
||||
slap_msgtype2str( response_tag ), op->o_client_connid,
|
||||
lload_msgtype2str( response_tag ), op->o_client_connid,
|
||||
op->o_client_msgid );
|
||||
|
||||
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
|
||||
@ -67,7 +67,7 @@ forward_response( Operation *op, BerElement *ber )
|
||||
}
|
||||
|
||||
int
|
||||
forward_final_response( Operation *op, BerElement *ber )
|
||||
forward_final_response( LloadOperation *op, BerElement *ber )
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -84,7 +84,7 @@ forward_final_response( Operation *op, BerElement *ber )
|
||||
}
|
||||
|
||||
static int
|
||||
handle_unsolicited( Connection *c, BerElement *ber )
|
||||
handle_unsolicited( LloadConnection *c, BerElement *ber )
|
||||
{
|
||||
if ( c->c_state == LLOAD_C_READY ) {
|
||||
c->c_state = LLOAD_C_CLOSING;
|
||||
@ -129,11 +129,11 @@ handle_unsolicited( Connection *c, BerElement *ber )
|
||||
* - op->o_client->c_refcnt > 0
|
||||
*/
|
||||
static int
|
||||
handle_one_response( Connection *c )
|
||||
handle_one_response( LloadConnection *c )
|
||||
{
|
||||
BerElement *ber;
|
||||
Operation *op = NULL, needle = { .o_upstream_connid = c->c_connid };
|
||||
OperationHandler handler = NULL;
|
||||
LloadOperation *op = NULL, needle = { .o_upstream_connid = c->c_connid };
|
||||
LloadOperationHandler handler = NULL;
|
||||
ber_tag_t tag;
|
||||
ber_len_t len;
|
||||
int rc = LDAP_SUCCESS;
|
||||
@ -198,11 +198,12 @@ handle_one_response( Connection *c )
|
||||
Debug( LDAP_DEBUG_STATS2, "handle_one_response: "
|
||||
"upstream connid=%lu, %s, msgid=%d not for a pending "
|
||||
"operation\n",
|
||||
c->c_connid, slap_msgtype2str( tag ), needle.o_upstream_msgid );
|
||||
c->c_connid, lload_msgtype2str( tag ),
|
||||
needle.o_upstream_msgid );
|
||||
}
|
||||
|
||||
if ( handler ) {
|
||||
Connection *client;
|
||||
LloadConnection *client;
|
||||
|
||||
op->o_upstream_refcnt++;
|
||||
CONNECTION_UNLOCK_INCREF(c);
|
||||
@ -251,7 +252,7 @@ fail:
|
||||
Debug( LDAP_DEBUG_STATS, "handle_one_response: "
|
||||
"error on processing a response (%s) on upstream connection "
|
||||
"connid=%ld, tag=%lx\n",
|
||||
slap_msgtype2str( tag ), c->c_connid, tag );
|
||||
lload_msgtype2str( tag ), c->c_connid, tag );
|
||||
CONNECTION_DESTROY(c);
|
||||
}
|
||||
/* We leave the connection locked */
|
||||
@ -259,10 +260,10 @@ fail:
|
||||
}
|
||||
|
||||
int
|
||||
upstream_bind_cb( Connection *c )
|
||||
upstream_bind_cb( LloadConnection *c )
|
||||
{
|
||||
BerElement *ber = c->c_currentber;
|
||||
Backend *b = c->c_private;
|
||||
LloadBackend *b = c->c_private;
|
||||
BerValue matcheddn, message;
|
||||
ber_tag_t tag;
|
||||
ber_int_t msgid, result;
|
||||
@ -278,7 +279,7 @@ upstream_bind_cb( Connection *c )
|
||||
if ( msgid != ( c->c_next_msgid - 1 ) || tag != LDAP_RES_BIND ) {
|
||||
Debug( LDAP_DEBUG_ANY, "upstream_bind_cb: "
|
||||
"unexpected %s from server, msgid=%d\n",
|
||||
slap_msgtype2str( tag ), msgid );
|
||||
lload_msgtype2str( tag ), msgid );
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -339,7 +340,7 @@ fail:
|
||||
void *
|
||||
upstream_bind( void *ctx, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
LloadConnection *c = arg;
|
||||
BerElement *ber;
|
||||
ber_int_t msgid;
|
||||
|
||||
@ -389,9 +390,9 @@ upstream_bind( void *ctx, void *arg )
|
||||
* The backend is already locked when entering the function.
|
||||
*/
|
||||
static int
|
||||
upstream_finish( Connection *c )
|
||||
upstream_finish( LloadConnection *c )
|
||||
{
|
||||
Backend *b = c->c_private;
|
||||
LloadBackend *b = c->c_private;
|
||||
int is_bindconn = 0, rc = 0;
|
||||
|
||||
c->c_pdu_cb = handle_one_response;
|
||||
@ -455,8 +456,8 @@ upstream_finish( Connection *c )
|
||||
static void
|
||||
upstream_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
{
|
||||
Connection *c = arg;
|
||||
Backend *b;
|
||||
LloadConnection *c = arg;
|
||||
LloadBackend *b;
|
||||
int rc = LDAP_SUCCESS;
|
||||
|
||||
CONNECTION_LOCK(c);
|
||||
@ -468,7 +469,7 @@ upstream_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
|
||||
}
|
||||
b = c->c_private;
|
||||
|
||||
rc = ldap_pvt_tls_connect( slap_tls_backend_ld, c->c_sb, b->b_host );
|
||||
rc = ldap_pvt_tls_connect( lload_tls_backend_ld, c->c_sb, b->b_host );
|
||||
if ( rc < 0 ) {
|
||||
goto fail;
|
||||
}
|
||||
@ -525,7 +526,7 @@ fail:
|
||||
}
|
||||
|
||||
static int
|
||||
upstream_starttls( Connection *c )
|
||||
upstream_starttls( LloadConnection *c )
|
||||
{
|
||||
BerValue matcheddn, message, responseOid,
|
||||
startTLSOid = BER_BVC(LDAP_EXOP_START_TLS);
|
||||
@ -545,7 +546,7 @@ upstream_starttls( Connection *c )
|
||||
if ( msgid != ( c->c_next_msgid - 1 ) || tag != LDAP_RES_EXTENDED ) {
|
||||
Debug( LDAP_DEBUG_ANY, "upstream_starttls: "
|
||||
"unexpected %s from server, msgid=%d\n",
|
||||
slap_msgtype2str( tag ), msgid );
|
||||
lload_msgtype2str( tag ), msgid );
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -573,7 +574,7 @@ upstream_starttls( Connection *c )
|
||||
}
|
||||
|
||||
if ( result != LDAP_SUCCESS ) {
|
||||
Backend *b = c->c_private;
|
||||
LloadBackend *b = c->c_private;
|
||||
int rc;
|
||||
|
||||
Debug( LDAP_DEBUG_STATS, "upstream_starttls: "
|
||||
@ -631,18 +632,18 @@ fail:
|
||||
/*
|
||||
* We must already hold b->b_mutex when called.
|
||||
*/
|
||||
Connection *
|
||||
upstream_init( ber_socket_t s, Backend *b )
|
||||
LloadConnection *
|
||||
upstream_init( ber_socket_t s, LloadBackend *b )
|
||||
{
|
||||
Connection *c;
|
||||
struct event_base *base = slap_get_base( s );
|
||||
LloadConnection *c;
|
||||
struct event_base *base = lload_get_base( s );
|
||||
struct event *event;
|
||||
int flags, rc = -1;
|
||||
|
||||
assert( b != NULL );
|
||||
|
||||
flags = (b->b_proto == LDAP_PROTO_IPC) ? CONN_IS_IPC : 0;
|
||||
if ( (c = connection_init( s, b->b_host, flags )) == NULL ) {
|
||||
if ( (c = lload_connection_init( s, b->b_host, flags )) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -738,9 +739,9 @@ fail:
|
||||
}
|
||||
|
||||
void
|
||||
upstream_destroy( Connection *c )
|
||||
upstream_destroy( LloadConnection *c )
|
||||
{
|
||||
Backend *b = c->c_private;
|
||||
LloadBackend *b = c->c_private;
|
||||
struct event *read_event, *write_event;
|
||||
TAvlnode *root;
|
||||
long freed, executing;
|
||||
@ -789,7 +790,7 @@ upstream_destroy( Connection *c )
|
||||
b->b_failed++;
|
||||
} else if ( c->c_type == LLOAD_C_BIND ) {
|
||||
if ( c == b->b_last_bindconn ) {
|
||||
Connection *prev =
|
||||
LloadConnection *prev =
|
||||
LDAP_CIRCLEQ_LOOP_PREV( &b->b_bindconns, c, c_next );
|
||||
if ( prev == c ) {
|
||||
b->b_last_bindconn = NULL;
|
||||
@ -801,7 +802,7 @@ upstream_destroy( Connection *c )
|
||||
b->b_bindavail--;
|
||||
} else {
|
||||
if ( c == b->b_last_conn ) {
|
||||
Connection *prev =
|
||||
LloadConnection *prev =
|
||||
LDAP_CIRCLEQ_LOOP_PREV( &b->b_conns, c, c_next );
|
||||
if ( prev == c ) {
|
||||
b->b_last_conn = NULL;
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include "slap.h"
|
||||
#include "lload.h"
|
||||
|
||||
int
|
||||
value_add_one( BerVarray *vals, struct berval *addval )
|
||||
|
Loading…
Reference in New Issue
Block a user