Hello,

now as I have sokme time to visit my dll problem again I recoded the
whole thing according to your suggestions which I do appreciate.

But it nevertheless crashes, although not as often as before. A TeabB
member already told me that I shouldn't create and destroy my global dll
thread I'm using in the initialization and finalization parts of the
dll, but for the finalizing part I don't know how to avoid.

The dll now looks like this:

- initialization creates a TThread descendant which is unique
  for the whole dll.
- this thread has a message pump with peekmessage and pm_remove
- it also has a state machine, the normal state is to process these
  messages (peekmessage...)
- there is a global list of open connections which also has the sockets
  being used.
- one can open a coonection by informing the thread to do so, the
  statemachine changes state then until the connection is opened.
- this is secured by a critical section
- the finalize method sends .terminate to the thread and has a waiting
  loop for timeout detection. In this loop I had message processing via
  peermessage as well, but it also crashed as explained below.
- when terminating, the thread looks at all open connections and
  closes it

I set it up this way so that a program which forgot (maybe it crashed)
to close any connections doesn't do too much harm, the dll will close
them then. The normal way would be to send another message to the thread
to close the connection.

Now I wrote a simple test program which Loadlibraries the dll, waits
some ms and freelibraries it then and waits another few ms. This is done
up to 1000 times to check whether it works or not. if only done a few
times all is well, but when really trying to do it 1000x it crashes (the
app hangs) and even windows explorer is crashed so that the PC has to be
rebootet then. It crashes after 200-300 cycles mostly.

How can I avoid to terminate the thread from finalize if the normal way
fails maybe due to a program crash?

What happens if the dll is used statically and what if dynamically? What
if several apps use the dll at the same time? is
initialization/finalization being called several times?

Opening the connection (one time so far) works good. if I can solve the
crash mentioned above I would be able to build the rest of it (using ICS).

Greetings and sorry for the bit length post

Markus
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to