]> git.sur5r.net Git - openldap/blobdiff - clients/tools/ldapwhoami.c
ITS#6548,#7092 Unbind,cleanup before client exit.
[openldap] / clients / tools / ldapwhoami.c
index 4f4c9f6290578d447077eebd077c606d041dcce5..ff57fda808f0f7e77723374f36ebafadf69b1485 100644 (file)
@@ -151,7 +151,7 @@ main( int argc, char *argv[] )
                struct timeval  tv;
 
                if ( tool_check_abandon( ld, id ) ) {
-                       return LDAP_CANCELLED;
+                       tool_exit( ld, LDAP_CANCELLED );
                }
 
                tv.tv_sec = 0;
@@ -160,7 +160,7 @@ main( int argc, char *argv[] )
                rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ALL, &tv, &res );
                if ( rc < 0 ) {
                        tool_perror( "ldap_result", rc, NULL, NULL, NULL, NULL );
-                       return rc;
+                       tool_exit( ld, rc );
                }
 
                if ( rc != 0 ) {
@@ -231,8 +231,5 @@ skip:
        ber_bvfree( authzid );
 
        /* disconnect from server */
-       tool_unbind( ld );
-       tool_destroy();
-
-       return code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
+       tool_exit( ld, code == LDAP_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE );
 }