Skip to content
Snippets Groups Projects
Commit 66818be6 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Don't attempt to send abandon unless connection exists.

If connection doesn't exist, return LDAP_SERVER_DOWN.
parent 282b1924
No related branches found
No related tags found
No related merge requests found
......@@ -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 );
......
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment