NIO+Multithreaded TCPSocket listener, very low cpu utilisation
kdevel
kdevel at vogtner.de
Wed Nov 15 20:13:48 UTC 2017
On Wednesday, 15 November 2017 at 14:22:51 UTC, Daniel Kozak
wrote:
> And this one
> https://paste.ofcode.org/KNqxcrmACLZLseB45MvwC
I thrash your code with two shell processes
```
while true; do curl 127.0.0.1:4444 -o /dev/null; done
```
running parallel. Using strace -fFeclose on the binary this
happens frequently:
```
:
[pid 10926] close(5) = 0
[pid 10926] close(4) = 0
[pid 10926] close(4) = 0
[pid 10926] close(4) = 0
[pid 10926] close(4) = 0
[pid 10926] --- SIGUSR1 (User defined signal 1) @ 0 (0) ---
[pid 10926] --- SIGUSR2 (User defined signal 2) @ 0 (0) ---
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
:
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
[pid 10919] close(4294967295) = -1 EBADF (Bad file
descriptor)
[pid 10926] close(4) = 0
[pid 10926] close(4) = 0
[pid 10926] close(4) = 0
:
```
The destructor of Socket is trying to close the already closed
socket? If the worker I change
```
socket.close();
```
to
```
destroy (socket);
```
these close(-1) calls go away.
More information about the Digitalmars-d-learn
mailing list