mirror of https://github.com/axmolengine/axmol.git
CCConsole: remove fd from _read_set when it is closed by client. (#19066)
* CCConsole: remove fd from _read_set when it is closed by client. * simplify code * remove comment
This commit is contained in:
parent
c61e45103c
commit
11339c4545
|
@ -743,10 +743,8 @@ void Console::loop()
|
|||
FD_SET(_listenfd, &_read_set);
|
||||
_maxfd = _listenfd;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
|
||||
/* 0.016 seconds. Wake up once per frame at 60PFS */
|
||||
timeout.tv_usec = 16000;
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(!_endThread) {
|
||||
|
||||
|
@ -790,11 +788,17 @@ void Console::loop()
|
|||
ioctlsocket(fd, FIONREAD, &n);
|
||||
#else
|
||||
int n = 0;
|
||||
ioctl(fd, FIONREAD, &n);
|
||||
if(ioctl(fd, FIONREAD, &n) < 0)
|
||||
{
|
||||
cocos2d::log("Abnormal error in ioctl()\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if(n == 0)
|
||||
{
|
||||
//no data received, or fd is closed
|
||||
//fix #18620. readable and no pending data means that the fd is closed.
|
||||
to_remove.push_back(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue