/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2008 The OpenLDAP Foundation.
+ * Copyright 2008-2013 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
-1
};
+static Uint32 ndb_lastrow[1];
+NdbInterpretedCode *ndb_lastrow_code;
+
static int
ndb_db_init( BackendDB *be, ConfigReply *cr )
{
if ( ni->ni_nconns < 1 )
ni->ni_nconns = 1;
- ni->ni_cluster = (Ndb_cluster_connection **)ch_malloc( ni->ni_nconns * sizeof( Ndb_cluster_connection *));
+ ni->ni_cluster = (Ndb_cluster_connection **)ch_calloc( ni->ni_nconns, sizeof( Ndb_cluster_connection *));
for ( i=0; i<ni->ni_nconns; i++ ) {
ni->ni_cluster[i] = new Ndb_cluster_connection( ni->ni_connectstr );
- rc = ni->ni_cluster[i]->connect( 4, 5, 1 );
+ rc = ni->ni_cluster[i]->connect( 20, 5, 1 );
+ if ( rc ) {
+ snprintf( cr->msg, sizeof( cr->msg ),
+ "ndb_db_open: ni_cluster[%d]->connect failed (%d)",
+ i, rc );
+ goto fail;
+ }
}
for ( i=0; i<ni->ni_nconns; i++ ) {
- rc = ni->ni_cluster[i]->wait_until_ready( 30, 0 );
+ rc = ni->ni_cluster[i]->wait_until_ready( 30, 30 );
+ if ( rc ) {
+ snprintf( cr->msg, sizeof( cr->msg ),
+ "ndb_db_open: ni_cluster[%d]->wait failed (%d)",
+ i, rc );
+ goto fail;
+ }
}
mysql_init( &ni->ni_sql );
static int
ndb_db_close( BackendDB *be, ConfigReply *cr )
{
- int i, rc;
+ int i;
struct ndb_info *ni = (struct ndb_info *) be->be_private;
mysql_close( &ni->ni_sql );
- for ( i=0; i<ni->ni_nconns; i++ ) {
- delete ni->ni_cluster[i];
- ni->ni_cluster[i] = NULL;
+ if ( ni->ni_cluster ) {
+ for ( i=0; i<ni->ni_nconns; i++ ) {
+ if ( ni->ni_cluster[i] ) {
+ delete ni->ni_cluster[i];
+ ni->ni_cluster[i] = NULL;
+ }
+ }
+ ch_free( ni->ni_cluster );
+ ni->ni_cluster = NULL;
}
- ch_free( ni->ni_cluster );
- ni->ni_cluster = NULL;
#ifdef DO_MONITORING
/* monitor handling */
ndb_back_initialize(
BackendInfo *bi )
{
+ static char *controls[] = {
+ LDAP_CONTROL_ASSERT,
+ LDAP_CONTROL_MANAGEDSAIT,
+ LDAP_CONTROL_NOOP,
+ LDAP_CONTROL_PAGEDRESULTS,
+ LDAP_CONTROL_PRE_READ,
+ LDAP_CONTROL_POST_READ,
+ LDAP_CONTROL_SUBENTRIES,
+ LDAP_CONTROL_X_PERMISSIVE_MODIFY,
+#ifdef LDAP_X_TXN
+ LDAP_CONTROL_X_TXN_SPEC,
+#endif
+ NULL
+ };
+
int rc = 0;
/* initialize the underlying database system */
ndb_init();
+ ndb_lastrow_code = new NdbInterpretedCode( NULL, ndb_lastrow, 1 );
+ ndb_lastrow_code->interpret_exit_last_row();
+ ndb_lastrow_code->finalise();
+
+ bi->bi_flags |=
+ SLAP_BFLAG_INCREMENT |
+ SLAP_BFLAG_SUBENTRIES |
+ SLAP_BFLAG_ALIASES |
+ SLAP_BFLAG_REFERRALS;
+
+ bi->bi_controls = controls;
+
bi->bi_open = 0;
bi->bi_close = 0;
bi->bi_config = 0;
#if SLAPD_NDB == SLAPD_MOD_DYNAMIC
/* conditionally define the init_module() function */
+extern "C" { int init_module( int argc, char *argv[] ); }
+
SLAP_BACKEND_INIT_MODULE( ndb )
#endif /* SLAPD_NDB == SLAPD_MOD_DYNAMIC */