Skip to content

evpp ioevent benchmark closes only one endpoint of each socketpair #319

Description

@OneBucket126

Summary

Each FdChannel owns and closes g_pipes[2*i], but the peer endpoint g_pipes[2*i+1], used for writes, has no owner and is never closed.

Affected code

  • Repository commit: 477033f938fd47dfecde43c82257cd286d9fa38e
  • File: benchmark/ioevent/evpp/evpp_ioevent_bench.cc
  • Original scanner location: line 106

Evidence

Source: benchmark/ioevent/evpp/evpp_ioevent_bench.cc lines 104-123

 104:     g_pipes.resize(2 * numPipes);
 105:     for (int i = 0; i < numPipes; ++i) {
 106:         if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, &g_pipes[i * 2]) == -1) {
 107:             perror("pipe");
 108:         }
 109: 
 110:         if (evutil_make_socket_nonblocking(g_pipes[i*2]) < 0 ||
 111:             evutil_make_socket_nonblocking(g_pipes[i*2 + 1]) < 0) {
 112:         }
 113: 
 114:     }
 115: 
 116:     EventLoop loop;
 117:     g_loop = &loop;
 118: 
 119:     for (int i = 0; i < numPipes; ++i) {
 120:         FdChannel* channel = new FdChannel(&loop, g_pipes[i * 2], true, false);
 121:         channel->SetReadCallback(std::bind(readCallback, channel->fd(), i));
 122:         channel->AttachToLoop();
 123:         g_channels.push_back(channel);

Source: benchmark/ioevent/evpp/evpp_ioevent_bench.cc lines 140-146

 140:     for (auto it = g_channels.begin();
 141:          it != g_channels.end(); ++it) {
 142:         (*it)->DisableAllEvent();
 143:         (*it)->Close();
 144:         delete *it;
 145:     }
 146: }

Impact

The benchmark retains one file descriptor per socketpair until exit and can exhaust descriptor limits at larger pipe counts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions