torwig commented on code in PR #3077:
URL: https://github.com/apache/kvrocks/pull/3077#discussion_r2232968948


##########
src/common/io_util.cc:
##########
@@ -310,8 +310,21 @@ Status SockSetBlocking(int fd, int blocking) {
 
 StatusOr<std::string> SockReadLine(int fd) {
   UniqueEvbuf evbuf;
-  if (evbuffer_read(evbuf.get(), fd, -1) <= 0) {
-    return Status::FromErrno("read response err");
+  while (true) {
+    int ret = evbuffer_read(evbuf.get(), fd, -1);
+    if (ret > 0) {
+      break;
+    } else if (ret == 0) {

Review Comment:
   Here we can make code more "flat":
   ```
   if (ret > 0) {
     break;
   }
    
   if (ret == 0) { 
     return Status::FromErrno("read response err: connection closed");
   } 
   
   if (errno == EAGAIN || errno == EWOULDBLOCK) {
       // Resource temporarily unavailable, sleep for a while
       std::this_thread::sleep_for(std::chrono::milliseconds(200));
       continue;
   }
   
   return Status::FromErrno("read response err");
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to