Index: src/ngircd/conn.c
===================================================================
RCS file: /usr/local/CVS/ngircd/ngircd/src/ngircd/conn.c,v
retrieving revision 1.185
diff -u -p -r1.185 conn.c
--- src/ngircd/conn.c	21 Nov 2005 15:06:37 -0000	1.185
+++ src/ngircd/conn.c	6 Dec 2005 10:30:28 -0000
@@ -703,11 +703,16 @@ Conn_Close( CONN_ID Idx, char *LogMsg, c
 	/* Mark link as "closing" */
 	Conn_OPTION_ADD( &My_Connections[Idx], CONN_ISCLOSING );
 		
-	if( LogMsg ) txt = LogMsg;
-	else txt = FwdMsg;
-	if( ! txt ) txt = "Reason unknown";
-
-	Log( LOG_INFO, "Shutting down connection %d (%s) with %s:%d ...", Idx, LogMsg ? LogMsg : FwdMsg, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ));
+	if (LogMsg)
+		txt = LogMsg;
+	else
+		txt = FwdMsg;
+	if (! txt)
+		txt = "Reason unknown";
+
+	Log(LOG_INFO, "Shutting down connection %d (%s) with %s:%d ...", Idx,
+	    LogMsg ? LogMsg : FwdMsg, My_Connections[Idx].host,
+	    ntohs(My_Connections[Idx].addr.sin_port));
 
 	/* Search client, if any */
 	c = Client_GetFromConn( Idx );
@@ -743,39 +748,53 @@ Conn_Close( CONN_ID Idx, char *LogMsg, c
 	c = Client_GetFromConn( Idx );
 
 	/* Shut down socket */
-	if( ! io_close( My_Connections[Idx].sock ))
-	{
+	if (! io_close(My_Connections[Idx].sock)) {
 		/* Oops, we can't close the socket!? This is ... ugly! */
-		Log( LOG_CRIT, "Error closing connection %d (socket %d) with %s:%d - %s! (ignored)", Idx, My_Connections[Idx].sock, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port), strerror( errno ));
+		Log(LOG_CRIT,
+		    "Error closing connection %d (socket %d) with %s:%d - %s! (ignored)",
+		    Idx, My_Connections[Idx].sock, My_Connections[Idx].host,
+		    ntohs(My_Connections[Idx].addr.sin_port), strerror(errno));
 	}
 
 	/* 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 );
+	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 )) {
+	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;
+		if (! in_z_k)
+			in_z_k = in_k;
+		if (! out_z_k)
+			out_z_k = out_k;
 		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 );
+		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 );
+		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);
 	}
 
 	/* cancel running resolver */
-	if (Resolve_INPROGRESS(&My_Connections[Idx].res_stat)) {
+	if (Resolve_INPROGRESS(&My_Connections[Idx].res_stat))
 		Resolve_Shutdown(&My_Connections[Idx].res_stat);
-	}
 
 	/* Servers: Modify time of next connect attempt? */
 	Conf_UnsetServer( Idx );
@@ -792,6 +811,7 @@ Conn_Close( CONN_ID Idx, char *LogMsg, c
 
 	array_free(&My_Connections[Idx].rbuf);
 	array_free(&My_Connections[Idx].wbuf);
+
 	/* Clean up connection structure (=free it) */
 	Init_Conn_Struct( Idx );
 
