commit - 09416f36bf9fde8365022bc1f4d5f73d868edd7c
commit + 63e89ceb21c4a12d1f3d29342b45ed2a5e513b2b
blob - 513c3c70768b0fc60aa70f12f3e8560c0ef73f07
blob + 051309739c9a8495cf5f3889430be98814adb09a
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.206 2007/05/09 08:55:14 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.207 2007/05/09 13:21:11 fw Exp $";
#include "imp.h"
#include <assert.h>
static bool Handle_Write PARAMS(( CONN_ID Idx ));
+static bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, size_t Len ));
static int New_Connection PARAMS(( int Sock ));
static CONN_ID Socket2Index PARAMS(( int Sock ));
static void Read_Request PARAMS(( CONN_ID Idx ));
} /* Conn_WriteStr */
-GLOBAL bool
+/**
+ * Append Data to outbound write buf.
+ * @param Idx Index fo the connection.
+ * @param Data pointer to data
+ * @param Len length of Data
+ * @return true on success, false otherwise.
+ */
+static bool
Conn_Write( CONN_ID Idx, char *Data, size_t Len )
{
- /* Daten in Socket schreiben. Bei "fatalen" Fehlern wird
- * der Client disconnectiert und false geliefert. */
-
CLIENT *c;
size_t writebuf_limit = WRITEBUFFER_LEN;
assert( Idx > NONE );
assert( c != NULL);
if (Client_Type(c) == CLIENT_SERVER)
writebuf_limit = WRITEBUFFER_LEN * 10;
- /* Ist der entsprechende Socket ueberhaupt noch offen? In einem
- * "Handler-Durchlauf" kann es passieren, dass dem nicht mehr so
- * ist, wenn einer von mehreren Conn_Write()'s fehlgeschlagen ist.
- * In diesem Fall wird hier einfach ein Fehler geliefert. */
+ /* Is the socket still open? A previous call to Conn_Write()
+ * may have closed the connection due to a fatal error.
+ * In this case it is sufficient to return an error */
if( My_Connections[Idx].sock <= NONE ) {
LogDebug("Skipped write on closed socket (connection %d).", Idx );
return false;
}
- /* Pruefen, ob im Schreibpuffer genuegend Platz ist. Ziel ist es,
- * moeglichts viel im Puffer zu haben und _nicht_ gleich alles auf den
- * Socket zu schreiben (u.a. wg. Komprimierung). */
+ /* check if outbound buffer has enough space for data.
+ * the idea is to keep data buffered before sending, e.g. to improve
+ * compression */
if (array_bytes(&My_Connections[Idx].wbuf) >= writebuf_limit) {
- /* Der Puffer ist dummerweise voll. Jetzt versuchen, den Puffer
- * zu schreiben, wenn das nicht klappt, haben wir ein Problem ... */
+ /* Buffer is full, flush. Handle_Write deals with low-level errors, if any. */
if( ! Handle_Write( Idx )) return false;
/* check again: if our writebuf is twice als large as the initial limit: Kill connection */
#ifdef ZLIB
if ( Conn_OPTION_ISSET( &My_Connections[Idx], CONN_ZIP )) {
- /* Daten komprimieren und in Puffer kopieren */
+ /* compress and move data to write buffer */
if( ! Zip_Buffer( Idx, Data, Len )) return false;
}
else
#endif
{
- /* Daten in Puffer kopieren */
+ /* copy data to write buffer */
if (!array_catb( &My_Connections[Idx].wbuf, Data, Len ))
return false;
blob - 9a794a1e2236cf351817816c75149aea57a63cab
blob + 03dcbfd1b75e8dae52acd10d79cc289ef618b435
--- src/ngircd/conn.h
+++ src/ngircd/conn.h
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: conn.h,v 1.43 2007/04/04 21:52:12 fw Exp $
+ * $Id: conn.h,v 1.44 2007/05/09 13:21:11 fw Exp $
*
* Connection management (header)
*/
GLOBAL void Conn_Handler PARAMS(( void ));
-GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, size_t Len ));
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));