From: Howard Chu Date: Fri, 18 Feb 2005 02:40:06 +0000 (+0000) Subject: Add code to aid in testing Abandon/Cancel processing X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~165 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0af48a3d64e4a3cdcdb7850c483b5de7ace39390;p=openldap Add code to aid in testing Abandon/Cancel processing --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index c603281d97..5e07b00c1b 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -48,6 +48,10 @@ #include #include +#if defined(TEST_ABANDON) || defined(TEST_CANCEL) +#include +#endif + #ifdef HAVE_FCNTL_H #include #endif @@ -550,6 +554,15 @@ private_conn_setup( LDAP *ld ) } } +#if defined(TEST_ABANDON) || defined(TEST_CANCEL) +static int gotintr; + +RETSIGTYPE +do_sig( int sig ) +{ + gotintr = 1; +} +#endif int main( int argc, char **argv ) @@ -609,6 +622,10 @@ main( int argc, char **argv ) attrs = &argv[optind]; } +#if defined(TEST_ABANDON) || defined(TEST_CANCEL) + SIGNAL( SIGINT, do_sig ); +#endif + if ( infile != NULL ) { if ( infile[0] == '-' && infile[1] == '\0' ) { fp = stdin; @@ -1105,6 +1122,20 @@ static int dosearch( ldap_msgfree( res ); } +#if defined(TEST_ABANDON) || defined(TEST_CANCEL) + if ( gotintr ) { +#ifdef TEST_CANCEL + rc = ldap_cancel_s( ld, msgid, NULL, NULL ); + fprintf( stderr, "got interrupt, cancel got %d\n", rc ); + return -1; +#endif +#ifdef TEST_ABANDON + rc = ldap_abandon( ld, msgid ); + fprintf( stderr, "got interrupt, abandon got %d\n", rc ); + return -1; +#endif + } +#endif if ( rc == -1 ) { ldap_perror( ld, "ldap_result" );