sock: Add handling for want read/write
This commit is contained in:
@ -211,8 +211,15 @@ long sock_send(sock *s, void *buf, unsigned long len, int flags) {
|
|||||||
|
|
||||||
long ret;
|
long ret;
|
||||||
if (s->enc) {
|
if (s->enc) {
|
||||||
ret = SSL_write(s->ssl, buf, (int) len);
|
while (1) {
|
||||||
if (ret <= 0) sock_error(s, (int) ret);
|
ret = SSL_write(s->ssl, buf, (int) len);
|
||||||
|
if (ret <= 0) {
|
||||||
|
sock_error(s, (int) ret);
|
||||||
|
if (error_get_ssl() == SSL_ERROR_WANT_WRITE)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (s->pipe) {
|
} else if (s->pipe) {
|
||||||
if (flags & ~MSG_MORE) {
|
if (flags & ~MSG_MORE) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -255,8 +262,15 @@ long sock_recv(sock *s, void *buf, unsigned long len, int flags) {
|
|||||||
long ret;
|
long ret;
|
||||||
if (s->enc) {
|
if (s->enc) {
|
||||||
int (*func)(SSL *, void *, int) = (flags & MSG_PEEK) ? SSL_peek : SSL_read;
|
int (*func)(SSL *, void *, int) = (flags & MSG_PEEK) ? SSL_peek : SSL_read;
|
||||||
ret = func(s->ssl, buf, (int) len);
|
while (1) {
|
||||||
if (ret <= 0) sock_error(s, (int) ret);
|
ret = func(s->ssl, buf, (int) len);
|
||||||
|
if (ret <= 0) {
|
||||||
|
sock_error(s, (int) ret);
|
||||||
|
if (error_get_ssl() == SSL_ERROR_WANT_READ)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (s->pipe) {
|
} else if (s->pipe) {
|
||||||
if (flags & ~MSG_WAITALL) {
|
if (flags & ~MSG_WAITALL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
Reference in New Issue
Block a user