Skip to content

Commit d4bded2

Browse files
update
1 parent 48dc75a commit d4bded2

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/turingcoroutine_linux.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,24 @@ class AsyncSendFile : public TAwaitBase {
105105
bool completed() const override
106106
{
107107
//tSystemInfo("AsyncSendFile::completed : _offset:{} _cqeflags:{} _cqeres:{}", _offset, _cqeflags, _cqeres);
108-
return (_cqeres < 0) || (_offset + _cqeres >= _fileSize);
108+
switch (_state) {
109+
case State::WaitForPollOut:
110+
if (_cqeres == POLLOUT) {
111+
return (_offset + _cqeres >= _fileSize);
112+
} else {
113+
// POLLERR or POLLHUP
114+
return true;
115+
}
116+
break;
117+
118+
case State::Sending:
119+
return (_cqeres <= 0);
120+
121+
case State::Idle:
122+
default:
123+
tSystemError("Bad status [{}:{}]", __FILE__, __LINE__);
124+
return true;
125+
}
109126
}
110127

111128
void iterate() override
@@ -116,7 +133,6 @@ class AsyncSendFile : public TAwaitBase {
116133
switch (_state) {
117134
case State::WaitForPollOut:
118135
if (_cqeres < 0) {
119-
// error
120136
return;
121137
}
122138
_state = State::Idle;
@@ -144,7 +160,7 @@ class AsyncSendFile : public TAwaitBase {
144160
}
145161
}
146162

147-
int res = TUringServer::instance()->addPoll(_sd, POLLOUT, this);
163+
int res = TUringServer::instance()->addPoll(_sd, (POLLOUT | POLLERR | POLLHUP), this);
148164
if (res < 0) {
149165
tSystemError("addPoll error: {}", strerror(errno));
150166
_cqeres = -1;

src/turingserver_linux.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ TUringServer::TUringServer(int listeningSocket, QObject *parent) :
8080
TApplicationServerBase(),
8181
_listenSocket(listeningSocket)
8282
{
83-
io_uring_queue_init(8192 * 2, &_ring, 0);
83+
io_uring_queue_init(8192, &_ring, 0);
8484

8585
// Event fd
8686
_notifyFd = eventfd(0, (EFD_NONBLOCK | EFD_CLOEXEC));
@@ -229,7 +229,7 @@ void TUringServer::run()
229229
}
230230
}
231231
} else {
232-
tSystemDebug("cqe->res:{} cqe->flags: {}", await->_cqeres, cqe->flags);
232+
tSystemDebug("cqe->res:{} cqe->flags: {}", cqe->res, cqe->flags);
233233
if (cqe->flags != IORING_CQE_F_MORE) [[likely]] {
234234
if (!await->_cqeres && !await->_cqeflags) {
235235
await->_cqeres = cqe->res;

0 commit comments

Comments
 (0)