/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <ac/unistd.h>
#include "slap.h"
-#include "lutil.h"
const struct berval slap_dummy_bv = BER_BVNULL;
bytes = send_ldap_ber( op->o_conn, ber );
ber_free_buf( ber );
- ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
- ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
- ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 );
- ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
- ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
+ if ( bytes < 0 ) {
+ rc = LDAP_UNAVAILABLE;
+ } else {
+ ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
+ ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
+ ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 );
+ ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
+ ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
+ }
#ifdef LDAP_CONNECTIONLESS
}
#endif
}
if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
- if ( c != NULL && lutil_atoi( code, c ) != 0 ) {
- goto bailout;
+ char *next = NULL;
+ long retcode;
+
+ if ( c == NULL ) {
+ Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
+ s, 0, 0 );
+ rc = -1;
+ continue;
+ }
+
+ while ( isspace( (unsigned char) c[ 0 ] ) ) c++;
+ if ( c[ 0 ] == '\0' ) {
+ Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
+ s, 0, 0 );
+ rc = -1;
+ continue;
+ }
+
+ retcode = strtol( c, &next, 10 );
+ if ( next == NULL || next == c ) {
+ Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
+ s, 0, 0 );
+ rc = -1;
+ continue;
+ }
+
+ while ( isspace( (unsigned char) next[ 0 ] ) ) next++;
+ if ( next[ 0 ] != '\0' ) {
+ Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
+ s, 0, 0 );
+ rc = -1;
+ continue;
}
+
+ /* FIXME: what if it's larger that max int? */
+ *code = (int)retcode;
+
} else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
if ( c != NULL ) {
*matched = c;
*info = c;
}
} else {
-bailout:;
Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n",
s, 0, 0 );
myop.o_bd = NULL;
myop.o_res_ber = ber;
myop.o_callback = NULL;
+ myop.ors_slimit = 1;
rc = slap_send_search_entry( &myop, rs );
if( rc ) return rc;