| 744 | } |
| 745 | |
| 746 | static int connTLSWrite(connection *conn_, const void *data, size_t data_len) { |
| 747 | tls_connection *conn = (tls_connection *) conn_; |
| 748 | int ret, ssl_err; |
| 749 | |
| 750 | if (conn->c.state != CONN_STATE_CONNECTED) return -1; |
| 751 | ERR_clear_error(); |
| 752 | ret = SSL_write(conn->ssl, data, data_len); |
| 753 | |
| 754 | if (ret <= 0) { |
| 755 | WantIOType want = 0; |
| 756 | if (!(ssl_err = handleSSLReturnCode(conn, ret, &want))) { |
| 757 | if (want == WANT_READ) conn->flags |= TLS_CONN_FLAG_WRITE_WANT_READ; |
| 758 | updateSSLEvent(conn); |
| 759 | errno = EAGAIN; |
| 760 | return -1; |
| 761 | } else { |
| 762 | if (ssl_err == SSL_ERROR_ZERO_RETURN || |
| 763 | ((ssl_err == SSL_ERROR_SYSCALL && !errno))) { |
| 764 | conn->c.state = CONN_STATE_CLOSED; |
| 765 | return 0; |
| 766 | } else { |
| 767 | conn->c.state = CONN_STATE_ERROR; |
| 768 | return -1; |
| 769 | } |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | return ret; |
| 774 | } |
| 775 | |
| 776 | static int connTLSRead(connection *conn_, void *buf, size_t buf_len) { |
| 777 | tls_connection *conn = (tls_connection *) conn_; |
nothing calls this directly
no test coverage detected