/// <summary> Creates an LdapResponse using an LdapException. /// Used to wake up the user following an abandon. /// Note: The abandon doesn't have to be user initiated /// but may be the result of error conditions. /// /// Referral information is available if this connection created solely /// to follow a referral. /// /// </summary> /// <param name="ex"> The exception /// /// </param> /// <param name="activeReferral"> The referral actually used to create the /// connection /// </param> public LdapResponse(InterThreadException ex, ReferralInfo activeReferral) { exception = ex; this.activeReferral = activeReferral; }
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(); } }