Skip to content

SocketReactor loads one core of CPU up to 100% #2966

@dmitry-pozdniakov

Description

@dmitry-pozdniakov

I have found a bug in SocketReactor for Linux. This is relevant for v1.10.1.

Steps to reproduce:

  1. Create and run the reactor.
  2. Create a socket and connect to a remote host.
  3. Subscribe to various types of events by using SocketReactor::addEventHandler() method. For example: ReadableNotification, WritableNotification and TimeoutNotification.
  4. Send some data to the socket.
  5. Wait for the WritableNotification event and unsubscribe from this event by using SocketReactor::removeEventHandler() method.

Voila!

It happened because your forgot to update _pollSet and remove the corresponding epoll event. As a result, _pollSet.poll() immediately returns with an event that doesn't have handle (in this example PollSet::POLL_WRITE). This happens over and over without any delay and loads the processor.

I have provided you with a simple fix for this error.

poco.patch.txt

Let me know if I was wrong. Thanks

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions