34
34
#include " error_response.hpp"
35
35
#include " event_response.hpp"
36
36
#include " logger.hpp"
37
- #include " utils.hpp"
38
37
39
38
#ifdef HAVE_NOSIGPIPE
40
39
#include < sys/socket.h>
@@ -344,14 +343,14 @@ void Connection::internal_close(ConnectionState close_state) {
344
343
345
344
if (state_ != CONNECTION_STATE_CLOSE &&
346
345
state_ != CONNECTION_STATE_CLOSE_DEFUNCT) {
347
- uv_handle_t * handle = copy_cast< uv_tcp_t *, uv_handle_t *>(&socket_);
346
+ uv_handle_t * handle = reinterpret_cast < uv_handle_t *>(&socket_);
348
347
if (!uv_is_closing (handle)) {
349
348
heartbeat_timer_.stop ();
350
349
terminate_timer_.stop ();
351
350
connect_timer_.stop ();
352
351
if (state_ == CONNECTION_STATE_CONNECTED ||
353
352
state_ == CONNECTION_STATE_READY) {
354
- uv_read_stop (copy_cast< uv_tcp_t *, uv_stream_t *>(&socket_));
353
+ uv_read_stop (reinterpret_cast < uv_stream_t *>(&socket_));
355
354
}
356
355
set_state (close_state);
357
356
uv_close (handle, on_close);
@@ -530,23 +529,23 @@ void Connection::on_connect(Connector* connector) {
530
529
connection->host_ ->address_string ().c_str (),
531
530
static_cast <void *>(connection));
532
531
533
- #ifdef HAVE_NOSIGPIPE
532
+ #if defined( HAVE_NOSIGPIPE) && UV_VERSION_MAJOR >= 1
534
533
// This must be done after connection for the socket file descriptor to be
535
534
// valid.
536
535
uv_os_fd_t fd = 0 ;
537
536
int enabled = 1 ;
538
- if (uv_fileno (copy_cast< uv_tcp_t *, uv_handle_t *>(&connection->socket_ ), &fd) != 0 ||
537
+ if (uv_fileno (reinterpret_cast < uv_handle_t *>(&connection->socket_ ), &fd) != 0 ||
539
538
setsockopt (fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&enabled, sizeof (int )) != 0 ) {
540
539
LOG_WARN (" Unable to set socket option SO_NOSIGPIPE for host %s" ,
541
540
connection->host_ ->address_string ().c_str ());
542
541
}
543
542
#endif
544
543
545
544
if (connection->ssl_session_ ) {
546
- uv_read_start (copy_cast< uv_tcp_t *, uv_stream_t *>(&connection->socket_ ),
545
+ uv_read_start (reinterpret_cast < uv_stream_t *>(&connection->socket_ ),
547
546
Connection::alloc_buffer_ssl, Connection::on_read_ssl);
548
547
} else {
549
- uv_read_start (copy_cast< uv_tcp_t *, uv_stream_t *>(&connection->socket_ ),
548
+ uv_read_start (reinterpret_cast < uv_stream_t *>(&connection->socket_ ),
550
549
Connection::alloc_buffer, Connection::on_read);
551
550
}
552
551
@@ -1036,7 +1035,7 @@ void Connection::PendingWrite::flush() {
1036
1035
}
1037
1036
1038
1037
is_flushed_ = true ;
1039
- uv_stream_t * sock_stream = copy_cast< uv_tcp_t *, uv_stream_t *>(&connection_->socket_ );
1038
+ uv_stream_t * sock_stream = reinterpret_cast < uv_stream_t *>(&connection_->socket_ );
1040
1039
uv_write (&req_, sock_stream, bufs.data (), bufs.size (), PendingWrite::on_write);
1041
1040
}
1042
1041
}
@@ -1106,7 +1105,7 @@ void Connection::PendingWriteSsl::flush() {
1106
1105
1107
1106
LOG_TRACE (" Sending %u encrypted bytes" , static_cast <unsigned int >(encrypted_size_));
1108
1107
1109
- uv_stream_t * sock_stream = copy_cast< uv_tcp_t *, uv_stream_t *>(&connection_->socket_ );
1108
+ uv_stream_t * sock_stream = reinterpret_cast < uv_stream_t *>(&connection_->socket_ );
1110
1109
uv_write (&req_, sock_stream, bufs.data (), bufs.size (), PendingWriteSsl::on_write);
1111
1110
1112
1111
is_flushed_ = true ;
@@ -1123,7 +1122,7 @@ void Connection::PendingWriteSsl::on_write(uv_write_t* req, int status) {
1123
1122
1124
1123
bool Connection::SslHandshakeWriter::write (Connection* connection, char * buf, size_t buf_size) {
1125
1124
SslHandshakeWriter* writer = new SslHandshakeWriter (connection, buf, buf_size);
1126
- uv_stream_t * stream = copy_cast< uv_tcp_t *, uv_stream_t *>(&connection->socket_ );
1125
+ uv_stream_t * stream = reinterpret_cast < uv_stream_t *>(&connection->socket_ );
1127
1126
1128
1127
int rc = uv_write (&writer->req_ , stream, &writer->uv_buf_ , 1 , SslHandshakeWriter::on_write);
1129
1128
if (rc != 0 ) {
0 commit comments