[ 
https://issues.apache.org/jira/browse/THRIFT-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16639864#comment-16639864
 ] 

ASF GitHub Bot commented on THRIFT-4618:
----------------------------------------

jeking3 commented on a change in pull request #1580: THRIFT-4618: Use poll() 
instead of select() in C++ TNonblockingServer if available
URL: https://github.com/apache/thrift/pull/1580#discussion_r223017516
 
 

 ##########
 File path: lib/cpp/src/thrift/server/TNonblockingServer.cpp
 ##########
 @@ -1291,10 +1295,44 @@ bool 
TNonblockingIOThread::notify(TNonblockingServer::TConnection* conn) {
     return false;
   }
 
-  fd_set wfds, efds;
-  long ret = -1;
+  int ret = -1;
   long kSize = sizeof(conn);
-  const char* pos = reinterpret_cast<const char*>(&conn);
+  const char * pos = (const char *)const_cast_sockopt(&conn);
+
+#if defined(HAVE_POLL_H) || defined(HAVE_SYS_POLL_H)
+  struct pollfd pfd = {fd, POLLOUT, 0};
+
+  while (kSize > 0) {
+    pfd.revents = 0;
+    ret = poll(&pfd, 1, -1);
+    if (ret < 0) {
+      return false;
+    } else if (ret == 0) {
+      continue;
+    }
+
+    if (pfd.revents & POLLHUP || pfd.revents & POLLERR) {
+      ::close(fd);
 
 Review comment:
   Should this and the other instances of close instead be THRIFT_CLOSESOCKET 
like the other code path?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> TNonblockingServer crash because of limitation of select()
> ----------------------------------------------------------
>
>                 Key: THRIFT-4618
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4618
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Library
>    Affects Versions: 0.9.3
>            Reporter: Alexander Boldyrev
>            Priority: Critical
>              Labels: C++, TNonblockingServer
>
> Process opened more than 1024 file descriptors. When new incoming connection 
> was established to TNonblockingServer, sig 6 came from one of 
> 'select'-related macros (FD_ZERO/FD_SET).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to