Hello,
I am currently trying to modify the OpenSSL library to include a struct that I have implemented. This part works great. I have created a hash table using a doubly linked list, and can insert, find, and everything else perfectly. From inside the library code at least.
My problem is that, the whole reason I am injecting this code is to be able to access the structure outside of the library in my program that uses Openssl. I am currently doing this with a global struct hash map that is being declared in the OpenSSL library (at global scope) and extern'd back into my program. The flow of control is as follows:
Library function call
Library inserts into hash table
Library function returns
User Program reads from hash table
User Program deletes the data from the hash table
Whenever I run my program the Library inserts perfectly fine, and the program reads perfectly fine, however they both insert, and read from different hash tables! I'm am thoroughly confused over this, and welcome any response. If there is a better way to do this from a shared library than a global, fell free to suggest a new method. I can also post any code that is needed.
The declaration of the hash table (and a shared threading lock) are right below the includes:
CMAP * key_map = NULL; //CMAP is a typdef of the struct that I created, and needs to be init'd to NULL as per the UThash documentation which is what I'm using for the hash table
pthread_rwlock_t lock;
CMAP is defined as:
typedef struct c_map{
pthread_t threadIdKey;
unsigned char * key;
int key_len;
UT_hash_handle hh;
} CMAP;
And there are three functions that go along with CMAP:
CMAP * hash_find(pthread_t threadId);
int hash_delete(pthread_t threadId);
int hash_add(pthread_t threadId, int key_len, unsigned char * key);
The library calls hash_add (which internally calls hash find)
and the user program calls hash find, and hash delete.
Thanks in advanced!
-Sam