In the server application, we have the following: A class called JobManager, which is a singleton. Another class is the Scheduler, which continues to check whether it is time to add any jobs to the JobManager.
When the time comes, the Scheduler will do something like:
TJobManager.Singleton.NewJobItem(parameterlist goes here...);
At the same time, in the client application, the user is doing something that causes a call to the server. Inside, the server sends the message to itself, and one of the classes listening to this message is the JobManager. JobManager processes the message and knows that it is time to add a new job to the list by calling its own method:
NewJobItem(parameter list...);
In the NewJobItem method, I have something like this:
CS.Acquire; try DoSomething; CallAMethodWithAnotherCriticalSessionInternally; finally CS.Release; end;
It happens that at this moment the system reaches a dead end (CS.Acquire). The communication between the client and server applications is through Indy 10. I think the RPC call, which runs the server application method that sends the message to JobManager, works in the context of Indy Thread.
The Scheduler has its own thread, which makes a direct call to the JobManager method. Is this situation prone to deadlocks? Can someone help me understand why there is a dead end here?
We knew that sometimes, when the client performed a certain action, it caused the system to block, then I could finally find out this point where the critical section in the same class is reached twice, from different points (Scheduler and JobManager message handler method).
Additional Information
I want to add that (it might be stupid, but anyway ...) inside DoSomething there is still
CS.Acquire; try Do other stuff... finally CS.Release; end;
Does this internal CS.Release do anything for external CS.Acquire? If so, this could be the point at which the Scheduler enters the Critical section, and all locks and unlocks become riots.