internal virtual void Abandon(LdapConstraints cons, InterThreadException informUserEx)
{
if (!waitForReply_Renamed_Field)
{
return ;
}
acceptReplies = false; // don't listen to anyone
waitForReply_Renamed_Field = false; // don't let sleeping threads lie
if (!complete)
{
try
{
// If a bind, release bind semaphore & wake up waiting threads
// Must do before writing abandon message, otherwise deadlock
if (bindprops != null)
{
int id;
if (conn.BindSemIdClear)
{
// Semaphore id for normal operations
id = msgId;
}
else
{
// Semaphore id for sasl bind
id = conn.BindSemId;
conn.clearBindSemId();
}
conn.freeWriteSemaphore(id);
}
// Create the abandon message, but don't track it.
LdapControl[] cont = null;
if (cons != null)
{
cont = cons.getControls();
}
LdapMessage msg = new LdapAbandonRequest(msgId, cont);
// Send abandon message to server
conn.writeMessage(msg);
}
catch (LdapException ex)
{
; // do nothing
}
// If not informing user, remove message from agent
if (informUserEx == null)
{
agent.Abandon(msgId, null);
}
conn.removeMessage(this);
}
// Get rid of all replies queued
if (informUserEx != null)
{
replies.Add(new LdapResponse(informUserEx, conn.ActiveReferral));
stopTimer();
// wake up waiting threads to receive exception
sleepersAwake();
// Message will get cleaned up when last response removed from queue
}
else
{
// Wake up any waiting threads, so they can terminate.
// If informing the user, we wake sleepers after
// caller queues dummy response with error status
sleepersAwake();
cleanup();
}
return ;
}