]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/result.c
Add BDB_INDEX error handling
[openldap] / servers / slapd / result.c
index e8aecf2a4de652586efcc5010d7b3d4ed6d58a62..f869f86c91d2f0eddc4f8817f1c31ba1627d84d3 100644 (file)
@@ -309,10 +309,34 @@ send_ldap_response(
                return;
        }
 
-       rc = ber_printf( ber, "{it{ess",
+#ifdef LDAP_CONNECTIONLESS
+       if (conn->c_is_udp) {
+           rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
+           if (rc != sizeof(struct sockaddr)) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "send_ldap_response: conn %d  ber_write failed\n",
+                          conn ? conn->c_connid : 0 ));
+#else
+               Debug( LDAP_DEBUG_ANY, "ber_write failed\n", 0, 0, 0 );
+#endif
+               ber_free(ber, 1);
+               return;
+           }
+       }
+       if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
+           rc = ber_printf( ber, "{is{t{ess",
+               msgid, "", tag, err,
+               matched == NULL ? "" : matched,
+               text == NULL ? "" : text );
+       } else
+#endif
+       {
+           rc = ber_printf( ber, "{it{ess",
                msgid, tag, err,
                matched == NULL ? "" : matched,
                text == NULL ? "" : text );
+       }
 
        if( rc != -1 ) {
                if ( ref != NULL ) {
@@ -342,6 +366,11 @@ send_ldap_response(
        if( rc != -1 ) {
                rc = ber_printf( ber, "N}N}" );
        }
+#ifdef LDAP_CONNECTIONLESS
+       if( conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1 ) {
+               rc = ber_printf( ber, "N}" );
+       }
+#endif
 
        if ( rc == -1 ) {
 #ifdef NEW_LOGGING
@@ -428,9 +457,9 @@ send_ldap_disconnect(
                reqoid, NULL, NULL, NULL );
 
        Statslog( LDAP_DEBUG_STATS,
-           "conn=%ld op=%ld DISCONNECT err=%ld tag=%lu text=%s\n",
+           "conn=%ld op=%ld DISCONNECT tag=%lu err=%ld text=%s\n",
                (long) op->o_connid, (long) op->o_opid,
-               (long) tag, (long) err, text ? text : "" );
+               (unsigned long) tag, (long) err, text ? text : "" );
 }
 
 void
@@ -515,7 +544,7 @@ send_ldap_result(
        Statslog( LDAP_DEBUG_STATS,
            "conn=%ld op=%ld RESULT tag=%lu err=%ld text=%s\n",
                (long) op->o_connid, (long) op->o_opid,
-               (long) tag, (long) err, text ? text : "" );
+               (unsigned long) tag, (long) err, text ? text : "" );
 
        if( tmp != NULL ) {
                ch_free(tmp);
@@ -657,7 +686,7 @@ send_search_result(
        Statslog( LDAP_DEBUG_STATS,
            "conn=%ld op=%ld SEARCH RESULT tag=%lu err=%ld text=%s\n",
                (long) op->o_connid, (long) op->o_opid,
-               (long) tag, (long) err, text ? text : "" );
+               (unsigned long) tag, (long) err, text ? text : "" );
 
        if (tmp != NULL) {
            ch_free(tmp);
@@ -731,8 +760,30 @@ send_search_entry(
                goto error_return;
        }
 
-       rc = ber_printf( ber, "{it{s{" /*}}}*/, op->o_msgid,
+#ifdef LDAP_CONNECTIONLESS
+       if (conn->c_is_udp) {
+           rc = ber_write(ber, (char *)&op->o_peeraddr, sizeof(struct sockaddr), 0);
+           if (rc != sizeof(struct sockaddr)) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "send_search_entry: conn %d  ber_printf failed\n",
+                          conn ? conn->c_connid : 0 ));
+#else
+               Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
+#endif
+               ber_free(ber, 1);
+               return;
+           }
+       }
+       if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2) {
+           rc = ber_printf( ber, "{is{t{s{",
+               op->o_msgid, "", LDAP_RES_SEARCH_ENTRY, e->e_dn );
+       } else
+#endif
+       {
+           rc = ber_printf( ber, "{it{s{" /*}}}*/, op->o_msgid,
                LDAP_RES_SEARCH_ENTRY, e->e_dn );
+       }
 
        if ( rc == -1 ) {
 #ifdef NEW_LOGGING
@@ -914,6 +965,7 @@ send_search_entry(
                        ber_free( ber, 1 );
                        send_ldap_result( conn, op, LDAP_OTHER,
                            NULL, "encoding description error", NULL, NULL );
+                       attrs_free( aa );
                        goto error_return;
                }
 
@@ -949,6 +1001,7 @@ send_search_entry(
                                        ber_free( ber, 1 );
                                        send_ldap_result( conn, op, LDAP_OTHER,
                                                NULL, "encoding values error", NULL, NULL );
+                                       attrs_free( aa );
                                        goto error_return;
                                }
                        }
@@ -966,6 +1019,7 @@ send_search_entry(
                        ber_free( ber, 1 );
                        send_ldap_result( conn, op, LDAP_OTHER,
                            NULL, "encode end error", NULL, NULL );
+                       attrs_free( aa );
                        goto error_return;
                }
        }
@@ -974,6 +1028,10 @@ send_search_entry(
 
        rc = ber_printf( ber, /*{{{*/ "}N}N}" );
 
+#ifdef LDAP_CONNECTIONLESS
+       if (conn->c_is_udp && op->o_protocol == LDAP_VERSION2 && rc != -1)
+               rc = ber_printf( ber, "}" );
+#endif
        if ( rc == -1 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
@@ -1159,7 +1217,7 @@ send_search_reference(
        num_pdu_sent++;
        ldap_pvt_thread_mutex_unlock( &num_sent_mutex );
 
-       Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld ENTRY dn=\"%s\"\n",
+       Statslog( LDAP_DEBUG_STATS2, "conn=%ld op=%ld REF dn=\"%s\"\n",
            (long) conn->c_connid, (long) op->o_opid, e->e_dn, 0, 0 );
 
 #ifdef NEW_LOGGING