mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 11:33:09 +00:00
#1016 bugfix SSL_read and SSL_do_handshake
This commit is contained in:
@@ -178,10 +178,15 @@ _ltls_context_handshake(lua_State* L) {
|
||||
int ret = SSL_do_handshake(tls_p->ssl);
|
||||
if(ret == 1) {
|
||||
return 0;
|
||||
} else if (ret == -1) {
|
||||
int all_read = _bio_read(L, tls_p);
|
||||
if(all_read>0) {
|
||||
return 1;
|
||||
} else if (ret < 0) {
|
||||
int err = SSL_get_error(tls_p->ssl, ret);
|
||||
if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
|
||||
int all_read = _bio_read(L, tls_p);
|
||||
if(all_read>0) {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
luaL_error(L, "SSL_do_handshake error:%d ret:%d", err, ret);
|
||||
}
|
||||
} else {
|
||||
int err = SSL_get_error(tls_p->ssl, ret);
|
||||
@@ -212,7 +217,7 @@ _ltls_context_read(lua_State* L) {
|
||||
read = SSL_read(tls_p->ssl, outbuff, sizeof(outbuff));
|
||||
if(read < 0) {
|
||||
int err = SSL_get_error(tls_p->ssl, read);
|
||||
if(err == SSL_ERROR_WANT_READ) {
|
||||
if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
|
||||
break;
|
||||
}
|
||||
luaL_error(L, "SSL_read error:%d", err);
|
||||
@@ -221,7 +226,7 @@ _ltls_context_read(lua_State* L) {
|
||||
}else if (read > 0) {
|
||||
luaL_addlstring(&b, outbuff, read);
|
||||
}
|
||||
}while(read == sizeof(outbuff));
|
||||
}while(true);
|
||||
luaL_pushresult(&b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user