Ticket #42471

Don't try to write log messages to the TCP listener file descriptor

Open Date: 2021-06-05 07:43 Last Update: 2022-02-19 18:55

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
1

Details

When starting a new game from the main menu the client spawns an instance of freeciv-server. When no --log argument was specified for the client the logfile variable is NULL and client_start_server ends up closing stdout and stderr without opening any file to replace them. The next file descriptor that is allocated happens to belong to the TCP listener. lsof for the server process:

freeciv-s 824527 gunnar 0r CHR 1,3 0t0 4 /dev/null

freeciv-s 824527 gunnar 1u IPv6 1362042 0t0 TCP [::1]:farenet (LISTEN)

freeciv-s 824527 gunnar 2u IPv4 1362043 0t0 TCP 127.0.0.1:farenet (LISTEN)

freeciv-s 824527 gunnar 3u IPv6 1341307 0t0 TCP [::1]:farenet->[::1]:54822 (ESTABLISHED)

This results in further log messages to be written to the TCP listener file descriptor.

Ticket History (3/10 Histories)

2021-06-05 07:43 Updated by: gunnarbeutner
  • New Ticket "Don't try to write log messages to the TCP listener file descriptor" created
2021-06-05 07:45 Updated by: gunnarbeutner
  • Details Updated
2021-06-05 07:47 Updated by: gunnarbeutner
  • Type Update from Bugs to Patches
2021-06-16 13:56 Updated by: cazfi
Comment

Isn't the FIXME comment about port related to command line parameters and not the logfile? Moving it inside the "if (logfile)" block makes no sense then.

2022-02-07 16:27 Updated by: cazfi
  • Milestone Update from (None) to 3.0.1 (closed)
  • Component Update from (None) to Client common
2022-02-13 22:51 Updated by: cazfi
  • Owner Update from (None) to cazfi
  • Resolution Update from None to Accepted
Comment

Reply To cazfi

Isn't the FIXME comment about port related to command line parameters and not the logfile? Moving it inside the "if (logfile)" block makes no sense then.

Looking closer, it does make sense. No need to change the patch.

2022-02-19 16:38 Updated by: cazfi
  • Status Update from Open to Closed
  • Resolution Update from Accepted to Fixed
2022-02-19 16:58 Updated by: cazfi
Comment

Occurred to me a bit late, but opening "/dev/null" might not work too well on Windows. Checking situation...

2022-02-19 18:55 Updated by: cazfi
Comment

Reply To cazfi

Occurred to me a bit late, but opening "/dev/null" might not work too well on Windows. Checking situation...

Ok, that particular code block is not used in Windows, at least as long as msys2 or cygwin implements fork() that is good enough for freeciv's configure check.

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login