[
https://issues.apache.org/jira/browse/TS-4879?focusedWorklogId=29549&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-29549
]
ASF GitHub Bot logged work on TS-4879:
--------------------------------------
Author: ASF GitHub Bot
Created on: 22/Sep/16 23:39
Start Date: 22/Sep/16 23:39
Worklog Time Spent: 10m
Work Description: 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;
}
```
Issue Time Tracking
-------------------
Worklog Id: (was: 29549)
Time Spent: 3h 10m (was: 3h)
> NetVC leaks while hyper emergency occur on check_emergency_throttle()
> ---------------------------------------------------------------------
>
> Key: TS-4879
> URL: https://issues.apache.org/jira/browse/TS-4879
> Project: Traffic Server
> Issue Type: Bug
> Components: Core
> Reporter: Oknet Xu
> Assignee: Oknet Xu
> Time Spent: 3h 10m
> Remaining Estimate: 0h
>
> The con could be closed if hyper emergency occur on
> check_emergency_throttle().
> But we did not check the con.fd while we get return from
> check_emergency_throttle().
> For hyper emergency:
> - The socket fd is removed from epoll while it is closed.
> - A NetVC with a closed socket fd is created and callback NET_EVENT_OPEN to
> SM.
> Thus:
> - The NetVC will never triggered by NetHandler.
> - Only InactivityCop could handle the NetVC and the default timeout value is
> 86400 secs.
> For the counter: net_connections_currently_open_stat
> - It is increased in “connect_re_internal()”
> - It isn't decreased while the con.fd set to NO_FD due to hyper emergency
> - Because it is decreased in close_UnixNetVConnection() only con.fd != NO_FD.
> (TS-4178)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)