Skip to content

Commit

Permalink
suppressing socketStream warnings during shutdown initiated by SIGINT
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Graczer authored and Geod24 committed Aug 31, 2020
1 parent a027c23 commit a462db4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions source/eventcore/drivers/posix/driver.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import eventcore.internal.utils;

import core.time : MonoTime;
import std.algorithm.comparison : among, min, max;
import std.format : format;

version (Posix) {
package alias sock_t = int;
Expand Down Expand Up @@ -116,14 +117,23 @@ final class PosixEventDriver(Loop : PosixEventLoop) : EventDriver {
return thname.length ? thname : "unknown";
}

if (m_loop.m_handleCount > 0) {
string leaking_handle_desc;
foreach (id, ref s; m_loop.m_fds) {
if (!s.specific.hasType!(typeof(null)) && !(s.common.flags & FDFlags.internal) &&
(!s.specific.hasType!(StreamSocketSlot) || s.streamSocket.state == ConnectionState.connected))
try {
leaking_handle_desc ~= format!" FD %s (%s)\n"(id, s.specific.kind);
} catch (Exception ex) { print("exception happened in Driver.dispose() during formatting"); }
}

if(leaking_handle_desc.length) {
print("Warning (thread: %s): leaking eventcore driver because there are still active handles", getThreadName());
foreach (id, ref s; m_loop.m_fds)
if (!s.specific.hasType!(typeof(null)) && !(s.common.flags & FDFlags.internal))
print(" FD %s (%s)", id, s.specific.kind);
return false;
print(leaking_handle_desc);
}

if (m_loop.m_handleCount > 0)
return false;

m_processes.dispose();
m_files.dispose();
m_dns.dispose();
Expand Down

0 comments on commit a462db4

Please sign in to comment.