浏览代码

Merge branch 'appletls-wantread' of https://github.com/nmaier/aria2 into nmaier-appletls-cred-kc

Tatsuhiro Tsujikawa 12 年之前
父节点
当前提交
83b801a0a5
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      src/AppleTLSSession.cc

+ 9 - 4
src/AppleTLSSession.cc

@@ -422,17 +422,22 @@ int AppleTLSSession::closeConnection()
 }
 
 int AppleTLSSession::checkDirection() {
-  if (writeBuffered_) {
-    return TLS_WANT_WRITE;
-  }
+  // See: https://github.com/tatsuhiro-t/aria2/pull/61#issuecomment-16051793
   if (state_ == st_connected) {
+    // Need to check read first, as SocketCore kinda expects this
     size_t buffered;
     lastError_ = SSLGetBufferedReadSize(sslCtx_, &buffered);
     if (lastError_ == noErr && buffered) {
       return TLS_WANT_READ;
     }
   }
-  return 0;
+
+  if (writeBuffered_) {
+    return TLS_WANT_WRITE;
+  }
+
+  // Default to WANT_READ, as SocketCore kinda expects this
+  return TLS_WANT_READ;
 }
 
 ssize_t AppleTLSSession::writeData(const void* data, size_t len)