| 168 |
|
send_queued_write(struct Client *to) |
| 169 |
|
{ |
| 170 |
|
int retlen = 0; |
| 171 |
+ |
#ifdef HAVE_TLS |
| 172 |
+ |
int want_read = 0; |
| 173 |
+ |
#endif |
| 174 |
|
|
| 175 |
|
/* |
| 176 |
|
** Once socket is marked dead, we cannot start writing to it, |
| 186 |
|
{ |
| 187 |
|
const struct dbuf_block *first = to->connection->buf_sendq.blocks.head->data; |
| 188 |
|
|
| 189 |
< |
#ifdef HAVE_LIBCRYPTO |
| 190 |
< |
if (to->connection->fd.ssl) |
| 189 |
> |
#ifdef HAVE_TLS |
| 190 |
> |
if (tls_isusing(&to->connection->fd.ssl)) |
| 191 |
|
{ |
| 192 |
< |
retlen = SSL_write(to->connection->fd.ssl, first->data + to->connection->buf_sendq.pos, first->size - to->connection->buf_sendq.pos); |
| 192 |
> |
retlen = tls_write(&to->connection->fd.ssl, first->data + to->connection->buf_sendq.pos, first->size - to->connection->buf_sendq.pos, &want_read); |
| 193 |
|
|
| 194 |
< |
/* translate openssl error codes, sigh */ |
| 195 |
< |
if (retlen < 0) |
| 193 |
< |
{ |
| 194 |
< |
switch (SSL_get_error(to->connection->fd.ssl, retlen)) |
| 195 |
< |
{ |
| 196 |
< |
case SSL_ERROR_WANT_READ: |
| 197 |
< |
return; /* retry later, don't register for write events */ |
| 198 |
< |
case SSL_ERROR_WANT_WRITE: |
| 199 |
< |
errno = EWOULDBLOCK; |
| 200 |
< |
case SSL_ERROR_SYSCALL: |
| 201 |
< |
break; |
| 202 |
< |
case SSL_ERROR_SSL: |
| 203 |
< |
if (errno == EAGAIN) |
| 204 |
< |
break; |
| 205 |
< |
default: |
| 206 |
< |
retlen = errno = 0; /* either an SSL-specific error or EOF */ |
| 207 |
< |
} |
| 208 |
< |
} |
| 194 |
> |
if (want_read) |
| 195 |
> |
return; /* Retry later, don't register for write events */ |
| 196 |
|
} |
| 197 |
|
else |
| 198 |
|
#endif |