Example #1
0
        private string Format(CPoolEntry entry)
        {
            StringBuilder buf = new StringBuilder();

            buf.Append("[id: ").Append(entry.GetId()).Append("]");
            buf.Append("[route: ").Append(entry.GetRoute()).Append("]");
            object state = entry.GetState();

            if (state != null)
            {
                buf.Append("[state: ").Append(state).Append("]");
            }
            return(buf.ToString());
        }
Example #2
0
 public virtual void ReleaseConnection(HttpClientConnection managedConn, object state
                                       , long keepalive, TimeUnit tunit)
 {
     Args.NotNull(managedConn, "Managed connection");
     lock (managedConn)
     {
         CPoolEntry entry = CPoolProxy.Detach(managedConn);
         if (entry == null)
         {
             return;
         }
         ManagedHttpClientConnection conn = entry.GetConnection();
         try
         {
             if (conn.IsOpen())
             {
                 entry.SetState(state);
                 entry.UpdateExpiry(keepalive, tunit != null ? tunit : TimeUnit.Milliseconds);
                 if (this.log.IsDebugEnabled())
                 {
                     string s;
                     if (keepalive > 0)
                     {
                         s = "for " + (double)keepalive / 1000 + " seconds";
                     }
                     else
                     {
                         s = "indefinitely";
                     }
                     this.log.Debug("Connection " + Format(entry) + " can be kept alive " + s);
                 }
             }
         }
         finally
         {
             this.pool.Release(entry, conn.IsOpen() && entry.IsRouteComplete());
             if (this.log.IsDebugEnabled())
             {
                 this.log.Debug("Connection released: " + Format(entry) + FormatStats(entry.GetRoute
                                                                                          ()));
             }
         }
     }
 }