+ new_size = Pool_Size + CONNECTION_POOL;
+
+ /* Im bisherigen Pool wurde keine freie Connection-Struktur mehr gefunden.
+ * Wenn erlaubt und moeglich muss nun der Pool vergroessert werden: */
+
+ if( Conf_MaxConnections > 0 )
+ {
+ /* Es ist ein Limit konfiguriert */
+ if( Pool_Size >= Conf_MaxConnections )
+ {
+ /* Mehr Verbindungen duerfen wir leider nicht mehr annehmen ... */
+ Log( LOG_ALERT, "Can't accept connection: limit (%d) reached!", Pool_Size );
+ close( new_sock );
+ return;
+ }
+ if( new_size > Conf_MaxConnections ) new_size = Conf_MaxConnections;
+ }
+ if( new_size < Pool_Size )
+ {
+ Log( LOG_ALERT, "Can't accespt connection: limit (%d) reached -- overflow!", Pool_Size );
+ close( new_sock );
+ return;
+ }
+
+ /* zunaechst realloc() versuchen; wenn das scheitert, malloc() versuchen
+ * und Daten ggf. "haendisch" umkopieren. (Haesslich! Eine wirklich
+ * dynamische Verwaltung waere wohl _deutlich_ besser ...) */
+ ptr = realloc( My_Connections, sizeof( CONNECTION ) * new_size );
+ if( ! ptr )
+ {
+ /* realloc() ist fehlgeschlagen. Nun malloc() probieren: */
+ ptr = malloc( sizeof( CONNECTION ) * new_size );
+ if( ! ptr )
+ {
+ /* Offenbar steht kein weiterer Sepeicher zur Verfuegung :-( */
+ Log( LOG_EMERG, "Can't allocate memory! [New_Connection]" );
+ close( new_sock );
+ return;
+ }
+
+ /* Struktur umkopieren ... */
+ memcpy( ptr, My_Connections, sizeof( CONNECTION ) * Pool_Size );
+
+ Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [malloc()/memcpy()]", new_size, sizeof( CONNECTION ) * new_size );
+ }
+ else Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [realloc()]", new_size, sizeof( CONNECTION ) * new_size );
+
+ /* Adjust pointer to new block */
+ My_Connections = ptr;
+
+ /* Initialize new items */
+ for( idx = Pool_Size; idx < new_size; idx++ ) Init_Conn_Struct( idx );
+ idx = Pool_Size;
+
+ /* Adjust new pool size */
+ Pool_Size = new_size;