|
Dear Users I have posted this before but did not get a satisfactory
reply. I have developed a simple multi-threaded server application using
OpenSSL for communication. The master thread only accepts new connections and
creates a new thread for each connection. My problem is the server runs fine
except for completely arbitrary segmentation faults. They seem to occur at
either SSL_accept or when a thread is exiting. There is no core dump. I have
very specific questions in this regard but first more details. I am developing this application on RH9 and OpenSSL 0.9.7a. I
have provided both callback functions required for multithreading. Both are
copied from mttest.c example file in the distribution, except for one change in
callback function. POSIX based version of the code in mttest.c has one
additional variable “lock_count”. Since, it was neither present in
other implementation nor called from anywhere else I didn’t include it in
my code. After replies from previous posts, I included this variable as well. And
here starts the interesting part. After “lock_count” was introduced, the server
showed completely bizarre behavior. It accepted few connections (5 – 50),
and then stopped accepting new requests. Not a single connection was accepted
even on plain sockets. When I changed it back to original and ran again, it is
running fine. Now here are my questions: -
Is it necessary for
me to use “lock_count” at all? -
If yes, example
code in the distribution only increments it. Should it be that way or should it
be decremented as well on lock release? -
Thirdly, what is
the purpose of SSL_CTX::references? Is it related to global variable “lock_count”
in anyway? -
Lastly, although it
might be a very silly question, but I am forced to ask due to unexpected
behavior of my application. In multithreading examples provided with the
distributions, all locking variables are named “lock_cs”
irrespective of their types (on different platforms). Similarly, the count
variable in POSIX specific code is “lock_count”. Do I have to use
these specific names or can I use any name of my choice? If these specific names
are not necessary, why did my application stopped accepting new connections
after handling few requests with “lock_count” incorporated as given
in multi-threading example? I am not in a position to locate the code by commenting
parts of it as was suggested in a previous reply. I have remote connection to
server where this code is run for testing, I have no control over client
applications and lastly segmentation fault occurs completely randomly. Once,
the server ran for 2 days without any fault. Any help will be highly appreciated. Regards Nauman Akbar Concise Solutions |
