Skip to content

Commit cb50dcb

Browse files
Fix a bug of poll condition in redis driver.
1 parent 8dddfcc commit cb50dcb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/tredisdriver_unix.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ bool TRedisDriver::writeCommand(const QByteArray &command)
9696

9797
qint64 total = 0;
9898
while (total < command.length()) {
99-
if (tf_poll_send(_socket, 5000) == 0) {
99+
if (tf_poll_send(_socket, 5000) > 0) {
100100
qint64 len = tf_send(_socket, command.data() + total, command.length() - total);
101101
if (len < 0) {
102+
tSystemError("Socket send error [%s:%d]", __FILE__, __LINE__);
102103
break;
103104
}
104105
total += len;
105106
} else {
107+
tSystemError("Socket poll error [%s:%d]", __FILE__, __LINE__);
106108
break;
107109
}
108110
}
@@ -122,9 +124,10 @@ bool TRedisDriver::readReply()
122124
int timeout = 5000;
123125
int len = 0;
124126

125-
while (tf_poll_recv(_socket, timeout) == 0) {
127+
while (tf_poll_recv(_socket, timeout) > 0) {
126128
len = tf_recv(_socket, buf.data(), RECV_BUF_SIZE, 0);
127129
if (len <= 0) {
130+
tSystemError("Socket recv error [%s:%d]", __FILE__, __LINE__);
128131
break;
129132
}
130133

0 commit comments

Comments
 (0)