| 1061 | } |
| 1062 | |
| 1063 | static int connTLSWrite(connection *conn_, const void *data, size_t data_len) { |
| 1064 | tls_connection *conn = (tls_connection *) conn_; |
| 1065 | int ret, ssl_err; |
| 1066 | |
| 1067 | if (data_len == 0) |
| 1068 | return 0; |
| 1069 | |
| 1070 | if (conn->c.state != CONN_STATE_CONNECTED) return -1; |
| 1071 | ERR_clear_error(); |
| 1072 | ret = SSL_write(conn->ssl, data, data_len); |
| 1073 | |
| 1074 | if (ret <= 0) { |
| 1075 | WantIOType want = WANT_INVALID; |
| 1076 | if (!(ssl_err = handleSSLReturnCode(conn, ret, &want))) { |
| 1077 | if (want == WANT_READ) conn->flags |= TLS_CONN_FLAG_WRITE_WANT_READ; |
| 1078 | updateSSLEvent(conn); |
| 1079 | errno = EAGAIN; |
| 1080 | return -1; |
| 1081 | } else { |
| 1082 | if (ssl_err == SSL_ERROR_ZERO_RETURN || |
| 1083 | ((ssl_err == SSL_ERROR_SYSCALL && !errno))) { |
| 1084 | conn->c.state = CONN_STATE_CLOSED; |
| 1085 | return 0; |
| 1086 | } else { |
| 1087 | conn->c.state = CONN_STATE_ERROR; |
| 1088 | return -1; |
| 1089 | } |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | return ret; |
| 1094 | } |
| 1095 | |
| 1096 | static int connTLSRead(connection *conn_, void *buf, size_t buf_len) { |
| 1097 | tls_connection *conn = (tls_connection *) conn_; |
nothing calls this directly
no test coverage detected