Solaris
--------
I am not being able to init a ssl client session on Solaris 2.6 (32
bit), using the 4.11 C SDK.
The very first call ldapssl_client_init() fails and I get the folloewing
error msg - "libc internal error: _rmutex_unlock: rmutex not held"
I have the latest library and all the service packs installed.
NT 4.0
--------
This is much better than Solaris. It does work, but if I run the same
code in the context of a debugger, even though if the call to
ldap_simple_bind_s() is successfull, I get a message saying the "thread
(id) exited with return code 0". This causes the termination of the main
thread itself and I cannot continue operation. However if I set break
points in the main thread at points after this call, the context returns
back to the main thread without throwing any errors.
From the two types of behavior shown above (both Solaris and NT), I
assume there is something wrong with SDK's threading routines, or else
their are some steps which I am missing and would certainly like to know
more about.
thanks
Sachin
Sachin Agarwal wrote:
The SDK by itself does no locking unless you specify the locking routines to
use.
(If you already did this, please provide a snippet of the relevant ldap
calls so that I can
take a look at it). The following example illustrates how to set the
ldap_thread_fns
structure.
Example of Specifying Thread Functions
For example, the following section of code sets up an ldap_thread_fns
structure for an LDAP session.
#include <stdio.h>
#include <malloc.h>
#include <errno.h>
#include <pthread.h>
#include <ldap.h>
struct ldap_thread_fns tfns;
...
/* Set up the ldap_thread_fns structure with pointers
to the functions that you want called */
memset( &tfns, '\0', sizeof(struct ldap_thread_fns) );
/* Specify the functions that you want called */
/* Call the my_mutex_alloc() function whenever mutexes
need to be allocated */
tfns.ltf_mutex_alloc = (void *(*)(void)) my_mutex_alloc;
/* Call the my_mutex_free() function whenever mutexes
need to be destroyed */
tfns.ltf_mutex_free = (void (*)(void *)) my_mutex_free;
/* Call the pthread_mutex_lock() function whenever a
thread needs to lock a mutex. */
tfns.ltf_mutex_lock = (int (*)(void *)) pthread_mutex_lock;
/* Call the pthread_mutex_unlock() function whenever a
thread needs to unlock a mutex. */
tfns.ltf_mutex_unlock = (int (*)(void *)) pthread_mutex_unlock;
/* Call the get_errno() function to get the value of errno */
tfns.ltf_get_errno = get_errno;
/* Call the set_errno() function to set the value of errno */
tfns.ltf_set_errno = set_errno;
/* Call the get_ld_error() function to get error values from
calls to functions in the libldap library */
tfns.ltf_get_lderrno = get_ld_error;
/* Call the set_ld_error() function to set error values for
calls to functions in the libldap library */
tfns.ltf_set_lderrno = set_ld_error;
/* Don't pass any extra parameter to the functions for
getting and setting libldap function call errors */
tfns.ltf_lderrno_arg = NULL;
...
/* Set the session option that specifies the functions to call for
multi-threaded clients */
if (ldap_set_option( ld, LDAP_OPT_THREAD_FN_PTRS, (void *) &tfns)!= 0) {
ldap_perror( ld, "ldap_set_option: thread pointers" );
}
I not using any threading rotuines, just trying to establish a single ssl
connection to the directory server.
Following is the code snippet that I am using
**************************************************************
#include "ldap.h"
#include "ldap_ssl.h"
#include <stdio.h>
int main ( void )
{
LDAP *ld;
if ( ldapssl_client_init( "/users/sagarwal/cert7.db", NULL ) ){
printf( "Failed to initialize SSL client...\n" );
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldapssl_init( "sagarwal2", LDAPS_PORT, 1 )) == NULL ){
perror( "ldapssl_init" );
return( 1 );
}
*************************************
As you can see I am not trying to use any threading routines, but I still get
the same error.
thanks
Sachin