+ in_k = (DOUBLE)My_Connections[Idx].bytes_in / 1024;
+ out_k = (DOUBLE)My_Connections[Idx].bytes_out / 1024;
+#ifdef USE_ZLIB
+ if( My_Connections[Idx].options & CONN_ZIP )
+ {
+ in_z_k = (DOUBLE)My_Connections[Idx].zip.bytes_in / 1024;
+ out_z_k = (DOUBLE)My_Connections[Idx].zip.bytes_out / 1024;
+ in_p = (INT)(( in_k * 100 ) / in_z_k );
+ out_p = (INT)(( out_k * 100 ) / out_z_k );
+ Log( LOG_INFO, "Connection %d with %s:%d closed (in: %.1fk/%.1fk/%d%%, out: %.1fk/%.1fk/%d%%).", Idx, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ), in_k, in_z_k, in_p, out_k, out_z_k, out_p );
+ }
+ else
+#endif
+ {
+ Log( LOG_INFO, "Connection %d with %s:%d closed (in: %.1fk, out: %.1fk).", Idx, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ), in_k, out_k );
+ }
+ }
+
+ /* Socket als "ungueltig" markieren */
+ FD_CLR( My_Connections[Idx].sock, &My_Sockets );
+ FD_CLR( My_Connections[Idx].sock, &My_Connects );
+ My_Connections[Idx].sock = NONE;
+
+ if( c ) Client_Destroy( c, LogMsg, FwdMsg, TRUE );
+
+ if( My_Connections[Idx].res_stat )
+ {
+ /* Resolver-Strukturen freigeben, wenn noch nicht geschehen */
+ FD_CLR( My_Connections[Idx].res_stat->pipe[0], &Resolver_FDs );
+ close( My_Connections[Idx].res_stat->pipe[0] );
+ close( My_Connections[Idx].res_stat->pipe[1] );
+ free( My_Connections[Idx].res_stat );
+ }
+
+ /* Startzeit des naechsten Connect-Versuchs modifizieren? */
+ if(( My_Connections[Idx].our_server > NONE ) && ( Conf_Server[My_Connections[Idx].our_server].lasttry < time( NULL ) - Conf_ConnectRetry ))
+ {
+ /* Okay, die Verbindung stand schon "genuegend lange":
+ * lasttry-Zeitpunkt so setzen, dass der naechste
+ * Verbindungsversuch in RECONNECT_DELAY Sekunden
+ * gestartet wird. */
+ Conf_Server[My_Connections[Idx].our_server].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
+ }
+
+#ifdef USE_ZLIB
+ /* Ggf. zlib abmelden */
+ if( Conn_Options( Idx ) & CONN_ZIP )
+ {
+ inflateEnd( &My_Connections[Idx].zip.in );
+ deflateEnd( &My_Connections[Idx].zip.out );
+ }
+#endif
+
+ /* Connection-Struktur loeschen (=freigeben) */
+ Init_Conn_Struct( Idx );
+} /* Conn_Close */
+
+
+GLOBAL VOID
+Conn_UpdateIdle( CONN_ID Idx )
+{
+ /* Idle-Timer zuruecksetzen */
+
+ assert( Idx > NONE );
+ My_Connections[Idx].lastprivmsg = time( NULL );
+}
+
+
+GLOBAL time_t
+Conn_GetIdle( CONN_ID Idx )
+{
+ /* Idle-Time einer Verbindung liefern (in Sekunden) */
+
+ assert( Idx > NONE );
+ return time( NULL ) - My_Connections[Idx].lastprivmsg;
+} /* Conn_GetIdle */
+
+
+GLOBAL time_t
+Conn_LastPing( CONN_ID Idx )
+{
+ /* Zeitpunkt des letzten PING liefern */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].lastping;
+} /* Conn_LastPing */
+
+
+GLOBAL VOID
+Conn_SetPenalty( CONN_ID Idx, time_t Seconds )
+{
+ /* Penalty-Delay fuer eine Verbindung (in Sekunden) setzen;
+ * waehrend dieser Zeit wird der entsprechende Socket vom Server
+ * bei Lese-Operationen komplett ignoriert. Der Delay kann mit
+ * dieser Funktion nur erhoeht, nicht aber verringert werden. */
+
+ time_t t;
+
+ assert( Idx > NONE );
+ assert( Seconds >= 0 );
+
+ t = time( NULL ) + Seconds;
+ if( t > My_Connections[Idx].delaytime ) My_Connections[Idx].delaytime = t;
+} /* Conn_SetPenalty */
+
+
+GLOBAL VOID
+Conn_ResetPenalty( CONN_ID Idx )
+{
+ assert( Idx > NONE );
+ My_Connections[Idx].delaytime = 0;
+} /* Conn_ResetPenalty */
+
+
+GLOBAL VOID
+Conn_ClearFlags( VOID )
+{
+ /* Alle Connection auf "nicht-markiert" setzen */
+
+ LONG i;
+
+ for( i = 0; i < Pool_Size; i++ ) My_Connections[i].flag = 0;
+} /* Conn_ClearFlags */
+
+
+GLOBAL INT
+Conn_Flag( CONN_ID Idx )
+{
+ /* Ist eine Connection markiert (TRUE) oder nicht? */
+
+ assert( Idx > NONE );
+ return My_Connections[Idx].flag;
+} /* Conn_Flag */
+
+
+GLOBAL VOID
+Conn_SetFlag( CONN_ID Idx, INT Flag )
+{
+ /* Connection markieren */
+
+ assert( Idx > NONE );
+ My_Connections[Idx].flag = Flag;
+} /* Conn_SetFlag */
+
+
+GLOBAL CONN_ID
+Conn_First( VOID )
+{
+ /* Connection-Struktur der ersten Verbindung liefern;
+ * Ist keine Verbindung vorhanden, wird NONE geliefert. */
+
+ LONG i;
+
+ for( i = 0; i < Pool_Size; i++ )
+ {
+ if( My_Connections[i].sock != NONE ) return i;
+ }
+ return NONE;
+} /* Conn_First */
+
+
+GLOBAL CONN_ID
+Conn_Next( CONN_ID Idx )
+{
+ /* Naechste Verbindungs-Struktur liefern; existiert keine
+ * weitere, so wird NONE geliefert. */
+
+ LONG i = NONE;
+
+ assert( Idx > NONE );
+
+ for( i = Idx + 1; i < Pool_Size; i++ )
+ {
+ if( My_Connections[i].sock != NONE ) return i;