[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Env.shutdown() thread safety



On Wed, 20 Dec 2000, Peter Schuller wrote:
> Hello,
> 
> could someone who knows the ins and outs of Ozone confirm/deny that Env.shutdown()
> is safe to envoke from any thread? It would seem it is, but I want to make sure.

No, it isn't. Calling Env.shutdown() from a transaction thread causes the whole
thing to deadlock, since shutdown waits on transactions to end.

In case of LocalDatabase Env.shutdown() _can_ be called from any thread but not
from "within" the server.

There are two cases to shutdown ozone: ExternalDatabase and LocalDatabase. In
case of ExternalDatabase the Env is initialized by the Server which also should
shut it down. Therefore it exposes a stop variable, which any thread can set to
true. In case of LocalDatabase, a client thread simple calls
LocalDatabase.close.

> 
> Btw, any objections against possibly working to make the DxLib stuff not use
> Thread.stop() (which is deprecated - for good reason), and instead go for a 
> co-operative approach?

There are two stop()s in the code.

DxAsyncClient: is no longer used by ozone

DxMultiServer: here is stops an Acceptor, which has no internal state. So the
use of stop() should not cause any problems here.

So, it was not very high on my todo list. Anyway, we should replace both.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com