- My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
- My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out;
-
- Log( LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx );
- Conn_SetOption( Idx, CONN_ZIP );
-
- return TRUE;
-} /* Conn_InitZip */
-
-
-GLOBAL LONG
-Conn_SendBytesZip( CONN_ID Idx )
-{
- /* Anzahl gesendeter Bytes (komprimiert!) liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].zip.bytes_out;
-} /* Conn_SendBytesZip */
-
-
-GLOBAL LONG
-Conn_RecvBytesZip( CONN_ID Idx )
-{
- /* Anzahl gesendeter Bytes (komprimiert!) liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].zip.bytes_in;
-} /* Conn_RecvBytesZip */
-
-#endif
-
-
-GLOBAL time_t
-Conn_StartTime( CONN_ID Idx )
-{
- /* Zeitpunkt des Link-Starts liefern (in Sekunden) */
-
- assert( Idx > NONE );
- return My_Connections[Idx].starttime;
-} /* Conn_Uptime */
-
-
-GLOBAL INT
-Conn_SendQ( CONN_ID Idx )
-{
- /* Laenge der Daten im Schreibbuffer liefern */
-
- assert( Idx > NONE );
-#ifdef USE_ZLIB
- if( My_Connections[Idx].options & CONN_ZIP ) return My_Connections[Idx].zip.wdatalen;
- else
-#endif
- return My_Connections[Idx].wdatalen;
-} /* Conn_SendQ */
-
-
-GLOBAL LONG
-Conn_SendMsg( CONN_ID Idx )
-{
- /* Anzahl gesendeter Nachrichten liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].msg_out;
-} /* Conn_SendMsg */
-
-
-GLOBAL LONG
-Conn_SendBytes( CONN_ID Idx )
-{
- /* Anzahl gesendeter Bytes (unkomprimiert) liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].bytes_out;
-} /* Conn_SendBytes */
-
-
-GLOBAL INT
-Conn_RecvQ( CONN_ID Idx )
-{
- /* Laenge der Daten im Lesebuffer liefern */
-
- assert( Idx > NONE );
-#ifdef USE_ZLIB
- if( My_Connections[Idx].options & CONN_ZIP ) return My_Connections[Idx].zip.rdatalen;
- else
-#endif
- return My_Connections[Idx].rdatalen;
-} /* Conn_RecvQ */
-
-
-GLOBAL LONG
-Conn_RecvMsg( CONN_ID Idx )
-{
- /* Anzahl empfangener Nachrichten liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].msg_in;
-} /* Conn_RecvMsg */
-
-
-GLOBAL LONG
-Conn_RecvBytes( CONN_ID Idx )
-{
- /* Anzahl empfangener Bytes (unkomprimiert) liefern */
-
- assert( Idx > NONE );
- return My_Connections[Idx].bytes_in;
-} /* Conn_RecvBytes */
-
-
-GLOBAL VOID
-Conn_ResetWCounter( VOID )
-{
- WCounter = 0;
-} /* Conn_ResetWCounter */
-
-
-GLOBAL LONG
-Conn_WCounter( VOID )
-{
- return WCounter;
-} /* Conn_WCounter */
-
-
-LOCAL BOOLEAN
-Try_Write( CONN_ID Idx )
-{
- /* Versuchen, Daten aus dem Schreib-Puffer in den Socket zu
- * schreiben. TRUE wird geliefert, wenn entweder keine Daten
- * zum Versenden vorhanden sind oder erfolgreich bearbeitet
- * werden konnten. Im Fehlerfall wird FALSE geliefert und
- * die Verbindung geschlossen. */
-
- fd_set write_socket;
- struct timeval tv;
-
- assert( Idx > NONE );
- assert( My_Connections[Idx].sock > NONE );
-
- /* sind ueberhaupt Daten vorhanden? */
-#ifdef USE_ZLIB
- if(( ! My_Connections[Idx].wdatalen > 0 ) && ( ! My_Connections[Idx].zip.wdatalen )) return TRUE;
-#else
- if( ! My_Connections[Idx].wdatalen > 0 ) return TRUE;
+ /* Mark socket as invalid: */
+ My_Connections[Idx].sock = NONE;
+
+ /* If there is still a client, unregister it now */
+ if( c ) Client_Destroy( c, LogMsg, FwdMsg, true );
+
+ /* Calculate statistics and log information */
+ in_k = (double)My_Connections[Idx].bytes_in / 1024;
+ out_k = (double)My_Connections[Idx].bytes_out / 1024;
+#ifdef ZLIB
+ if ( Conn_OPTION_ISSET( &My_Connections[Idx], 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