]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/result.c
Removed o_suffix and o_suffixalias as they were 1) leaked and 2) unused
[openldap] / servers / slapd / result.c
index e8f4be47d6dd052c7edb8683c9a1c2d2057e14b5..12e90a805b2e8f514934538d2b80bfabf330a1bd 100644 (file)
@@ -1,30 +1,18 @@
 /* result.c - routines to send ldap results, errors, and referrals */
 
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <signal.h>
 #include "portable.h"
-#include "slap.h"
 
-#ifndef SYSERRLIST_IN_STDIO
-extern int             sys_nerr;
-extern char            *sys_errlist[];
-#endif
-extern int             active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_t       listener_tid;
-extern struct acl      *acl_get_applicable();
-extern long            num_entries_sent;
-extern long            num_bytes_sent;
-extern pthread_mutex_t num_sent_mutex;
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>         /* get close() */
+
+#include "slap.h"
 
-void   close_connection();
 
 static void
 send_ldap_result2(
@@ -64,7 +52,7 @@ send_ldap_result2(
                break;
        }
 
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
            == NULLBER ) {
 #else
@@ -74,13 +62,13 @@ send_ldap_result2(
                return;
        }
 
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        if ( op->o_cldap ) {
                rc = ber_printf( ber, "{is{t{ess}}}", op->o_msgid, "", tag,
                    err, matched ? matched : "", text ? text : "" );
        } else
 #endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "{it{{ess}}}", op->o_msgid, tag, err,
                    matched ? matched : "", text ? text : "" );
@@ -125,13 +113,13 @@ send_ldap_result2(
                active_threads--;
                conn->c_writewaiter = 1;
 
-#ifdef linux
-               pthread_kill( listener_tid, SIGSTKFLT );
-#else /* !linux */
-               pthread_kill( listener_tid, SIGUSR1 );
-#endif /* !linux */
+               pthread_kill( listener_tid, LDAP_SIGUSR1 );
 
                pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
+
+               if( active_threads < 1 ) {
+                       pthread_cond_signal(&active_threads_cond);
+               }
                pthread_mutex_unlock( &active_threads_mutex );
 
                pthread_yield();
@@ -160,7 +148,7 @@ send_ldap_result(
     char       *text
 )
 {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
        if ( op->o_cldap ) {
                SAFEMEMCPY( (char *)conn->c_sb.sb_useaddr, &op->o_clientaddr,
                    sizeof( struct sockaddr ));
@@ -205,16 +193,17 @@ send_search_entry(
 
        Debug( LDAP_DEBUG_TRACE, "=> send_search_entry (%s)\n", e->e_dn, 0, 0 );
 
-       if ( ! access_allowed( be, conn, op, e, "entry", NULL, op->o_dn,
-           ACL_READ ) ) {
+       if ( ! access_allowed( be, conn, op, e,
+               "entry", NULL, ACL_READ ) )
+       {
                Debug( LDAP_DEBUG_ACL, "acl: access to entry not allowed\n",
                    0, 0, 0 );
                return( 1 );
        }
 
-       edn = dn_normalize_case( strdup( e->e_dn ) );
+       edn = e->e_ndn;
 
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
                == NULLBER )
 #else
@@ -227,7 +216,7 @@ send_search_entry(
                goto error_return;
        }
 
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "{it{{s{", op->o_msgid,
                    LDAP_RES_SEARCH_ENTRY, e->e_dn );
@@ -263,12 +252,12 @@ send_search_entry(
                                a->a_type, 0, 0 );
                        acl = NULL;
                } else {
-                       acl = acl_get_applicable( be, op, e, a->a_type, edn,
+                       acl = acl_get_applicable( be, op, e, a->a_type,
                                MAXREMATCHES, matches );
                }
 
-               if ( ! acl_access_allowed( acl, be, conn, e, NULL, op, ACL_READ,
-                       edn, matches ) ) 
+               if ( ! acl_access_allowed( acl, be, conn, e,
+                       NULL, op, ACL_READ, edn, matches ) ) 
                {
                        continue;
                }
@@ -314,9 +303,7 @@ send_search_entry(
                }
        }
 
-       free(edn);
-
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
        if ( conn->c_version == 30 ) {
                rc = ber_printf( ber, "}}}}" );
        } else
@@ -360,8 +347,12 @@ send_search_entry(
                pthread_mutex_lock( &active_threads_mutex );
                active_threads--;
                conn->c_writewaiter = 1;
-               pthread_kill( listener_tid, SIGUSR1 );
+               pthread_kill( listener_tid, LDAP_SIGUSR1 );
                pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
+
+               if( active_threads < 1 ) {
+                       pthread_cond_signal(&active_threads_cond);
+               }
                pthread_mutex_unlock( &active_threads_mutex );
 
                pthread_yield();
@@ -390,7 +381,6 @@ send_search_entry(
        return( rc );
 
 error_return:;
-       free(edn);
        return( 1 );
 }