[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: OpenLDAP API



Pierre,

I figured it out.  The os is raising SIGPIPE (write() to a broken socket)
and by default it terminates the program.  I just needed to ignore the
signal or write a special handler for it.  Thanks for you help...

-Igor

On Tue, 2 Apr 2002, Igor Brezac wrote:

>
> I do not have gdb, but adb is available.  I do not get core dump in this
> example.  The following is the output:
>
> # ./a.out
> ldap_search_st() error Can't contact LDAP server
> Broken Pipe
>
> I do not expect "Broken Pipe".  I traced it to ldap_send_unbind()
> call in libldap.so.
>
> I added
> debug = 0x00028;
> ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &(debug));
> after ldap_initialize() call and I get the following output.
>
> # ./a.out
> request 1 done
> ber_get_next failed.
> LDAP: Can't contact LDAP server
> Broken Pipe
>
> I hope that this will help.
>
> -Igor
>
> On Tue, 2 Apr 2002, Kervin Pierre wrote:
>
> >
> > Do you have gdb installed? How about a full backtrace on the core file.
> >
> > Igor Brezac wrote:
> > > Hello,
> > >
> > > I tried to send this message to openldap-software, but I did not have
> > > much luck there.  So, maybe some of you guys may be able to help me.
> > >
> > > I use Solaris 8 and openldap 2.0.23.  The following short program crashes
> > > on the ldap_unbind() call.  I tried various different versions of this
> > > program without success.  Am I doing something wrong here?
> > >
> > > Your help will be greatly appreciated.
> > >
> > > -Igor
> > >
> > > #include        <sys/types.h>
> > > #include        <stdlib.h>
> > >
> > > #include        <lber.h>
> > > #include        <ldap.h>
> > >
> > > int main() {
> > >
> > >         int rc;
> > >         LDAP   *ldi;
> > >         struct timeval tv;
> > >         LDAPMessage *res = NULL;
> > >         LDAPMessage *msg = NULL;
> > >         char *dn;
> > >         char *server = "ldap://10.1.1.197/";;
> > >         char *base_dn = "o=pb";
> > >         char *filter = "uid=igor";
> > >         char *attrs[] = {"dn",NULL};
> > >
> > >
> > >         rc = ldap_initialize(&ldi, server);
> > >         if (rc != LDAP_SUCCESS) {
> > >                 exit (2);
> > >         }
> > >
> > >         rc = ldap_simple_bind_s(ldi, "", "");
> > >         if (rc != LDAP_SUCCESS) {
> > >                 exit (2);
> > >         }
> > >
> > > //  If the ldap server is no longer available at this point
> > >
> > >         tv.tv_sec = 5;
> > >         tv.tv_usec = 0;
> > >         rc = ldap_search_st(ldi, base_dn, LDAP_SCOPE_SUBTREE, filter,
> > >                         (char **) attrs, 0, &tv, &res);
> > >
> > >         if (rc != LDAP_SUCCESS) {
> > >                 ldap_get_option(ldi, LDAP_OPT_ERROR_NUMBER, &rc);
> > >                 printf("ldap_search_st() error %s\n", ldap_err2string(rc));
> > >                 ldap_msgfree(res);
> > >                 ldap_unbind(ldi);
> > >
> > > // ldap_unbind will cause a dump here
> > >
> > >                 exit(2);
> > >         }
> > >
> > >         msg = ldap_first_entry(ldi, res);
> > >         dn = ldap_get_dn(ldi, msg);
> > >         printf("DN: %s\n", dn);
> > >
> > >         ldap_msgfree(msg);
> > >         free(dn);
> > >         ldap_unbind_s(ldi);
> > >         exit (1);
> > > }
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>