Menu

#319 Fixes to the simpleserver so it does not leak and can be stopped

v1.2.x
open
5
2016-01-10
2015-05-31
No

A simple loggingserver that (1) does not leak memory each time we connect to it, (2) can reply with the server version, (3) can quit cleanly.

I will provide a patch too, if you prefer to use such, but really most of the file was modified one way or another so not much is left of the original... so I'm also providing the loggingserver.cxx file as is here.

The threads would work fine and die, but once dead the ClientThread object would never get deleted. Also the simple server was so simple that the only way to quit was to kill the process and we could not be sure what would happen on the thread (they should be transformed into stand alone processes and continue to survive the server which I think is wrong because they could survive forever--as long as the client was still connected to them.)

Let me know if you have any question about the code. I tested quite a bit with the existing socket_test, but I suppose we should look in a way to have a test we can actually run and that proves that most of the code is works as expected.

1 Attachments

Discussion

  • Alexis Wilke

    Alexis Wilke - 2015-05-31

    So, as I mentioned, there is a patch if you prefer such a file...

     
  • Václav Haisman

    Václav Haisman - 2015-05-31
    • assigned_to: Václav Haisman
     
  • Alexis Wilke

    Alexis Wilke - 2015-10-28

    There is a new version with a couple of comments and lines of code fixed (cleaned up, really).

     
  • Václav Haisman

    Václav Haisman - 2016-01-10

    Hmm, the leak has been fixed differently by https://github.com/log4cplus/log4cplus/commit/99b6abedff15ef83e679c129e849e07ad286672f and previous comits.

    Also the simple server was so simple that the only way to quit was to kill the process and we could not be sure what would happen on the thread (they should be transformed into stand alone processes and continue to survive the server which I think is wrong because they could survive forever--as long as the client was still connected to them.)

    I do not understand this. Once process dies, all of its threads are dead.

    From your source comments:

            // client requested a quit from the whole server
            // WARNING: this is absolutely not secure...
    

    I agree with the warning. :-) I think killing the process through signals is still better.

     
  • Alexis Wilke

    Alexis Wilke - 2016-01-10

    It depends on the thread library and the current settings. Threads are not automatically killed when the main process is killed. They can survive their parent process.

    The Unix signal (kill 123) or sending a message to the process are both insecure. I guess it depends on whether you open the connection to anywhere anywhere. Also a kill prevents a clean shutdown in case a message can still be saved, cleanly, before quitting.

     

Log in to post a comment.