openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/nss-pam-ldapd/0.9.8-r0/nss-pam-ldapd-0.9.8/nslcd/myldap.c
static void do_close(MYLDAP_SESSION* session)
{
    int i;
    int rc;
    time_t sec;
    /* if we had reachability problems with the server close the connection */
    if (session->ld != NULL)
    {
        /* set timeout options on socket to avoid hang in some cases
           (we set a short timeout because we don't care too much about properly
           shutting down the connection) */
        if (nslcd_cfg->timelimit)
        {
            sec = nslcd_cfg->timelimit / 2;
            if (!sec)
                sec = 1;
            set_socket_timeout(session->ld, sec, 0);
        }
        /* go over the other searches and partially close them */
        for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
        {
            if (session->searches[i] != NULL)
            {
                /* free any messages (because later ld is no longer valid) */
                if (session->searches[i]->msg != NULL)
                {
                    ldap_msgfree(session->searches[i]->msg);
                    session->searches[i]->msg = NULL;
                }
                /* abandon the search if there were more results to fetch */
                if (session->searches[i]->msgid != -1)
                {
                    log_log(LOG_DEBUG, "ldap_abandon()");
                    if (ldap_abandon(session->searches[i]->session->ld,
                                     session->searches[i]->msgid))
                    {
                        if (ldap_get_option(session->ld, LDAP_OPT_ERROR_NUMBER,
                                            &rc) != LDAP_SUCCESS)
                            rc = LDAP_OTHER;
                        myldap_err(LOG_WARNING, session->ld, rc,
                                   "ldap_abandon() failed to abandon search");
                    }
                    session->searches[i]->msgid = -1;
                }
                /* flag the search as invalid */
                session->searches[i]->valid = 0;
            }
        }
        /* close the connection to the server */
        log_log(LOG_DEBUG, "ldap_unbind()");
        rc = ldap_unbind(session->ld);
        session->ld = NULL;
        if (rc != LDAP_SUCCESS)
            myldap_err(LOG_WARNING, session->ld, rc, "ldap_unbind() failed");
    }
}
/* close the connection to the server and invalidate any running searches */
close the connection to the server and invalidate any running searches
close the connection to the server and invalidate any running searches
static void do_close(MYLDAP_SESSION* session)
{
    int i;
    int rc;
    time_t sec;
    if (session->ld != NULL)
    {
        if (nslcd_cfg->timelimit)
        {
            sec = nslcd_cfg->timelimit / 2;
            if (!sec)
                sec = 1;
            set_socket_timeout(session->ld, sec, 0);
        }
        for (i = 0; i < MAX_SEARCHES_IN_SESSION; i++)
        {
            if (session->searches[i] != NULL)
            {
                if (session->searches[i]->msg != NULL)
                {
                    ldap_msgfree(session->searches[i]->msg);
                    session->searches[i]->msg = NULL;
                }
                if (session->searches[i]->msgid != -1)
                {
                    log_log(LOG_DEBUG, "ldap_abandon()");
                    if (ldap_abandon(session->searches[i]->session->ld,
                                     session->searches[i]->msgid))
                    {
                        if (ldap_get_option(session->ld, LDAP_OPT_ERROR_NUMBER,
                                            &rc) != LDAP_SUCCESS)
                            rc = LDAP_OTHER;
                        myldap_err(LOG_WARNING, session->ld, rc,
                                   "ldap_abandon() failed to abandon search");
                    }
                    session->searches[i]->msgid = -1;
                }
                session->searches[i]->valid = 0;
            }
        }
        log_log(LOG_DEBUG, "ldap_unbind()");
        rc = ldap_unbind(session->ld);
        session->ld = NULL;
        if (rc != LDAP_SUCCESS)
            myldap_err(LOG_WARNING, session->ld, rc, "ldap_unbind() failed");
    }
}
static void do_close ( MYLDAP_SESSION * session ) { int i ; int rc ; time_t sec ; if ( session -> ld != NULL ) { if ( nslcd_cfg -> timelimit ) { sec = nslcd_cfg -> timelimit / 2 ; if ( ! sec ) sec = 1 ; set_socket_timeout ( session -> ld , sec , 0 ) ; } for ( i = 0 ; i < MAX_SEARCHES_IN_SESSION ; i ++ ) { if ( session -> searches [ i ] != NULL ) { if ( session -> searches [ i ] -> msg != NULL ) { ldap_msgfree ( session -> searches [ i ] -> msg ) ; session -> searches [ i ] -> msg = NULL ; } if ( session -> searches [ i ] -> msgid != -1 ) { log_log ( LOG_DEBUG , " " ) ; if ( ldap_abandon ( session -> searches [ i ] -> session -> ld , session -> searches [ i ] -> msgid ) ) { if ( ldap_get_option ( session -> ld , LDAP_OPT_ERROR_NUMBER , & rc ) != LDAP_SUCCESS ) rc = LDAP_OTHER ; myldap_err ( LOG_WARNING , session -> ld , rc , " " ) ; } session -> searches [ i ] -> msgid = -1 ; } session -> searches [ i ] -> valid = 0 ; } } log_log ( LOG_DEBUG , " " ) ; rc = ldap_unbind ( session -> ld ) ; session -> ld = NULL ; if ( rc != LDAP_SUCCESS ) myldap_err ( LOG_WARNING , session -> ld , rc , " " ) ; } }
close the connection to the server and invalidate any running searches
close the connection to the server and invalidate any running searches
/* if we had reachability problems with the server close the connection */ /* set timeout options on socket to avoid hang in some cases
           (we set a short timeout because we don't care too much about properly
           shutting down the connection) */ /* go over the other searches and partially close them */ /* free any messages (because later ld is no longer valid) */ /* abandon the search if there were more results to fetch */ /* flag the search as invalid */ /* close the connection to the server */