/// <summary> The timeout thread. If it wakes from the sleep, future input /// is stopped and the request is timed out. /// </summary> override public void Run() { try { Thread.Sleep(new TimeSpan(10000 * timeToWait)); message.acceptReplies = false; // Note: Abandon clears the bind semaphore after failed bind. message.Abandon(null, new InterThreadException("Client request timed out", null, LdapException.Ldap_TIMEOUT, null, message)); } catch (ThreadInterruptedException) { // the timer was stopped, do nothing } }
/// <summary> Abandon the request associated with MsgId /// /// </summary> /// <param name="msgId">the message id to abandon /// /// </param> /// <param name="cons">constraints associated with this request /// </param> /* package */ internal void Abandon(int msgId, LdapConstraints cons) //, boolean informUser) { Message info = null; try { // Send abandon request and remove from connection list info = messages.findMessageById(msgId); SupportClass.VectorRemoveElement(messages, info); // This message is now dead info.Abandon(cons, null); } catch (FieldAccessException ex) { } }
/// <summary> The timeout thread. If it wakes from the sleep, future input /// is stopped and the request is timed out. /// </summary> public override void Run() { for (int i = 0; i < 10000; i++) { if (!IsStopping) { System.Threading.Thread.Sleep(new System.TimeSpan(timeToWait)); message.acceptReplies = false; // Note: Abandon clears the bind semaphore after failed bind. message.Abandon(null, new InterThreadException("Client request timed out", null, LdapException.Ldap_TIMEOUT, null, message)); } else { break; } } }
/// <summary> The timeout thread. If it wakes from the sleep, future input /// is stopped and the request is timed out. /// </summary> override public void Run() { try { ThrowIfCancellationRequested(); Thread.Sleep(new TimeSpan(10000 * timeToWait)); ThrowIfCancellationRequested(); message.acceptReplies = false; // Note: Abandon clears the bind semaphore after failed bind. message.Abandon(null, new InterThreadException("Client request timed out", null, LdapException.Ldap_TIMEOUT, null, message)); } catch (OperationCanceledException oce) { Debug.WriteLine("Timer was stopped by cancellation token"); } catch (Exception ie) { // the timer was stopped, do nothing } }
internal System.Object getLdapMessage(Integer32 msgId) { System.Object rfcMsg; // If no messages for this agent, just return null if (messages.Count == 0) { return(null); } if (msgId != null) { // Request messages for a specific ID try { // Get message for this ID // Message info = messages.findMessageById(msgId); Message info = messages.findMessageById(msgId.intValue); rfcMsg = info.waitForReply(); // blocks for a response if (!info.acceptsReplies() && !info.hasReplies()) { // Message complete and no more replies, remove from id list SupportClass.VectorRemoveElement(messages, info); info.Abandon(null, null); // Get rid of resources } else { } return(rfcMsg); } catch (System.FieldAccessException ex) { // no such message id return(null); } } else { // A msgId was NOT specified, any message will do lock (messages.SyncRoot) { while (true) { int next = indexLastRead + 1; Message info; for (int i = 0; i < messages.Count; i++) { if (next >= messages.Count) { next = 0; } info = (Message)messages[next]; indexLastRead = next++; rfcMsg = info.Reply; // Check this request is complete if (!info.acceptsReplies() && !info.hasReplies()) { // Message complete & no more replies, remove from id list SupportClass.VectorRemoveElement(messages, info); // remove from list info.Abandon(null, null); // Get rid of resources // Start loop at next message that is now moved // to the current position in the Vector. i -= 1; } if (rfcMsg != null) { // We got a reply return(rfcMsg); } else { // We found no reply here } } // end for loop */ // Messages can be removed in this loop, we we must // check if any messages left for this agent if (messages.Count == 0) { return(null); } // No data, wait for something to come in. try { System.Threading.Monitor.Wait(messages.SyncRoot, TimeSpan.FromSeconds(40)); } catch (System.Threading.ThreadInterruptedException ex) { } } /* end while */ } /* end synchronized */ } }