-#ifdef LDAP_SLAPI
- /* call destructors, then constructors; avoids unnecessary allocation */
- if ( slapi_plugins_used ) {
- slapi_int_clear_object_extensions( SLAPI_X_EXT_CONNECTION, c );
+ /* c must be fully reset by this point; when we call slapd_remove
+ * it may get immediately reused by a new connection.
+ */
+ if ( sd != AC_SOCKET_INVALID ) {
+ slapd_remove( sd, sb, 1, 0, 0 );
+
+ Statslog( LDAP_DEBUG_STATS, (close_reason
+ ? "conn=%lu fd=%ld closed (%s)\n"
+ : "conn=%lu fd=%ld closed\n"),
+ connid, (long) sd, close_reason, 0, 0 );