Github user jpeach commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1033#discussion_r80158464
  
    --- Diff: iocore/net/UnixNetVConnection.cc ---
    @@ -1273,14 +1273,21 @@ UnixNetVConnection::connectUp(EThread *t, int fd)
         con.is_bound     = true;
       }
     
    +  if (check_emergency_throttle(con)) {
    +    // `con' could be closed if there is hyper emergency
    +    if (con.fd == NO_FD) {
    +      NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, -1);
    +      // set errno force to EMFILE (reached limit for open file 
descriptors)
    +      res = errno = EMFILE;
    +      goto fail;
    +    }
    +  }
    +
       // Must connect after EventIO::Start() to avoid a race condition
       // when edge triggering is used.
       if (ep.start(get_PollDescriptor(t), this, EVENTIO_READ | EVENTIO_WRITE) 
< 0) {
    -    lerrno = errno;
         Debug("iocore_net", "connectUp : Failed to add to epoll list");
    -    action_.continuation->handleEvent(NET_EVENT_OPEN_FAILED, (void *)0); 
// 0 == res
    -    free(t);
    -    return CONNECT_FAILURE;
    +    goto fail;
    --- End diff --
    
    I think it would be more correct to set ``res`` to ``-errno``.  Ultimately, 
``EventIO::start`` returns -1 on failure and the other parts of this code are 
setting ``res`` to ``-errno`` on failure.
    
    How about:
    ```C
    if (ep.start(get_PollDescriptor(t), this, EVENTIO_READ | EVENTIO_WRITE) < 
0) {
      res = -errno;
      Debug("iocore_net", "failed to add to epoll list: %s", strerror(errno));
      goto fail;
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to