Open cbwood opened 2 years ago
确实错了,需要修改
惊了还真是 我自己大概看了一下,fd初始有一个O_RDWR状态(值为2),正常情况下与的结果应该是O_RDWR|O_NONBLOCK(2|2048=2050) 而F_GETFD返回的就是0,0|O_NONBLOCK还是O_NONBLOCK(2048),这段程序会导致丢失O_RDWR状态 但好像并不影响正常运行,不知道会不会在某种情况下成为一个雷
int WebServer::SetFdNonblock(int fd) { assert(fd > 0); return fcntl(fd, F_SETFL, fcntl(fd, F_GETFD, 0) | O_NONBLOCK); }
其中
F_GETFD
是否应该改为F_GETFL
? 确实是写错了,还好我自己实现的时候没有写错
我也注意到了,他写的这个项目,小问题挺多
其中
F_GETFD
是否应该改为F_GETFL
?