URL:
  <http://gna.org/bugs/?16461>

                 Summary: server can exceed MAX_NUM_CONNECTIONS and leak
sockets
                 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: 

    _______________________________________________________

Details:

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:

  <http://gna.org/bugs/?16461>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to