]> git.sur5r.net Git - openldap/commitdiff
Don't attempt to send abandon unless connection exists.
authorKurt Zeilenga <kurt@openldap.org>
Mon, 16 Oct 2000 23:11:41 +0000 (23:11 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 16 Oct 2000 23:11:41 +0000 (23:11 +0000)
If connection doesn't exist, return LDAP_SERVER_DOWN.

libraries/libldap/abandon.c
libraries/libldap/apitest.c

index 597ded2f8428ab726e4c5779c091f18293227d9f..fbb184722a5357553da576b82ea5873972c6a6ca 100644 (file)
@@ -131,12 +131,18 @@ do_abandon(
 
        err = 0;
        if ( sendabandon ) {
-               /* create a message to send */
-               if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               if( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, NULL ) == -1 ) {
+                       /* not connected */
+                       err = -1;
+                       ld->ld_errno = LDAP_SERVER_DOWN;
+
+               } else if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+                       /* BER element alocation failed */
                        err = -1;
                        ld->ld_errno = LDAP_NO_MEMORY;
 
                } else {
+                       /* create a message to send */
                        err = ber_printf( ber, "{iti",  /* '}' */
                                ++ld->ld_msgid,
                            LDAP_REQ_ABANDON, msgid );
index 0fe1de5ee5eb347e5d414a351e2e6bc1d7ae3265..17548cd2b3eb7ecc1f025d3293faa82ba61be7aa 100644 (file)
@@ -188,5 +188,47 @@ main(int argc, char **argv)
                puts("  HOST NAME:         <not set>");
        }
 
+#if 0
+       /* API tests */
+       {       /* bindless unbind */
+               LDAP *ld;
+               int rc;
+
+               ld = ldap_init( "localhost", 389 );
+               if( ld == NULL ) {
+                       perror("ldap_init");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_unbind( ld );
+               if( rc != LDAP_SUCCESS ) {
+                       perror("ldap_unbind");
+                       return EXIT_FAILURE;
+               }
+       }
+       {       /* bindless unbind */
+               LDAP *ld;
+               int rc;
+
+               ld = ldap_init( "localhost", 389 );
+               if( ld == NULL ) {
+                       perror("ldap_init");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_abandon_ext( ld, 0, NULL, NULL );
+               if( rc != LDAP_SERVER_DOWN ) {
+                       ldap_perror( ld, "ldap_abandon");
+                       return EXIT_FAILURE;
+               }
+
+               rc = ldap_unbind( ld );
+               if( rc != LDAP_SUCCESS ) {
+                       perror("ldap_unbind");
+                       return EXIT_FAILURE;
+               }
+       }
+#endif
+
        return EXIT_SUCCESS;
 }