Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in the named pipe Serverloop creates huge logfiles and high CPU usage #81

Open
renetenthije opened this issue Sep 27, 2023 · 1 comment

Comments

@renetenthije
Copy link

The Serverloop in NpListener.cs calls ProcessNextClient() in a while loop. If an exception is thrown in the ProcessNextClient method, a message is logged and the loop continues. From the comment line I understand that this is done on purpose, but the result is that it writes log messages as fast as it can when an exceptions happens repeatedly. In my case that resulted in a logfile over 1 gigabyte within 1 or 2 minutes and a high CPU usage. Exceptions can happen there for more reasons than reaching the connection limit only. In our case it was an UnauthorizedAccessException. Another reason could be an invalid pipename e.g.

I don't know what the best solution would be. Maybe silently catch the specific exception that is triggered by exceeding the number of available connections, pause for 50ms and continue? And re-throw all other exceptions?

private void ServerLoop()
{
    while (running)
    {
        ProcessNextClient();
    }
}

public void ProcessNextClient()
{
    try
    {
        // pipe code
        // every exception thrown here causes a log message 
    }
    catch (Exception e)
    {
        //If there are no more avail connections (254 is in use already) then just keep looping until one is avail
        _log.Error("ProcessNextClient error: {0}", e.ToString().Flatten());
     }
}
@tylerje
Copy link
Member

tylerje commented Jan 11, 2024

Or only log the Nth instance of the exception? I'll try to get to this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants