| 116 | } |
| 117 | |
| 118 | int CEvent::WakeUp() |
| 119 | { |
| 120 | int nRet = 0; |
| 121 | //qDebug(log) << "WakeUp()"; |
| 122 | #if HAVE_EVENTFD |
| 123 | if(INVALID_SOCKET == fd[0]) |
| 124 | return -1; |
| 125 | nRet = eventfd_write(fd[0], 1); |
| 126 | if(nRet) { |
| 127 | if(EAGAIN == errno || EWOULDBLOCK == errno) |
| 128 | return 0; |
| 129 | qDebug(log) << "eventfd_write fail" << errno << "-" << strerror(errno); |
| 130 | } |
| 131 | #else |
| 132 | if(INVALID_SOCKET == fd[1]) |
| 133 | return -1; |
| 134 | const int len = 1; |
| 135 | char buf[len]; |
| 136 | nRet = send(fd[1], buf, len, 0); |
| 137 | if(nRet >= 0) { |
| 138 | //qDebug(log) << "send" << nRet; |
| 139 | return 0; |
| 140 | } |
| 141 | if(nRet < 0) { |
| 142 | if(EAGAIN == errno || EWOULDBLOCK == errno) |
| 143 | return 0; |
| 144 | qDebug(log) << "send fail" << "fd:" << fd[1] |
| 145 | << "error:" << errno << "-" << strerror(errno); |
| 146 | } |
| 147 | #endif |
| 148 | return nRet; |
| 149 | } |
| 150 | |
| 151 | qintptr CEvent::GetFd() |
| 152 | { |