Commit 8bc7650a authored by Nadezhda Ivanova's avatar Nadezhda Ivanova Committed by Ondřej Kuzník
Browse files

Clean ups and renames to coexist with slapd

parent c7e3437e
......@@ -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);
......
This diff is collapsed.
......@@ -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 );
......
This diff is collapsed.
......@@ -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: "