[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts DSMigration.pm.in, 1.14, 1.15
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv5955/ldapserver/ldap/admin/src/scripts
Modified Files:
DSMigration.pm.in
Log Message:
Resolves: bug 262021
Bug Description: Migration script does not migrate nsDS5ReplicaCredentials correctly.
Reviewed by: nhosoi (Thanks!)
Fix Description: We still need to be able to decrypt passwords using the broken method. I guess it works on Solaris and HP because the values are already in network byte order. But when the values were encrypted on x86, they were encrypted the wrong way. It is safe to use MIGRATE_BROKEN_PWD on Solaris and HP because it is essentially a no-op. But this allows us to decrypt x86 passwords and store them correctly.
Platforms tested: RHEL4 i386, RHEL5 x86_64
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: DSMigration.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSMigration.pm.in,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DSMigration.pm.in 14 Sep 2007 21:24:12 -0000 1.14
+++ DSMigration.pm.in 20 Sep 2007 20:27:34 -0000 1.15
@@ -180,7 +180,9 @@
my ($ent, $attr, $mig, $inst) = @_;
my $oldval = $ent->getValues($attr);
debug(3, "Executing @bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\' . . .\n");
+ $ENV{MIGRATE_BROKEN_PWD} = "1"; # passwords prior to 8.0 were encrypted incorrectly
my $newval = `@bindir@/migratecred -o $mig->{actualsroot}/$inst -n @instconfigdir@/$inst -c \'$oldval\'`;
+ delete $ENV{MIGRATE_BROKEN_PWD}; # clear the flag
debug(3, "Converted old value [$oldval] to new value [$newval] for attr $attr in entry ", $ent->getDN(), "\n");
return $newval;
}
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldif2ldbm.c, 1.12, 1.13 vlv_srch.c, 1.7, 1.8
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32368/back-ldbm
Modified Files:
ldif2ldbm.c vlv_srch.c
Log Message:
Resolves: #243820
Summary: Online browsing indexing hangs
Description:
1. adding more shutdown checks in the indexing code to achieve the swift
shutdown even in the long running browsing indexing.
2. in the error case, cleaning up the index file.
3. found minor memory leaks.
Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ldif2ldbm.c 13 Dec 2006 22:21:22 -0000 1.12
+++ ldif2ldbm.c 20 Sep 2007 16:58:41 -0000 1.13
@@ -1264,7 +1264,7 @@
int numvlv = 0;
int return_value = -1;
ID temp_id;
- int i, j;
+ int i, j, vlvidx;
ID lastid;
struct backentry *ep;
char *type;
@@ -1277,6 +1277,9 @@
int index_aid = 0; /* index ancestorid */
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
+ if ( g_get_shutdown() || c_get_shutdown() ) {
+ return -1;
+ }
slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name);
slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li);
@@ -1387,6 +1390,10 @@
slapi_pblock_get(pb, SLAPI_DB2INDEX_ATTRS, &attrs);
for (i = 0; attrs[i] != NULL; i++) {
+ if ( g_get_shutdown() || c_get_shutdown() ) {
+ ret = -1;
+ goto out;
+ }
switch(attrs[i][0]) {
case 't': /* attribute type to index */
db2index_add_indexed_attr(be, attrs[i]);
@@ -1495,6 +1502,10 @@
*/
vlv_acquire_lock(be);
while (1) {
+ if ( g_get_shutdown() || c_get_shutdown() ) {
+ ret = -1;
+ goto out;
+ }
if (idl) {
if (idindex >= idl->b_nids)
break;
@@ -1597,6 +1608,10 @@
slapi_attr_get_type( attr, &type );
for ( j = 0; indexAttrs[j] != NULL; j++ ) {
+ if ( g_get_shutdown() || c_get_shutdown() ) {
+ ret = -1;
+ goto out;
+ }
if (slapi_attr_type_cmp(indexAttrs[j], type,
SLAPI_TYPE_CMP_SUBTYPE) == 0 ) {
back_txn txn;
@@ -1679,9 +1694,13 @@
/*
* Update the Virtual List View indexes
*/
- for ( j = 0; j<numvlv; j++ ) {
+ for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
back_txn txn;
int rc = 0;
+ if ( g_get_shutdown() || c_get_shutdown() ) {
+ ret = -1;
+ goto out;
+ }
if (run_from_cmdline)
{
txn.back_txn_txn = NULL;
@@ -1693,7 +1712,7 @@
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to begin txn for update index '%s'\n",
- inst->inst_name, indexAttrs[j], 0);
+ inst->inst_name, indexAttrs[vlvidx], 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -1701,20 +1720,20 @@
slapi_task_log_notice(task,
"%s: ERROR: failed to begin txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[j], rc, dblayer_strerror(rc));
+ indexAttrs[vlvidx], rc, dblayer_strerror(rc));
}
ret = -2;
goto out;
}
}
- vlv_update_index(pvlv[j], &txn, li, pb, NULL, ep);
+ vlv_update_index(pvlv[vlvidx], &txn, li, pb, NULL, ep);
if (!run_from_cmdline)
{
rc = dblayer_txn_commit(li, &txn);
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to commit txn for update index '%s'\n",
- inst->inst_name, indexAttrs[j], 0);
+ inst->inst_name, indexAttrs[vlvidx], 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -1722,7 +1741,7 @@
slapi_task_log_notice(task,
"%s: ERROR: failed to commit txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[j], rc, dblayer_strerror(rc));
+ indexAttrs[vlvidx], rc, dblayer_strerror(rc));
}
ret = -2;
goto out;
@@ -1810,6 +1829,16 @@
} else {
dbc->c_close(dbc);
}
+ if (ret < 0) {/* error case: undo vlv indexing */
+ struct vlvIndex *p = NULL;
+ /* if jumped to out due to an error, vlv lock has not been released */
+ vlv_release_lock(be);
+ for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ p = pvlv[vlvidx];
+ vlvIndex_go_offline(p, be);
+ vlvIndex_delete(&p);
+ }
+ }
dblayer_release_id2entry( be, db );
instance_set_not_busy(inst);
Index: vlv_srch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv_srch.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- vlv_srch.c 10 Nov 2006 23:45:39 -0000 1.7
+++ vlv_srch.c 20 Sep 2007 16:58:41 -0000 1.8
@@ -245,9 +245,9 @@
for(pi= (*ppvs)->vlv_index;pi!=NULL;)
{
ni= pi->vlv_next;
- if(pi->vlv_be != NULL) {
- vlvIndex_go_offline(pi,pi->vlv_be);
- }
+ if(pi->vlv_be != NULL) {
+ vlvIndex_go_offline(pi,pi->vlv_be);
+ }
vlvIndex_delete(&pi);
pi= ni;
}
@@ -569,6 +569,8 @@
}
ldap_free_sort_keylist((*ppvs)->vlv_sortkey);
attrinfo_delete(&((*ppvs)->vlv_attrinfo));
+ slapi_ch_free((void**)&((*ppvs)->vlv_name));
+ slapi_ch_free((void**)&((*ppvs)->vlv_filename));
slapi_ch_free((void**)&((*ppvs)->vlv_mrpb));
slapi_ch_free((void**)&((*ppvs)->vlv_syntax_plugin));
PR_DestroyLock((*ppvs)->vlv_indexlength_lock);
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd libglobs.c, 1.20, 1.21 proto-slap.h, 1.28, 1.29 connection.c, 1.16, 1.17 daemon.c, 1.14, 1.15 task.c, 1.12, 1.13 monitor.c, 1.6, 1.7 psearch.c, 1.8, 1.9 fe.h, 1.7, 1.8 globals.c, 1.6, 1.7
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31746
Modified Files:
libglobs.c proto-slap.h connection.c daemon.c task.c monitor.c
psearch.c fe.h globals.c
Log Message:
Resolves: #240897
Summary: CRM 1474928 : ds7.1 db index/vlv not handling a stop-slapd, hangs slapd
Description:
1. moved active thread count from ns-slapd to libslapd for the task threads to
use.
2. provided APIs to increment/decrement/get the active thread count
3. let task threads increment the active thread count when it's spawned and
decrement it when it quits.
Index: libglobs.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/libglobs.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- libglobs.c 17 Sep 2007 22:48:10 -0000 1.20
+++ libglobs.c 20 Sep 2007 16:54:38 -0000 1.21
@@ -735,6 +735,29 @@
}
/*
+ * counter for active threads
+ */
+static PRInt32 active_threads = 0;
+
+void
+g_incr_active_threadcnt()
+{
+ PR_AtomicIncrement(&active_threads);
+}
+
+void
+g_decr_active_threadcnt()
+{
+ PR_AtomicDecrement(&active_threads);
+}
+
+int
+g_get_active_threadcnt()
+{
+ return (int)active_threads;
+}
+
+/*
** Setting this flag forces the server to shutdown.
*/
static int slapd_shutdown;
Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- proto-slap.h 11 Jul 2007 01:14:05 -0000 1.28
+++ proto-slap.h 20 Sep 2007 16:54:38 -0000 1.29
@@ -203,6 +203,9 @@
int g_get_deftime();
void be_unbindall( Connection *conn, Operation *op);
int be_nbackends_public();
+void g_incr_active_threadcnt();
+void g_decr_active_threadcnt();
+int g_get_active_threadcnt();
/*
* bind.c
Index: connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/connection.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- connection.c 14 May 2007 22:04:55 -0000 1.16
+++ connection.c 20 Sep 2007 16:54:38 -0000 1.17
@@ -402,7 +402,7 @@
LDAPDebug( LDAP_DEBUG_ANY, "PR_CreateThread failed, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
prerr, slapd_pr_strerror( prerr ), 0 );
} else {
- PR_AtomicIncrement(&active_threads);
+ g_incr_active_threadcnt();
}
}
}
@@ -746,7 +746,7 @@
}
}
}
- PR_AtomicDecrement(&active_threads);
+ g_decr_active_threadcnt();
}
static int handle_read_data(Connection *conn,Operation **op,
@@ -1948,9 +1948,11 @@
No bother to do so much calcuation, short-cut to non-turbo mode if no activities in passed interval */
new_mode = 0;
} else {
+ double activet = 0.0;
connection_find_our_rank(conn,&connection_count, &our_rank);
LDAPDebug(LDAP_DEBUG_CONNS,"conn %d turbo rank = %d out of %d conns\n",conn->c_connid,our_rank,connection_count);
- threshold_rank = (int)((double)active_threads * ((double)CONN_TURBO_PERCENTILE / 100.0) );
+ activet = (double)g_get_active_threadcnt();
+ threshold_rank = (int)(activet * ((double)CONN_TURBO_PERCENTILE / 100.0));
/* adjust threshold_rank according number of connections,
less turbo threads as more connections,
@@ -2023,7 +2025,7 @@
if( op_shutdown ) {
LDAPDebug( LDAP_DEBUG_TRACE,
"op_thread received shutdown signal\n", 0, 0, 0 );
- PR_AtomicDecrement(&active_threads);
+ g_decr_active_threadcnt();
return;
}
@@ -2039,7 +2041,7 @@
case CONN_SHUTDOWN:
LDAPDebug( LDAP_DEBUG_TRACE,
"op_thread received shutdown signal\n", 0, 0, 0 );
- PR_AtomicDecrement(&active_threads);
+ g_decr_active_threadcnt();
return;
case CONN_FOUND_WORK_TO_DO:
default:
@@ -2102,7 +2104,7 @@
case CONN_SHUTDOWN:
LDAPDebug( LDAP_DEBUG_TRACE,
"op_thread received shutdown signal\n", 0, 0, 0 );
- PR_AtomicDecrement(&active_threads);
+ g_decr_active_threadcnt();
return;
default:
break;
@@ -2333,7 +2335,7 @@
#ifdef _WIN32
LDAPDebug( LDAP_DEBUG_ANY,
"slapd shutting down - waiting for %d threads to terminate\n",
- active_threads, 0, 0 );
+ g_get_active_threadcnt(), 0, 0 );
/* kill off each worker waiting on GetQueuedCompletionStatus */
for ( i = 0; i < max_threads; ++ i )
{
Index: daemon.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/daemon.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- daemon.c 3 Aug 2007 22:14:41 -0000 1.14
+++ daemon.c 20 Sep 2007 16:54:38 -0000 1.15
@@ -352,7 +352,7 @@
configure_ns_socket( &ns );
}
#endif
-
+
return ns;
}
@@ -807,15 +807,16 @@
housekeeping_stop(); /* Run this after op_thread_cleanup() logged sth */
#ifndef _WIN32
- if ( active_threads > 0 ) {
+ threads = g_get_active_threadcnt();
+ if ( threads > 0 ) {
LDAPDebug( LDAP_DEBUG_ANY,
"slapd shutting down - waiting for %d thread%s to terminate\n",
- active_threads, ( active_threads > 1 ) ? "s" : "", 0 );
+ threads, ( threads > 1 ) ? "s" : "", 0 );
}
#endif
- threads = active_threads;
- while ( active_threads > 0 ) {
+ threads = g_get_active_threadcnt();
+ while ( threads > 0 ) {
PRPollDesc xpd;
char x;
int spe = 0;
@@ -845,11 +846,11 @@
/* no data */
}
DS_Sleep(PR_INTERVAL_NO_WAIT);
- if ( threads != active_threads ) {
+ if ( threads != g_get_active_threadcnt() ) {
LDAPDebug( LDAP_DEBUG_TRACE,
"slapd shutting down - waiting for %d threads to terminate\n",
- active_threads, 0, 0 );
- threads = active_threads;
+ g_get_active_threadcnt(), 0, 0 );
+ threads = g_get_active_threadcnt();
}
}
@@ -1247,7 +1248,7 @@
snmp_collator_update();
prevtime = curtime;
- num_active_threads = active_threads;
+ num_active_threads = g_get_active_threadcnt();
if ( (num_active_threads == 0) ||
(difftime(curtime, housekeeping_fire_time) >=
slapd_housekeeping_timer*3) ) {
Index: task.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/task.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- task.c 7 Sep 2007 19:08:45 -0000 1.12
+++ task.c 20 Sep 2007 16:54:38 -0000 1.13
@@ -73,9 +73,9 @@
static int task_modify(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
static int task_deny(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
static int task_generic_destructor(Slapi_Task *task);
/* create a new task, fill in DN, and setup modify callback */
@@ -94,16 +94,16 @@
task->task_dn = slapi_ch_strdup(dn);
task->destructor = task_generic_destructor;
slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", task_modify, (void *)task);
+ LDAP_SCOPE_BASE, "(objectclass=*)", task_modify, (void *)task);
slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
+ LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
/* don't add entries under this one */
#if 0
/* don't know why, but this doesn't work. it makes the current add
* operation fail. :(
*/
slapi_config_register_callback(SLAPI_OPERATION_ADD, DSE_FLAG_PREOP, dn,
- LDAP_SCOPE_SUBTREE, "(objectclass=*)", task_deny, NULL);
+ LDAP_SCOPE_SUBTREE, "(objectclass=*)", task_deny, NULL);
#endif
return task;
@@ -139,11 +139,11 @@
}
slapi_config_remove_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP,
- task->task_dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_modify);
+ task->task_dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_modify);
slapi_config_remove_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP,
- task->task_dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny);
+ task->task_dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny);
slapi_delete_internal_set_pb(pb, task->task_dn, NULL, NULL,
- (void *)plugin_get_default_component_id(), 0);
+ (void *)plugin_get_default_component_id(), 0);
slapi_delete_internal_pb(pb);
slapi_pblock_destroy(pb);
@@ -175,7 +175,7 @@
void
slapi_destroy_task(void *arg)
{
- destroy_task(1, arg);
+ destroy_task(1, arg);
}
/********** some useful helper functions **********/
@@ -204,7 +204,7 @@
int ret = 0;
slapi_search_internal_set_pb(pb, dn, LDAP_SCOPE_BASE, "(objectclass=*)",
- NULL, 0, NULL, NULL, (void *)plugin_get_default_component_id(), 0);
+ NULL, 0, NULL, NULL, (void *)plugin_get_default_component_id(), 0);
slapi_search_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
if (ret != LDAP_SUCCESS) {
@@ -225,17 +225,17 @@
static void modify_internal_entry(char *dn, LDAPMod **mods)
{
Slapi_PBlock pb;
- Slapi_Operation *op;
+ Slapi_Operation *op;
int ret = 0;
int tries = 0;
int dont_write_file = 1;
do {
- pblock_init(&pb);
+ pblock_init(&pb);
- slapi_modify_internal_set_pb(&pb, dn, mods, NULL, NULL,
- (void *)plugin_get_default_component_id(), 0);
+ slapi_modify_internal_set_pb(&pb, dn, mods, NULL, NULL,
+ (void *)plugin_get_default_component_id(), 0);
/* all modifications to the cn=tasks subtree are transient --
* we erase them all when the server starts up next time, so there's
@@ -243,10 +243,10 @@
*/
slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &dont_write_file);
- /* Make sure these mods are not logged in audit or changelog */
- slapi_pblock_get(&pb, SLAPI_OPERATION, &op);
- operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
-
+ /* Make sure these mods are not logged in audit or changelog */
+ slapi_pblock_get(&pb, SLAPI_OPERATION, &op);
+ operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
+
slapi_modify_internal_pb(&pb);
slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
if (ret != LDAP_SUCCESS) {
@@ -257,13 +257,13 @@
if (tries == 3) {
LDAPDebug(LDAP_DEBUG_ANY, "WARNING: can't modify task "
"entry '%s'; %s (%d)\n", dn, ldap_err2string(ret), ret);
- pblock_done(&pb);
+ pblock_done(&pb);
return;
}
DS_Sleep(PR_SecondsToInterval(1));
}
- pblock_done(&pb);
+ pblock_done(&pb);
} while (ret != LDAP_SUCCESS);
}
@@ -283,9 +283,9 @@
va_list ap;
if (! task->task_status)
- task->task_status = (char *)slapi_ch_malloc(10 * LOG_BUFFER);
+ task->task_status = (char *)slapi_ch_malloc(10 * LOG_BUFFER);
if (! task->task_status)
- return; /* out of memory? */
+ return; /* out of memory? */
va_start(ap, format);
PR_vsnprintf(task->task_status, (10 * LOG_BUFFER), format, ap);
@@ -308,22 +308,22 @@
len = 2 + strlen(buffer) + (task->task_log ? strlen(task->task_log) : 0);
if ((len > MAX_SCROLLBACK_BUFFER) && task->task_log) {
- size_t i;
- char *newbuf;
+ size_t i;
+ char *newbuf;
- /* start from middle of buffer, and find next linefeed */
- i = strlen(task->task_log)/2;
- while (task->task_log[i] && (task->task_log[i] != '\n'))
- i++;
- if (task->task_log[i])
- i++;
- len = strlen(task->task_log) - i + 2 + strlen(buffer);
- newbuf = (char *)slapi_ch_malloc(len);
- if (! newbuf)
- return; /* out of memory? */
- strcpy(newbuf, task->task_log + i);
- slapi_ch_free((void **)&task->task_log);
- task->task_log = newbuf;
+ /* start from middle of buffer, and find next linefeed */
+ i = strlen(task->task_log)/2;
+ while (task->task_log[i] && (task->task_log[i] != '\n'))
+ i++;
+ if (task->task_log[i])
+ i++;
+ len = strlen(task->task_log) - i + 2 + strlen(buffer);
+ newbuf = (char *)slapi_ch_malloc(len);
+ if (! newbuf)
+ return; /* out of memory? */
+ strcpy(newbuf, task->task_log + i);
+ slapi_ch_free((void **)&task->task_log);
+ task->task_log = newbuf;
} else {
if (! task->task_log) {
task->task_log = (char *)slapi_ch_malloc(len);
@@ -331,8 +331,8 @@
} else {
task->task_log = (char *)slapi_ch_realloc(task->task_log, len);
}
- if (! task->task_log)
- return; /* out of memory? */
+ if (! task->task_log)
+ return; /* out of memory? */
}
if (task->task_log[0])
@@ -359,7 +359,7 @@
static int task_deny(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
/* internal operations (conn=NULL) are allowed to do whatever they want */
if (pb->pb_conn == NULL) {
@@ -372,7 +372,7 @@
}
static int task_modify(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
Slapi_Task *task = (Slapi_Task *)arg;
LDAPMod **mods;
@@ -420,7 +420,7 @@
}
static int task_import_add(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
Slapi_Attr *attr;
Slapi_Value *val = NULL;
@@ -433,7 +433,7 @@
Slapi_PBlock mypb;
Slapi_Task *task;
char *nameFrombe_name = NULL;
- const char *encrypt_on_import = NULL;
+ const char *encrypt_on_import = NULL;
if ((cn = fetch_attr(e, "cn", NULL)) == NULL) {
*returncode = LDAP_OBJECT_CLASS_VIOLATION;
@@ -465,40 +465,40 @@
char **instances, **ip;
int counter;
- if (slapi_lookup_instance_name_by_suffixes(include, exclude,
- &instances) < 0) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: No backend instance is specified.\n", 0, 0, 0);
- *returncode = LDAP_OBJECT_CLASS_VIOLATION;
- return SLAPI_DSE_CALLBACK_ERROR;
- }
+ if (slapi_lookup_instance_name_by_suffixes(include, exclude,
+ &instances) < 0) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: No backend instance is specified.\n", 0, 0, 0);
+ *returncode = LDAP_OBJECT_CLASS_VIOLATION;
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
if (instances) {
for (ip = instances, counter = 0; ip && *ip; ip++, counter++)
;
- if (counter == 1){
- instance_name = *instances;
- nameFrombe_name = *instances;
-
- }
- else if (counter == 0) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: No backend instance is specified.\n", 0, 0, 0);
- *returncode = LDAP_OBJECT_CLASS_VIOLATION;
- return SLAPI_DSE_CALLBACK_ERROR;
- } else {
- LDAPDebug(LDAP_DEBUG_ANY,
- "ERROR: Multiple backend instances are specified: "
- "%s, %s, ...\n", instances[0], instances[1], 0);
- *returncode = LDAP_OBJECT_CLASS_VIOLATION;
- return SLAPI_DSE_CALLBACK_ERROR;
- }
- } else {
- *returncode = LDAP_OBJECT_CLASS_VIOLATION;
- return SLAPI_DSE_CALLBACK_ERROR;
- }
- }
+ if (counter == 1){
+ instance_name = *instances;
+ nameFrombe_name = *instances;
+
+ }
+ else if (counter == 0) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: No backend instance is specified.\n", 0, 0, 0);
+ *returncode = LDAP_OBJECT_CLASS_VIOLATION;
+ return SLAPI_DSE_CALLBACK_ERROR;
+ } else {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "ERROR: Multiple backend instances are specified: "
+ "%s, %s, ...\n", instances[0], instances[1], 0);
+ *returncode = LDAP_OBJECT_CLASS_VIOLATION;
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
+ } else {
+ *returncode = LDAP_OBJECT_CLASS_VIOLATION;
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
+ }
/* lookup the backend */
be = slapi_be_select_by_instance_name(instance_name);
@@ -576,9 +576,9 @@
mypb.pb_ldif_exclude = exclude;
mypb.pb_task = task;
mypb.pb_task_flags = TASK_RUNNING_AS_TASK;
- if (NULL != encrypt_on_import && 0 == strcasecmp(encrypt_on_import, "true") ) {
- mypb.pb_ldif_encrypt = 1;
- }
+ if (NULL != encrypt_on_import && 0 == strcasecmp(encrypt_on_import, "true") ) {
+ mypb.pb_ldif_encrypt = 1;
+ }
rv = (*mypb.pb_plugin->plg_ldif2db)(&mypb);
if (rv == 0) {
@@ -615,6 +615,7 @@
int count;
Slapi_Task *task = pb->pb_task;
+ g_incr_active_threadcnt();
for (count = 0, inp = instance_names; *inp; inp++, count++)
;
task->task_work = count;
@@ -623,7 +624,7 @@
slapi_task_status_changed(task);
for (inp = instance_names; *inp; inp++) {
- int release_me = 0;
+ int release_me = 0;
/* lookup the backend */
be = slapi_be_select_by_instance_name((const char *)*inp);
if (be == NULL) {
@@ -639,39 +640,39 @@
/* ldif_file name for each? */
if (pb->pb_ldif_printkey & EXPORT_APPENDMODE) {
- if (inp == instance_names) { /* first export */
- pb->pb_ldif_printkey |= EXPORT_APPENDMODE_1;
- } else {
- pb->pb_ldif_printkey &= ~EXPORT_APPENDMODE_1;
- }
- } else {
- if (strcmp(ldif_file, "-")) { /* not '-' */
- char *p;
+ if (inp == instance_names) { /* first export */
+ pb->pb_ldif_printkey |= EXPORT_APPENDMODE_1;
+ } else {
+ pb->pb_ldif_printkey &= ~EXPORT_APPENDMODE_1;
+ }
+ } else {
+ if (strcmp(ldif_file, "-")) { /* not '-' */
+ char *p;
#if defined( _WIN32 )
- char sep = '\\';
- if (NULL != strchr(ldif_file, '/'))
- sep = '/';
+ char sep = '\\';
+ if (NULL != strchr(ldif_file, '/'))
+ sep = '/';
#else
- char sep = '/';
+ char sep = '/';
#endif
- this_ldif_file = (char *)slapi_ch_malloc(strlen(ldif_file) +
+ this_ldif_file = (char *)slapi_ch_malloc(strlen(ldif_file) +
strlen(*inp) + 2);
- p = strrchr(ldif_file, sep);
- if (NULL == p) {
- sprintf(this_ldif_file, "%s_%s", *inp, ldif_file);
- } else {
- char *q;
-
- q = p + 1;
- *p = '\0';
- sprintf(this_ldif_file, "%s%c%s_%s",
- ldif_file, sep, *inp, q);
- *p = sep;
- }
- pb->pb_ldif_file = this_ldif_file;
- release_me = 1;
- }
- }
+ p = strrchr(ldif_file, sep);
+ if (NULL == p) {
+ sprintf(this_ldif_file, "%s_%s", *inp, ldif_file);
+ } else {
+ char *q;
+
+ q = p + 1;
+ *p = '\0';
+ sprintf(this_ldif_file, "%s%c%s_%s",
+ ldif_file, sep, *inp, q);
+ *p = sep;
+ }
+ pb->pb_ldif_file = this_ldif_file;
+ release_me = 1;
+ }
+ }
slapi_task_log_notice(task, "Beginning export of '%s'", *inp);
LDAPDebug(LDAP_DEBUG_ANY, "Beginning export of '%s'\n", *inp, 0, 0);
@@ -714,10 +715,11 @@
task->task_exitcode = rv;
task->task_state = SLAPI_TASK_FINISHED;
slapi_task_status_changed(task);
+ g_decr_active_threadcnt();
}
static int task_export_add(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
Slapi_Attr *attr;
Slapi_Value *val = NULL;
@@ -748,16 +750,16 @@
goto out;
}
- decrypt_on_export = fetch_attr(e, "nsExportDecrypt", NULL);
+ decrypt_on_export = fetch_attr(e, "nsExportDecrypt", NULL);
/* nsInstances -- from here on, memory has been allocated */
if (slapi_entry_attr_find(e, "nsInstance", &attr) == 0) {
- for (idx = slapi_attr_first_value(attr, &val);
+ for (idx = slapi_attr_first_value(attr, &val);
idx >= 0; idx = slapi_attr_next_value(attr, idx, &val)) {
charray_add(&instance_names,
slapi_ch_strdup(slapi_value_get_string(val)));
instance_cnt++;
- }
+ }
}
/* include/exclude suffixes */
@@ -879,7 +881,7 @@
}
if (be->be_database->plg_db2ldif == NULL) {
LDAPDebug(LDAP_DEBUG_ANY, "ERROR: no db2ldif function defined for "
- "backend %s\n", be->be_database->plg_name, 0, 0);
+ "backend %s\n", be->be_database->plg_name, 0, 0);
*returncode = LDAP_UNWILLING_TO_PERFORM;
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
@@ -914,14 +916,14 @@
mypb->pb_instance_name = (char *)instance_names;
mypb->pb_task = task;
mypb->pb_task_flags = TASK_RUNNING_AS_TASK;
- if (NULL != decrypt_on_export && 0 == strcasecmp(decrypt_on_export, "true") ) {
- mypb->pb_ldif_encrypt = 1;
- }
+ if (NULL != decrypt_on_export && 0 == strcasecmp(decrypt_on_export, "true") ) {
+ mypb->pb_ldif_encrypt = 1;
+ }
/* start the export as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_export_thread,
- (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
- PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
+ (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
if (thread == NULL) {
LDAPDebug(LDAP_DEBUG_ANY,
"unable to create ldbm2ldif thread!\n", 0, 0, 0);
@@ -955,6 +957,7 @@
Slapi_Task *task = pb->pb_task;
int rv;
+ g_incr_active_threadcnt();
task->task_work = 1;
task->task_progress = 0;
task->task_state = SLAPI_TASK_RUNNING;
@@ -983,10 +986,11 @@
slapi_ch_free((void **)&pb->pb_seq_val);
slapi_pblock_destroy(pb);
+ g_decr_active_threadcnt();
}
static int task_backup_add(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
Slapi_Backend *be = NULL;
PRThread *thread = NULL;
@@ -1070,8 +1074,8 @@
/* start the backup as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_backup_thread,
- (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
- PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
+ (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
if (thread == NULL) {
LDAPDebug(LDAP_DEBUG_ANY,
"unable to create backup thread!\n", 0, 0, 0);
@@ -1099,6 +1103,7 @@
Slapi_Task *task = pb->pb_task;
int rv;
+ g_incr_active_threadcnt();
task->task_work = 1;
task->task_progress = 0;
task->task_state = SLAPI_TASK_RUNNING;
@@ -1127,10 +1132,11 @@
slapi_ch_free((void **)&pb->pb_seq_val);
slapi_pblock_destroy(pb);
+ g_decr_active_threadcnt();
}
static int task_restore_add(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
Slapi_Backend *be = NULL;
const char *cn = NULL;
@@ -1222,8 +1228,8 @@
/* start the restore as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_restore_thread,
- (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
- PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
+ (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
if (thread == NULL) {
LDAPDebug(LDAP_DEBUG_ANY,
"unable to create restore thread!\n", 0, 0, 0);
@@ -1251,6 +1257,7 @@
Slapi_Task *task = pb->pb_task;
int rv;
+ g_incr_active_threadcnt();
task->task_work = 1;
task->task_progress = 0;
task->task_state = SLAPI_TASK_RUNNING;
@@ -1271,10 +1278,11 @@
charray_free(pb->pb_db2index_attrs);
slapi_ch_free((void **)&pb->pb_instance_name);
slapi_pblock_destroy(pb);
+ g_decr_active_threadcnt();
}
static int task_index_add(Slapi_PBlock *pb, Slapi_Entry *e,
- Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
+ Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg)
{
const char *instance_name;
const char *cn;
@@ -1317,7 +1325,7 @@
/* normal indexes */
if (slapi_entry_attr_find(e, "nsIndexAttribute", &attr) == 0) {
- for (idx = slapi_attr_first_value(attr, &val);
+ for (idx = slapi_attr_first_value(attr, &val);
idx >= 0; idx = slapi_attr_next_value(attr, idx, &val)) {
const char *indexname = slapi_value_get_string(val);
char *index = slapi_ch_smprintf("t%s", indexname);
@@ -1325,12 +1333,12 @@
if (index != NULL) {
charray_add(&indexlist, index);
}
- }
+ }
}
/* vlv indexes */
if (slapi_entry_attr_find(e, "nsIndexVlvAttribute", &attr) == 0) {
- for (idx = slapi_attr_first_value(attr, &val);
+ for (idx = slapi_attr_first_value(attr, &val);
idx >= 0; idx = slapi_attr_next_value(attr, idx, &val)) {
const char *indexname = slapi_value_get_string(val);
char *index = slapi_ch_smprintf("T%s", indexname);
@@ -1338,7 +1346,7 @@
if (index != NULL) {
charray_add(&indexlist, index);
}
- }
+ }
}
if (NULL == indexlist) {
@@ -1375,8 +1383,8 @@
/* start the db2index as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_index_thread,
- (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
- PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
+ (void *)mypb, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+ PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE);
if (thread == NULL) {
LDAPDebug(LDAP_DEBUG_ANY,
"unable to create index thread!\n", 0, 0, 0);
@@ -1576,62 +1584,62 @@
*/
void task_cleanup(void)
{
- Slapi_PBlock *pb = slapi_pblock_new();
- Slapi_Entry **entries = NULL;
- int ret = 0, i, x;
- Slapi_DN *rootDN;
-
- slapi_search_internal_set_pb(pb, TASK_BASE_DN, LDAP_SCOPE_SUBTREE,
- "(objectclass=*)", NULL, 0, NULL, NULL,
- (void *)plugin_get_default_component_id(), 0);
- slapi_search_internal_pb(pb);
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
- if (ret != LDAP_SUCCESS) {
- LDAPDebug(LDAP_DEBUG_ANY, "WARNING: entire cn=tasks tree seems to "
- "be AWOL!\n", 0, 0, 0);
- slapi_pblock_destroy(pb);
- return;
- }
-
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
- if (NULL == entries) {
- LDAPDebug(LDAP_DEBUG_ANY, "WARNING: entire cn=tasks tree seems to "
- "be AWOL!\n", 0, 0, 0);
- slapi_pblock_destroy(pb);
- return;
- }
-
- rootDN = slapi_sdn_new_dn_byval(TASK_BASE_DN);
-
- /* rotate through entries, skipping the base dn */
- for (i = 0; entries[i] != NULL; i++) {
- const Slapi_DN *sdn = slapi_entry_get_sdn_const(entries[i]);
- Slapi_PBlock *mypb;
- Slapi_Operation *op;
-
- if (slapi_sdn_compare(sdn, rootDN) == 0)
- continue;
-
- mypb = slapi_pblock_new();
- if (mypb == NULL) {
- continue;
- }
- slapi_delete_internal_set_pb(mypb, slapi_sdn_get_dn(sdn), NULL, NULL,
- plugin_get_default_component_id(), 0);
-
- /* Make sure these deletes don't appear in the audit and change logs */
- slapi_pblock_get(mypb, SLAPI_OPERATION, &op);
- operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
-
- x = 1;
- slapi_pblock_set(mypb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &x);
- slapi_delete_internal_pb(mypb);
- slapi_pblock_destroy(mypb);
- }
-
- slapi_sdn_free(&rootDN);
- slapi_free_search_results_internal(pb);
- slapi_pblock_destroy(pb);
+ Slapi_PBlock *pb = slapi_pblock_new();
+ Slapi_Entry **entries = NULL;
+ int ret = 0, i, x;
+ Slapi_DN *rootDN;
+
+ slapi_search_internal_set_pb(pb, TASK_BASE_DN, LDAP_SCOPE_SUBTREE,
+ "(objectclass=*)", NULL, 0, NULL, NULL,
+ (void *)plugin_get_default_component_id(), 0);
+ slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
+ if (ret != LDAP_SUCCESS) {
+ LDAPDebug(LDAP_DEBUG_ANY, "WARNING: entire cn=tasks tree seems to "
+ "be AWOL!\n", 0, 0, 0);
+ slapi_pblock_destroy(pb);
+ return;
+ }
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ if (NULL == entries) {
+ LDAPDebug(LDAP_DEBUG_ANY, "WARNING: entire cn=tasks tree seems to "
+ "be AWOL!\n", 0, 0, 0);
+ slapi_pblock_destroy(pb);
+ return;
+ }
+
+ rootDN = slapi_sdn_new_dn_byval(TASK_BASE_DN);
+
+ /* rotate through entries, skipping the base dn */
+ for (i = 0; entries[i] != NULL; i++) {
+ const Slapi_DN *sdn = slapi_entry_get_sdn_const(entries[i]);
+ Slapi_PBlock *mypb;
+ Slapi_Operation *op;
+
+ if (slapi_sdn_compare(sdn, rootDN) == 0)
+ continue;
+
+ mypb = slapi_pblock_new();
+ if (mypb == NULL) {
+ continue;
+ }
+ slapi_delete_internal_set_pb(mypb, slapi_sdn_get_dn(sdn), NULL, NULL,
+ plugin_get_default_component_id(), 0);
+
+ /* Make sure these deletes don't appear in the audit and change logs */
+ slapi_pblock_get(mypb, SLAPI_OPERATION, &op);
+ operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
+
+ x = 1;
+ slapi_pblock_set(mypb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &x);
+ slapi_delete_internal_pb(mypb);
+ slapi_pblock_destroy(mypb);
+ }
+
+ slapi_sdn_free(&rootDN);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
}
/* name is, for exmaple, "import" */
@@ -1639,7 +1647,7 @@
{
char *dn = NULL;
Slapi_PBlock *pb = NULL;
- Slapi_Operation *op;
+ Slapi_Operation *op;
LDAPMod *mods[3];
LDAPMod mod[3];
const char *objectclass[3];
@@ -1676,10 +1684,10 @@
plugin_get_default_component_id(), 0);
x = 1;
slapi_pblock_set(pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &x);
- /* Make sure these adds don't appear in the audit and change logs */
- slapi_pblock_get(pb, SLAPI_OPERATION, &op);
- operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
-
+ /* Make sure these adds don't appear in the audit and change logs */
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
+ operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
+
slapi_add_internal_pb(pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &x);
if ((x != LDAP_SUCCESS) && (x != LDAP_ALREADY_EXISTS)) {
@@ -1692,12 +1700,12 @@
/* register add callback */
slapi_config_register_callback(SLAPI_OPERATION_ADD, DSE_FLAG_PREOP,
- dn, LDAP_SCOPE_SUBTREE, "(objectclass=*)", func, NULL);
+ dn, LDAP_SCOPE_SUBTREE, "(objectclass=*)", func, NULL);
/* deny modify/delete of the root task entry */
slapi_config_register_callback(SLAPI_OPERATION_MODIFY, DSE_FLAG_PREOP,
- dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
+ dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
slapi_config_register_callback(SLAPI_OPERATION_DELETE, DSE_FLAG_PREOP,
- dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
+ dn, LDAP_SCOPE_BASE, "(objectclass=*)", task_deny, NULL);
ret = 0;
Index: monitor.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/monitor.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- monitor.c 10 Nov 2006 23:45:40 -0000 1.6
+++ monitor.c 20 Sep 2007 16:54:38 -0000 1.7
@@ -86,7 +86,7 @@
attrlist_replace( &e->e_attrs, "version", vals );
slapi_ch_free( (void **) &val.bv_val );
- sprintf( buf, "%d", active_threads );
+ sprintf( buf, "%d", g_get_active_threadcnt() );
val.bv_val = buf;
val.bv_len = strlen( buf );
attrlist_replace( &e->e_attrs, "threads", vals );
Index: psearch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/psearch.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- psearch.c 10 Nov 2006 23:45:40 -0000 1.8
+++ psearch.c 20 Sep 2007 16:54:38 -0000 1.9
@@ -295,7 +295,7 @@
char **pbattrs = NULL;
int conn_acq_flag = 0;
- PR_AtomicIncrement( &active_threads );
+ g_incr_active_threadcnt();
/* need to acquire a reference to this connection so that it will not
be released or cleaned up out from under us */
@@ -443,7 +443,7 @@
pe_ch_free( &peq );
}
slapi_ch_free((void **) &ps );
- PR_AtomicDecrement(&active_threads);
+ g_decr_active_threadcnt();
}
Index: fe.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/fe.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- fe.h 3 Aug 2007 22:14:41 -0000 1.7
+++ fe.h 20 Sep 2007 16:54:38 -0000 1.8
@@ -56,7 +56,6 @@
#endif /* DONT_DECLARE_SLAPD_LDAP_DEBUG */
#endif
#endif
-extern int active_threads;
extern PRInt32 ops_initiated;
extern PRInt32 ops_completed;
extern PRLock *ops_mutex;
Index: globals.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/globals.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- globals.c 10 Nov 2006 23:45:40 -0000 1.6
+++ globals.c 20 Sep 2007 16:54:38 -0000 1.7
@@ -88,14 +88,12 @@
/*
* global variables that need mutex protection
*/
-int active_threads;
PRInt32 ops_initiated;
PRInt32 ops_completed;
PRLock *ops_mutex;
int num_conns;
PRLock *num_conns_mutex;
-
/*
DEC/COMPAQ has released a patch for 4.0d (e?) which will speed up
malloc/free considerably in multithreaded multiprocessor
16 years, 7 months
[Fedora-directory-commits] admservconsole/help/en footer.html, 1.1, 1.2 tokens.map, 1.1, 1.2
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/admservconsole/help/en
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30516
Modified Files:
footer.html tokens.map
Log Message:
Use less restrictive version of Open Publication License for online help docs.
Index: footer.html
===================================================================
RCS file: /cvs/dirsec/admservconsole/help/en/footer.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- footer.html 9 Aug 2007 16:04:03 -0000 1.1
+++ footer.html 20 Sep 2007 16:33:13 -0000 1.2
@@ -12,15 +12,6 @@
forth in the Open Publication License, V1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
</p>
- <p class="copy">
- Distribution of substantively modified versions of this document is prohibited
- without the explicit permission of the copyright holder.
- </p>
- <p class="copy">
- Distribution of the work or derivative of the work in any standard (paper)
- book form for commercial purposes is prohibited unless prior permission
- is obtained from the copyright holder.
- </p>
<!-- END COPYRIGHT BLOCK -->
<br />
</body>
Index: tokens.map
===================================================================
RCS file: /cvs/dirsec/admservconsole/help/en/tokens.map,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tokens.map 9 Aug 2007 16:04:03 -0000 1.1
+++ tokens.map 20 Sep 2007 16:33:13 -0000 1.2
@@ -5,14 +5,8 @@
; This material may be distributed only subject to the terms and conditions set
; forth in the Open Publication License, V1.0 or later (the latest version is
; presently available at http://www.opencontent.org/openpub/).
-;
-; Distribution of substantively modified versions of this document is prohibited
-; without the explicit permission of the copyright holder.
-;
-; Distribution of the work or derivative of the work in any standard (paper)
-; book form for commercial purposes is prohibited unless prior permission
-; is obtained from the copyright holder.
; END COPYRIGHT BLOCK
+
; This is the mapping file for Admin Server online help.
; each directory is relative to <server_root>/manual/en/admin/
16 years, 7 months
[Fedora-directory-commits] directoryconsole/help/en footer.html, 1.1, 1.2
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/directoryconsole/help/en
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30362
Modified Files:
footer.html
Log Message:
Use less restrictive version of Open Publication License for online help docs.
Index: footer.html
===================================================================
RCS file: /cvs/dirsec/directoryconsole/help/en/footer.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- footer.html 13 Aug 2007 22:28:09 -0000 1.1
+++ footer.html 20 Sep 2007 16:30:55 -0000 1.2
@@ -12,15 +12,6 @@
forth in the Open Publication License, V1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
</p>
- <p class="copy">
- Distribution of substantively modified versions of this document is prohibited
- without the explicit permission of the copyright holder.
- </p>
- <p class="copy">
- Distribution of the work or derivative of the work in any standard (paper)
- book form for commercial purposes is prohibited unless prior permission
- is obtained from the copyright holder.
- </p>
<!-- END COPYRIGHT BLOCK -->
<br />
</body>
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/docs/dirhlp/help account_mgmt.htm, 1.4, NONE adv_search.htm, 1.4, NONE configtab_chaindb.htm, 1.4, NONE configtab_chaindb2.htm, 1.4, NONE configtab_chaindb3.htm, 1.4, NONE configtab_chaindb4.htm, 1.5, NONE configtab_chaindb5.htm, 1.4, NONE configtab_chaindb6.htm, 1.4, NONE configtab_chaindb7.htm, 1.4, NONE configtab_db.htm, 1.4, NONE configtab_db10.htm, 1.4, NONE configtab_db11.htm, 1.4, NONE configtab_db12.htm, 1.4, NONE configtab_db13.htm, 1.4, NONE configtab_db1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/docs/dirhlp/help
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22659/dirhlp/help
Removed Files:
account_mgmt.htm adv_search.htm configtab_chaindb.htm
configtab_chaindb2.htm configtab_chaindb3.htm
configtab_chaindb4.htm configtab_chaindb5.htm
configtab_chaindb6.htm configtab_chaindb7.htm configtab_db.htm
configtab_db10.htm configtab_db11.htm configtab_db12.htm
configtab_db13.htm configtab_db14.htm configtab_db15.htm
configtab_db2.htm configtab_db3.htm configtab_db4.htm
configtab_db5.htm configtab_db6.htm configtab_db7.htm
configtab_db8.htm configtab_db9.htm configtab_ldbmdb.htm
configtab_logs.htm configtab_logs2.htm configtab_logs3.htm
configtab_maptree.htm configtab_maptree2.htm
configtab_maptree3.htm configtab_maptree4.htm
configtab_maptree5.htm configtab_maptree6.htm
configtab_maptree7.htm configtab_plugins.htm
configtab_replication.htm configtab_replication2.htm
configtab_replication3.htm configtab_replication4.htm
configtab_replication5.htm configtab_replication6.htm
configtab_replication7.htm configtab_replication8.htm
configtab_rootnode.htm configtab_rootnode2.htm
configtab_rootnode3.htm configtab_rootnode4.htm
configtab_rootnode5.htm configtab_rootnode6.htm
configtab_rootnode7.htm configtab_rootnode8.htm
configtab_rootnode9.htm configtab_schema.htm
configtab_schema2.htm configtab_schema3.htm
configtab_schema4.htm configtab_schema5.htm
configtab_synchronization1.htm configtab_synchronization2.htm
configtab_synchronization3.htm dir_browser.htm
dir_browser2.htm dir_browser3.htm dir_browser4.htm
dirtab_cos.htm dirtab_cos2.htm dirtab_cos3.htm dirtab_role.htm
dirtab_role2.htm dirtab_role3.htm dirtab_role4.htm
dirtab_role5.htm dirtab_role6.htm dirtab_role7.htm
helpmenu.htm ix.htm ldapurl.htm netscape32.gif
new_instance.htm pixel.gif property_editor.htm
property_editor2.htm property_editor3.htm property_editor4.htm
redir_agtoc.htm redir_dochome.htm replication_wizard.htm
replication_wizard2.htm replication_wizard3.htm
replication_wizard4.htm replication_wizard5.htm
replication_wizard6.htm sniffer.js statustab_general.htm
statustab_logs.htm statustab_logs2.htm statustab_logs3.htm
statustab_performance.htm statustab_performance2.htm
statustab_replication.htm synchronization_wizard1.htm
synchronization_wizard2.htm synchronization_wizard3.htm
taskstab_bkup_restore.htm taskstab_bkup_restore2.htm
topics.htm
Log Message:
Removed online help docs now that they've been moved to directoryconsole.
--- account_mgmt.htm DELETED ---
--- adv_search.htm DELETED ---
--- configtab_chaindb.htm DELETED ---
--- configtab_chaindb2.htm DELETED ---
--- configtab_chaindb3.htm DELETED ---
--- configtab_chaindb4.htm DELETED ---
--- configtab_chaindb5.htm DELETED ---
--- configtab_chaindb6.htm DELETED ---
--- configtab_chaindb7.htm DELETED ---
--- configtab_db.htm DELETED ---
--- configtab_db10.htm DELETED ---
--- configtab_db11.htm DELETED ---
--- configtab_db12.htm DELETED ---
--- configtab_db13.htm DELETED ---
--- configtab_db14.htm DELETED ---
--- configtab_db15.htm DELETED ---
--- configtab_db2.htm DELETED ---
--- configtab_db3.htm DELETED ---
--- configtab_db4.htm DELETED ---
--- configtab_db5.htm DELETED ---
--- configtab_db6.htm DELETED ---
--- configtab_db7.htm DELETED ---
--- configtab_db8.htm DELETED ---
--- configtab_db9.htm DELETED ---
--- configtab_ldbmdb.htm DELETED ---
--- configtab_logs.htm DELETED ---
--- configtab_logs2.htm DELETED ---
--- configtab_logs3.htm DELETED ---
--- configtab_maptree.htm DELETED ---
--- configtab_maptree2.htm DELETED ---
--- configtab_maptree3.htm DELETED ---
--- configtab_maptree4.htm DELETED ---
--- configtab_maptree5.htm DELETED ---
--- configtab_maptree6.htm DELETED ---
--- configtab_maptree7.htm DELETED ---
--- configtab_plugins.htm DELETED ---
--- configtab_replication.htm DELETED ---
--- configtab_replication2.htm DELETED ---
--- configtab_replication3.htm DELETED ---
--- configtab_replication4.htm DELETED ---
--- configtab_replication5.htm DELETED ---
--- configtab_replication6.htm DELETED ---
--- configtab_replication7.htm DELETED ---
--- configtab_replication8.htm DELETED ---
--- configtab_rootnode.htm DELETED ---
--- configtab_rootnode2.htm DELETED ---
--- configtab_rootnode3.htm DELETED ---
--- configtab_rootnode4.htm DELETED ---
--- configtab_rootnode5.htm DELETED ---
--- configtab_rootnode6.htm DELETED ---
--- configtab_rootnode7.htm DELETED ---
--- configtab_rootnode8.htm DELETED ---
--- configtab_rootnode9.htm DELETED ---
--- configtab_schema.htm DELETED ---
--- configtab_schema2.htm DELETED ---
--- configtab_schema3.htm DELETED ---
--- configtab_schema4.htm DELETED ---
--- configtab_schema5.htm DELETED ---
--- configtab_synchronization1.htm DELETED ---
--- configtab_synchronization2.htm DELETED ---
--- configtab_synchronization3.htm DELETED ---
--- dir_browser.htm DELETED ---
--- dir_browser2.htm DELETED ---
--- dir_browser3.htm DELETED ---
--- dir_browser4.htm DELETED ---
--- dirtab_cos.htm DELETED ---
--- dirtab_cos2.htm DELETED ---
--- dirtab_cos3.htm DELETED ---
--- dirtab_role.htm DELETED ---
--- dirtab_role2.htm DELETED ---
--- dirtab_role3.htm DELETED ---
--- dirtab_role4.htm DELETED ---
--- dirtab_role5.htm DELETED ---
--- dirtab_role6.htm DELETED ---
--- dirtab_role7.htm DELETED ---
--- helpmenu.htm DELETED ---
--- ix.htm DELETED ---
--- ldapurl.htm DELETED ---
--- new_instance.htm DELETED ---
--- property_editor.htm DELETED ---
--- property_editor2.htm DELETED ---
--- property_editor3.htm DELETED ---
--- property_editor4.htm DELETED ---
--- redir_agtoc.htm DELETED ---
--- redir_dochome.htm DELETED ---
--- replication_wizard.htm DELETED ---
--- replication_wizard2.htm DELETED ---
--- replication_wizard3.htm DELETED ---
--- replication_wizard4.htm DELETED ---
--- replication_wizard5.htm DELETED ---
--- replication_wizard6.htm DELETED ---
--- sniffer.js DELETED ---
--- statustab_general.htm DELETED ---
--- statustab_logs.htm DELETED ---
--- statustab_logs2.htm DELETED ---
--- statustab_logs3.htm DELETED ---
--- statustab_performance.htm DELETED ---
--- statustab_performance2.htm DELETED ---
--- statustab_replication.htm DELETED ---
--- synchronization_wizard1.htm DELETED ---
--- synchronization_wizard2.htm DELETED ---
--- synchronization_wizard3.htm DELETED ---
--- taskstab_bkup_restore.htm DELETED ---
--- taskstab_bkup_restore2.htm DELETED ---
--- topics.htm DELETED ---
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/docs/dirhlp Makefile, 1.5, NONE dssynchhelp.z, 1.1.1.1, NONE index.htm, 1.4, NONE index.map, 1.2, NONE pixel.gif, 1.1.1.1, NONE tokens.map, 1.3, NONE topicindex.htm, 1.1.1.1, NONE
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/docs/dirhlp
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22659/dirhlp
Removed Files:
Makefile dssynchhelp.z index.htm index.map pixel.gif
tokens.map topicindex.htm
Log Message:
Removed online help docs now that they've been moved to directoryconsole.
--- Makefile DELETED ---
--- dssynchhelp.z DELETED ---
--- index.htm DELETED ---
--- index.map DELETED ---
--- tokens.map DELETED ---
--- topicindex.htm DELETED ---
16 years, 7 months
[Fedora-directory-commits] adminserver/admserv/newinst/src AdminServer.pm.in, 1.10, 1.11
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19540
Modified Files:
AdminServer.pm.in
Log Message:
One character fix: added ';'
Index: AdminServer.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminServer.pm.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AdminServer.pm.in 18 Sep 2007 17:11:47 -0000 1.10
+++ AdminServer.pm.in 20 Sep 2007 01:01:21 -0000 1.11
@@ -332,7 +332,7 @@
}
my @contents = <CONSOLECONF>;
close (CONSOLECONF);
- grep { s/^Group.*$/Group $admConf->{sysgroup}/ } @contents
+ grep { s/^Group.*$/Group $admConf->{sysgroup}/ } @contents;
if (!open(CONSOLECONF, ">$admConf->{configdir}/console.conf")) {
debug(0, "Error writing new group $admConf->{sysgroup} to $admConf->{configdir}/console.conf: $!");
return 0;
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm import.c, 1.8, 1.9
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1730/ldapserver/ldap/servers/slapd/back-ldbm
Modified Files:
import.c
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on interger attributes value greater than 231
Reviewed by: nhosoi (Thanks!)
Fix Description: The problem is that the current code uses atol() to convert the string value to an integer. long is 4 bytes or 8 bytes depending on the underlying platform. These binary values are stored in the index as 4 or 8 byte values. Finally, the behavior of atol() is different on the platform in overflow cases. Instead of dealing with binary values, we must store the values in string format, and perform string comparison, string normalization, and string key generation on INTEGER syntax values. I added another syntax type to the list in syntax.h. The code in string.c and value.c was mostly usable. I had to add some code in value_normalize to handle cases like " -00000001" -> "-1" to make it work like atol(), and I had to add some code to value_cmp to handle the sign (e.g. positive is always greater than negative, no other comparison is necessary) and magnitude (longer number is larger/smaller than shorter number, depending on sign). Otherwise, strcmp() doe!
s the right thing (e.g. "50" > "49", the same as int(50) > int(49)). One problem I ran into was that the value_normalize code takes just a char *, rather than a berval* or a char * + size_t length. To be efficient, this function should return the new length of the normalized string. Fortunately, none of the existing code cares about the length, but I needed the length for magnitude comparison, so I just used strlen for those cases. Which should be fine. value_normalize always produces a correctly null terminated string. I rewrote the value_cmp code to use a simple if rather than the switch statement. This makes it much clearer - if syntax is case insensitive, use slapi_utf8casecmp - if case sensitive, use strcmp - otherwise, error.
I also found a problem with the ldif2db code, which I uncovered because I added my integer indexes online and did an online import. The db2index code will correctly clear the INDEX_OFFLINE bit after the index is completed, but the ldif2db code will not.
Platforms tested: RHEL5 x86_64
Flag Day: Yes, if you are upgrading and you have integer valued indexes, you will have to remove them and recreate them.
Doc impact: We will have to document this in the release notes.
Index: import.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- import.c 10 Nov 2006 23:45:39 -0000 1.8
+++ import.c 19 Sep 2007 19:32:03 -0000 1.9
@@ -1054,6 +1054,20 @@
}
if (job->flags & FLAG_ONLINE) {
+ /* make sure the indexes are online as well */
+ /* richm 20070919 - if index entries are added online, they
+ are created and marked as INDEX_OFFLINE, in anticipation
+ of someone doing a db2index. In this case, the db2index
+ code will correctly unset the INDEX_OFFLINE flag.
+ However, if import is used to create the indexes, the
+ INDEX_OFFLINE flag will not be cleared. So, we do that
+ here
+ */
+ IndexInfo *index = job->index_list;
+ while (index != NULL) {
+ index->ai->ai_indexmask &= ~INDEX_OFFLINE;
+ index = index->next;
+ }
/* start up the instance */
ret = dblayer_instance_start(job->inst->inst_be, DBLAYER_NORMAL_MODE);
if (ret != 0)
16 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/syntaxes int.c, 1.5, 1.6 string.c, 1.7, 1.8 syntax.h, 1.5, 1.6 value.c, 1.6, 1.7
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1730/ldapserver/ldap/servers/plugins/syntaxes
Modified Files:
int.c string.c syntax.h value.c
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on interger attributes value greater than 231
Reviewed by: nhosoi (Thanks!)
Fix Description: The problem is that the current code uses atol() to convert the string value to an integer. long is 4 bytes or 8 bytes depending on the underlying platform. These binary values are stored in the index as 4 or 8 byte values. Finally, the behavior of atol() is different on the platform in overflow cases. Instead of dealing with binary values, we must store the values in string format, and perform string comparison, string normalization, and string key generation on INTEGER syntax values. I added another syntax type to the list in syntax.h. The code in string.c and value.c was mostly usable. I had to add some code in value_normalize to handle cases like " -00000001" -> "-1" to make it work like atol(), and I had to add some code to value_cmp to handle the sign (e.g. positive is always greater than negative, no other comparison is necessary) and magnitude (longer number is larger/smaller than shorter number, depending on sign). Otherwise, strcmp() doe!
s the right thing (e.g. "50" > "49", the same as int(50) > int(49)). One problem I ran into was that the value_normalize code takes just a char *, rather than a berval* or a char * + size_t length. To be efficient, this function should return the new length of the normalized string. Fortunately, none of the existing code cares about the length, but I needed the length for magnitude comparison, so I just used strlen for those cases. Which should be fine. value_normalize always produces a correctly null terminated string. I rewrote the value_cmp code to use a simple if rather than the switch statement. This makes it much clearer - if syntax is case insensitive, use slapi_utf8casecmp - if case sensitive, use strcmp - otherwise, error.
I also found a problem with the ldif2db code, which I uncovered because I added my integer indexes online and did an online import. The db2index code will correctly clear the INDEX_OFFLINE bit after the index is completed, but the ldif2db code will not.
Platforms tested: RHEL5 x86_64
Flag Day: Yes, if you are upgrading and you have integer valued indexes, you will have to remove them and recreate them.
Doc impact: We will have to document this in the release notes.
Index: int.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/int.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- int.c 10 Nov 2006 23:45:31 -0000 1.5
+++ int.c 19 Sep 2007 19:32:03 -0000 1.6
@@ -50,11 +50,10 @@
static int int_filter_ava( Slapi_PBlock *pb, struct berval *bvfilter,
Slapi_Value **bvals, int ftype, Slapi_Value **retVal );
static int int_values2keys( Slapi_PBlock *pb, Slapi_Value **val,
- Slapi_Value ***ivals );
+ Slapi_Value ***ivals, int ftype );
static int int_assertion2keys( Slapi_PBlock *pb, Slapi_Value *val,
Slapi_Value ***ivals, int ftype );
static int int_compare(struct berval *v1, struct berval *v2);
-static long int_to_canonical( long num );
/* the first name is the official one from RFC 2252 */
static char *names[] = { "INTEGER", "int", INTEGER_SYNTAX_OID, 0 };
@@ -97,103 +96,22 @@
int_filter_ava( Slapi_PBlock *pb, struct berval *bvfilter,
Slapi_Value **bvals, int ftype, Slapi_Value **retVal )
{
- int i, rc;
- long flong, elong;
-
- if ( ftype == LDAP_FILTER_APPROX ) {
- return( LDAP_PROTOCOL_ERROR );
- }
- if(retVal) {
- *retVal=NULL;
- }
- flong = atol( bvfilter->bv_val );
- for ( i = 0; bvals[i] != NULL; i++ ) {
- elong = atol ( slapi_value_get_string(bvals[i]) );
- rc = elong - flong;
- switch ( ftype ) {
- case LDAP_FILTER_GE:
- if ( rc >= 0 ) {
- if(retVal) {
- *retVal = bvals[i];
- }
- return( 0 );
- }
- break;
- case LDAP_FILTER_LE:
- if ( rc <= 0 ) {
- if(retVal) {
- *retVal = bvals[i];
- }
- return( 0 );
- }
- break;
- case LDAP_FILTER_EQUALITY:
- if ( rc == 0 ) {
- if(retVal) {
- *retVal = bvals[i];
- }
- return( 0 );
- }
- break;
- }
- }
-
- return( -1 );
+ return( string_filter_ava( bvfilter, bvals, SYNTAX_INT | SYNTAX_CES,
+ ftype, retVal ) );
}
static int
-int_values2keys( Slapi_PBlock *pb, Slapi_Value **vals, Slapi_Value ***ivals )
+int_values2keys( Slapi_PBlock *pb, Slapi_Value **vals, Slapi_Value ***ivals, int ftype )
{
- long num;
- int i;
-
- for ( i = 0; vals[i] != NULL; i++ ) {
- /* NULL */
- }
-
- *ivals = (Slapi_Value **) slapi_ch_malloc(( i + 1 ) * sizeof(Slapi_Value *) );
-
- for ( i = 0; vals[i] != NULL; i++ )
- {
- num = atol( slapi_value_get_string(vals[i]) );
- num = int_to_canonical( num );
- (*ivals)[i] = slapi_value_new();
- slapi_value_set((*ivals)[i],&num,sizeof(long));
- }
- (*ivals)[i] = NULL;
-
- return( 0 );
+ return( string_values2keys( pb, vals, ivals, SYNTAX_INT | SYNTAX_CES,
+ ftype ) );
}
static int
int_assertion2keys( Slapi_PBlock *pb, Slapi_Value *val, Slapi_Value ***ivals, int ftype )
{
- long num;
- size_t len;
- unsigned char *b;
- Slapi_Value *tmpval=NULL;
-
- num = atol( slapi_value_get_string(val) );
- num = int_to_canonical( num );
- /* similar to string.c to optimize equality path: avoid malloc/free */
- if(ftype == LDAP_FILTER_EQUALITY_FAST) {
- len=sizeof(long);
- tmpval=(*ivals)[0];
- if ( len > tmpval->bv.bv_len) {
- tmpval->bv.bv_val=(char *)slapi_ch_malloc(len);
- }
- tmpval->bv.bv_len=len;
- b = (unsigned char *)#
- memcpy(tmpval->bv.bv_val,b,len);
- } else {
- *ivals = (Slapi_Value **) slapi_ch_malloc( 2 * sizeof(Slapi_Value *) );
- (*ivals)[0] = (Slapi_Value *) slapi_ch_malloc( sizeof(Slapi_Value) );
- /* XXXSD initialize memory */
- memset((*ivals)[0],0,sizeof(Slapi_Value));
- slapi_value_set((*ivals)[0],&num,sizeof(long));
- (*ivals)[1] = NULL;
- }
- return( 0 );
+ return(string_assertion2keys_ava( pb, val, ivals,
+ SYNTAX_INT | SYNTAX_CES, ftype ));
}
static int int_compare(
@@ -201,25 +119,5 @@
struct berval *v2
)
{
- long value1 = atol(v1->bv_val);
- long value2 = atol(v2->bv_val);
-
- if (value1 == value2) {
- return 0;
- }
- return ( ((value1 - value2) > 0) ? 1 : -1);
-}
-
-static long
-int_to_canonical( long num )
-{
- long ret = 0L;
- unsigned char *b = (unsigned char *)&ret;
-
- b[0] = (unsigned char)(num >> 24);
- b[1] = (unsigned char)(num >> 16);
- b[2] = (unsigned char)(num >> 8);
- b[3] = (unsigned char)num;
-
- return ret;
+ return value_cmp(v1, v2, SYNTAX_INT|SYNTAX_CES, 3 /* Normalise both values */);
}
Index: string.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/string.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- string.c 10 Nov 2006 23:45:31 -0000 1.7
+++ string.c 19 Sep 2007 19:32:03 -0000 1.8
@@ -73,6 +73,7 @@
SAFEMEMCPY( bvfilter_norm.bv_val, bvfilter->bv_val, bvfilter->bv_len );
bvfilter_norm.bv_val[bvfilter->bv_len] = '\0';
value_normalize( bvfilter_norm.bv_val, syntax, 1 /* trim leading blanks */ );
+ bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
for ( i = 0; bvals[i] != NULL; i++ ) {
rc = value_cmp( (struct berval*)slapi_value_get_berval(bvals[i]), &bvfilter_norm, syntax, 1/* Normalise the first value only */ );
Index: syntax.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/syntax.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- syntax.h 10 Nov 2006 23:45:31 -0000 1.5
+++ syntax.h 19 Sep 2007 19:32:03 -0000 1.6
@@ -56,6 +56,7 @@
#define SYNTAX_TEL 4 /* telephone number: used with SYNTAX_CIS */
#define SYNTAX_DN 8 /* distinguished name: used with SYNTAX_CIS */
#define SYNTAX_SI 16 /* space insensitive: used with SYNTAX_CIS */
+#define SYNTAX_INT 32 /* INTEGER */
#define SUBLEN 3
Index: value.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/value.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- value.c 10 Nov 2006 23:45:31 -0000 1.6
+++ value.c 19 Sep 2007 19:32:03 -0000 1.7
@@ -78,6 +78,13 @@
** of the form "cn=a* b*" (note the space) would be wrongly
** normalized into "cn=a*b*", because this function is called
** once for "a" and once for " b".
+** richm 20070917 - added integer syntax - note that this implementation
+** of integer syntax tries to mimic the old implementation (atol) as much
+** as possible - leading spaces are ignored, then the optional hyphen for
+** negative numbers, then leading 0s. That is
+** " -0000000000001" should normalize to "-1" which is what atol() does
+** Also note that this deviates from rfc 4517 INTEGER syntax, but we must
+** support legacy clients for the time being
*/
void
value_normalize(
@@ -105,10 +112,34 @@
LDAP_UTF8INC(s);
}
}
+
+ /* for int syntax, look for leading sign, then trim 0s */
+ /* have to do this after trimming spaces */
+ if (syntax & SYNTAX_INT) {
+ int foundsign = 0;
+ if (*s == '-') {
+ foundsign = 1;
+ LDAP_UTF8INC(s);
+ }
+
+ while (*s && (*s == '0')) {
+ LDAP_UTF8INC(s);
+ }
+
+ /* if there is a hyphen, make sure it is just to the left
+ of the first significant (i.e. non-zero) digit e.g.
+ convert -00000001 to -1 */
+ if (foundsign && (s > d)) {
+ *d = '-';
+ d++;
+ }
+ /* s should now point at the first significant digit/char */
+ }
+
/* handle value of all spaces - turn into single space */
- /* unless space insensitive syntax - turn into zero length string */
+ /* unless space insensitive syntax or int - turn into zero length string */
if ( *s == '\0' && s != d ) {
- if ( ! (syntax & SYNTAX_SI)) {
+ if ( ! (syntax & SYNTAX_SI) && ! (syntax & SYNTAX_INT) ) {
*d++ = ' ';
}
*d = '\0';
@@ -175,7 +206,7 @@
int normalize
)
{
- int rc;
+ int rc = 0;
struct berval bvcopy1;
struct berval bvcopy2;
char little_buffer[64];
@@ -183,6 +214,7 @@
int buffer_offset = 0;
int free_v1 = 0;
int free_v2 = 0;
+ int v1sign = 1, v2sign = 1; /* default to positive */
/* This code used to call malloc up to four times in the copying
* of attributes to be normalized. Now we attempt to keep everything
@@ -221,20 +253,42 @@
value_normalize( v2->bv_val, syntax, 1 /* trim leading blanks */ );
}
- switch ( syntax ) {
- case SYNTAX_CIS:
- case (SYNTAX_CIS | SYNTAX_TEL):
- case (SYNTAX_CIS | SYNTAX_DN):
- case (SYNTAX_CIS | SYNTAX_SI):
- rc = slapi_utf8casecmp( (unsigned char *)v1->bv_val,
- (unsigned char *)v2->bv_val );
- break;
+ if (syntax & SYNTAX_INT) {
+ v1sign = v1->bv_val && (*v1->bv_val != '-');
+ v2sign = v2->bv_val && (*v2->bv_val != '-');
+ rc = v1sign - v2sign;
+ if (rc) { /* one is positive, one is negative */
+ goto done;
+ }
+
+ /* check magnitude */
+ /* unfortunately, bv_len cannot be trusted - bv_len is not
+ updated during or after value_normalize */
+ rc = (strlen(v1->bv_val) - strlen(v2->bv_val));
+ if (rc) {
+ rc = (rc > 0) ? 1 : -1;
+ if (!v1sign && !v2sign) { /* both negative */
+ rc = 0 - rc; /* flip it */
+ }
+ goto done;
+ }
+ }
- case SYNTAX_CES:
+ if (syntax & SYNTAX_CIS) {
+ rc = slapi_utf8casecmp( (unsigned char *)v1->bv_val,
+ (unsigned char *)v2->bv_val );
+ } else if (syntax & SYNTAX_CES) {
rc = strcmp( v1->bv_val, v2->bv_val );
- break;
+ } else { /* error - unknown syntax */
+ LDAPDebug(LDAP_DEBUG_PLUGIN,
+ "invalid syntax [%d]\n", syntax, 0, 0);
+ }
+
+ if ((syntax & SYNTAX_INT) && !v1sign && !v2sign) { /* both negative */
+ rc = 0 - rc; /* flip it */
}
+done:
if ( (normalize & 1) && free_v1) {
ber_bvfree( v1 );
}
16 years, 7 months