Summary: server can exceed MAX_NUM_CONNECTIONS and leak
                 Project: Freeciv
            Submitted by: kernigh
            Submitted on: Tuesday 08/17/2010 at 00:02
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: S2_2
         Discussion Lock: Any
        Operating System: *BSD
         Planned Release: 



If too many clients connect to the server, then the server accepts the extra
connections, then does nothing with the extra sockets.

MAX_NUM_CONNECTIONS is now 64. To reproduce this bug without opening 64
clients, use a script (like this Ruby line) to create 64 connections:

ruby -rsocket -e '64.times { TCPSocket.new("localhost", 5556) }; gets'

Then open Freeciv client and make 65th connection. Server will log this:

1: maximum number of connections reached
1: failed accepting connection

The server never closes the 65th socket, so the client waits forever.

After hundreds of connections, the server reaches a process limit and repeats
this message to infinity:

1: accept failed: Too many open files
1: failed accepting connection

One must understand that 'listen(socket, MAX_NUM_CONNECTIONS)' allows a
backlog of 64 connections. After the server accepts 64 connections, the
backlog is empty and the server can accept more connections.

To fix this bug, server_make_connection() in server/sernet.c might need to
close the extra socket (after perhaps sending an error to the client).


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to