mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +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);
|
int ret = SSL_do_handshake(tls_p->ssl);
|
||||||
if(ret == 1) {
|
if(ret == 1) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ret == -1) {
|
} else if (ret < 0) {
|
||||||
int all_read = _bio_read(L, tls_p);
|
int err = SSL_get_error(tls_p->ssl, ret);
|
||||||
if(all_read>0) {
|
if(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) {
|
||||||
return 1;
|
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 {
|
} else {
|
||||||
int err = SSL_get_error(tls_p->ssl, ret);
|
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));
|
read = SSL_read(tls_p->ssl, outbuff, sizeof(outbuff));
|
||||||
if(read < 0) {
|
if(read < 0) {
|
||||||
int err = SSL_get_error(tls_p->ssl, read);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
luaL_error(L, "SSL_read error:%d", err);
|
luaL_error(L, "SSL_read error:%d", err);
|
||||||
@@ -221,7 +226,7 @@ _ltls_context_read(lua_State* L) {
|
|||||||
}else if (read > 0) {
|
}else if (read > 0) {
|
||||||
luaL_addlstring(&b, outbuff, read);
|
luaL_addlstring(&b, outbuff, read);
|
||||||
}
|
}
|
||||||
}while(read == sizeof(outbuff));
|
}while(true);
|
||||||
luaL_pushresult(&b);
|
luaL_pushresult(&b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user