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

sometimes goes into a 100% CPU loop when an fd is closed #73

Closed

Conversation

folkertvanheusden
Copy link
Contributor

No description provided.

@folkertvanheusden folkertvanheusden mentioned this pull request Aug 20, 2021
@davidmoreno
Copy link
Owner

Looks a bit overkill as any exception on the callback of the poller will cause it to be removed. This should be only for some exceptions about the fd being invalid or similar. Si maybe a new exception of "invalid_fd" or similar.

@folkertvanheusden
Copy link
Contributor Author

What about c5d6c29?

There is something strange with this code from poller.cpp:

    } catch (const invalid_fd &e) {
      ERROR("Caught exception at poller: {}, forgetting fd {}.", e.what(), fd);
      remove_fd(fd);
    }

and rtpclient.cpp:

void rtpclient::data_ready(rtppeer::port_e port) {
  uint8_t raw[1500];
  struct sockaddr_in6 cliaddr;
  unsigned int len = sizeof(cliaddr);
  auto socket = port == rtppeer::CONTROL_PORT ? control_socket : midi_socket;
  auto n = recvfrom(socket, raw, 1500, MSG_DONTWAIT,
                    (struct sockaddr *)&cliaddr, &len);
  // DEBUG("Got some data from control: {}", n);
  if (n < 0) {
    if (errno == EBADF)
      throw invalid_fd("Filedescriptor {} for {}/{}-port is invalid",
                      socket, peer.remote_name,
                      port == rtppeer::CONTROL_PORT ? "control" : "MIDI");
Aug 20 19:16:01 lappiemctopface rtpmidid[33230]: [poller.cpp:204] Caught exception at poller: Filedescriptor 18 for DOREMiDi-MIDI/MIDI-port is invalid, forgetting fd 10.

I don't understand why it is 18 in data_ready and 10 in the poller.

@davidmoreno
Copy link
Owner

I think you might be getting a fd problem called from an event of another fd.

The invalid_fd exception should say which fd had the exception, and then remove that one from the poller.

@folkertvanheusden
Copy link
Contributor Author

folkertvanheusden commented Aug 20, 2021 via email

@davidmoreno
Copy link
Owner

The how, storing the fd at the exception and using it later.

About dangling.. if one fails the other should fail too sooner or later, isnt it? If not then maybe we should add some callback to be called when a fd is removed... or is this getting too complicated?

@folkertvanheusden
Copy link
Contributor Author

folkertvanheusden commented Aug 20, 2021 via email

@davidmoreno
Copy link
Owner

I can only think that becaus eof whatever happenend on the first fd affected to do something on the second. For example an ALSA event may cause to send some network data.

Do you know https://rr-project.org/ ? I did try it years ago, and dont know if it will help, but I think it can record the full history of one crash, and then we can inspect why it got there.

Can you give it a try?

@folkertvanheusden
Copy link
Contributor Author

folkertvanheusden commented Aug 21, 2021 via email

@folkertvanheusden
Copy link
Contributor Author

folkertvanheusden commented Aug 21, 2021 via email

@davidmoreno
Copy link
Owner

Code would not apply on current master.

Please open a issue or another pull request.

Thanks a lot anyway for the effort for creating this pull request.

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

Successfully merging this pull request may close these issues.

None yet

2 participants