src: Use static_cast instead of reinterpret_cast if possible

This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-19 19:46:58 +09:00
parent 660e1ec44d
commit dfbea797bd
13 changed files with 116 additions and 118 deletions

View File

@ -80,7 +80,7 @@ void start_element_func
const xmlChar *name, const xmlChar *name,
const xmlChar **attrs) const xmlChar **attrs)
{ {
auto parser_data = reinterpret_cast<ParserData*>(user_data); auto parser_data = static_cast<ParserData*>(user_data);
if(util::strieq(reinterpret_cast<const char*>(name), "link")) { if(util::strieq(reinterpret_cast<const char*>(name), "link")) {
auto rel_attr = get_attr(attrs, "rel"); auto rel_attr = get_attr(attrs, "rel");
auto href_attr = get_attr(attrs, "href"); auto href_attr = get_attr(attrs, "href");

View File

@ -216,7 +216,7 @@ namespace {
void readcb(bufferevent *bev, void *ptr) void readcb(bufferevent *bev, void *ptr)
{ {
int rv; int rv;
auto handler = reinterpret_cast<Http2Handler*>(ptr); auto handler = static_cast<Http2Handler*>(ptr);
rv = handler->on_read(); rv = handler->on_read();
if(rv != 0) { if(rv != 0) {
delete_handler(handler); delete_handler(handler);
@ -231,7 +231,7 @@ void writecb(bufferevent *bev, void *ptr)
return; return;
} }
int rv; int rv;
auto handler = reinterpret_cast<Http2Handler*>(ptr); auto handler = static_cast<Http2Handler*>(ptr);
rv = handler->on_write(); rv = handler->on_write();
if(rv != 0) { if(rv != 0) {
delete_handler(handler); delete_handler(handler);
@ -242,7 +242,7 @@ void writecb(bufferevent *bev, void *ptr)
namespace { namespace {
void eventcb(bufferevent *bev, short events, void *ptr) void eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto handler = reinterpret_cast<Http2Handler*>(ptr); auto handler = static_cast<Http2Handler*>(ptr);
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
// SSL/TLS handshake completed // SSL/TLS handshake completed
if(handler->verify_npn_result() != 0) { if(handler->verify_npn_result() != 0) {
@ -267,7 +267,7 @@ namespace {
void connhd_readcb(bufferevent *bev, void *ptr) void connhd_readcb(bufferevent *bev, void *ptr)
{ {
uint8_t data[24]; uint8_t data[24];
auto handler = reinterpret_cast<Http2Handler*>(ptr); auto handler = static_cast<Http2Handler*>(ptr);
size_t leftlen = handler->get_left_connhd_len(); size_t leftlen = handler->get_left_connhd_len();
auto input = bufferevent_get_input(bev); auto input = bufferevent_get_input(bev);
int readlen = evbuffer_remove(input, data, leftlen); int readlen = evbuffer_remove(input, data, leftlen);
@ -353,7 +353,7 @@ int Http2Handler::on_write()
namespace { namespace {
void settings_timeout_cb(evutil_socket_t fd, short what, void *arg) void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{ {
auto hd = reinterpret_cast<Http2Handler*>(arg); auto hd = static_cast<Http2Handler*>(arg);
hd->terminate_session(NGHTTP2_SETTINGS_TIMEOUT); hd->terminate_session(NGHTTP2_SETTINGS_TIMEOUT);
hd->on_write(); hd->on_write();
} }
@ -606,7 +606,7 @@ ssize_t hd_send_callback(nghttp2_session *session,
const uint8_t *data, size_t len, int flags, const uint8_t *data, size_t len, int flags,
void *user_data) void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
return hd->sendcb(data, len); return hd->sendcb(data, len);
} }
} // namespace } // namespace
@ -615,7 +615,7 @@ namespace {
ssize_t hd_recv_callback(nghttp2_session *session, ssize_t hd_recv_callback(nghttp2_session *session,
uint8_t *data, size_t len, int flags, void *user_data) uint8_t *data, size_t len, int flags, void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
return hd->recvcb(data, len); return hd->recvcb(data, len);
} }
} // namespace } // namespace
@ -778,7 +778,7 @@ int on_header_callback(nghttp2_session *session,
const uint8_t *value, size_t valuelen, const uint8_t *value, size_t valuelen,
void *user_data) void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) { if(hd->get_config()->verbose) {
verbose_on_header_callback(session, frame, name, namelen, value, valuelen, verbose_on_header_callback(session, frame, name, namelen, value, valuelen,
user_data); user_data);
@ -812,7 +812,7 @@ int on_end_headers_callback(nghttp2_session *session,
frame->headers.cat != NGHTTP2_HCAT_REQUEST) { frame->headers.cat != NGHTTP2_HCAT_REQUEST) {
return 0; return 0;
} }
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
auto stream = hd->get_stream(frame->hd.stream_id); auto stream = hd->get_stream(frame->hd.stream_id);
if(!stream) { if(!stream) {
return 0; return 0;
@ -847,7 +847,7 @@ namespace {
int hd_on_frame_recv_callback int hd_on_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) { if(hd->get_config()->verbose) {
print_session_id(hd->session_id()); print_session_id(hd->session_id());
verbose_on_frame_recv_callback(session, frame, user_data); verbose_on_frame_recv_callback(session, frame, user_data);
@ -884,7 +884,7 @@ int hd_on_frame_recv_callback
int htdocs_on_request_recv_callback int htdocs_on_request_recv_callback
(nghttp2_session *session, int32_t stream_id, void *user_data) (nghttp2_session *session, int32_t stream_id, void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
auto stream = hd->get_stream(stream_id); auto stream = hd->get_stream(stream_id);
if(stream) { if(stream) {
prepare_response(stream, hd); prepare_response(stream, hd);
@ -896,7 +896,7 @@ namespace {
int hd_before_frame_send_callback int hd_before_frame_send_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) { if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
auto stream_id = frame->push_promise.promised_stream_id; auto stream_id = frame->push_promise.promised_stream_id;
auto req = util::make_unique<Request>(stream_id); auto req = util::make_unique<Request>(stream_id);
@ -914,7 +914,7 @@ int hd_on_frame_send_callback
(nghttp2_session *session, const nghttp2_frame *frame, (nghttp2_session *session, const nghttp2_frame *frame,
void *user_data) void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) { if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
auto stream = hd->get_stream(frame->push_promise.promised_stream_id); auto stream = hd->get_stream(frame->push_promise.promised_stream_id);
if(stream) { if(stream) {
@ -945,7 +945,7 @@ int hd_on_data_recv_callback
void *user_data) void *user_data)
{ {
// TODO Handle POST // TODO Handle POST
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) { if(hd->get_config()->verbose) {
print_session_id(hd->session_id()); print_session_id(hd->session_id());
verbose_on_data_recv_callback(session, length, flags, stream_id, verbose_on_data_recv_callback(session, length, flags, stream_id,
@ -960,7 +960,7 @@ int hd_on_data_send_callback
(nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id, (nghttp2_session *session, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data) void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
if(hd->get_config()->verbose) { if(hd->get_config()->verbose) {
print_session_id(hd->session_id()); print_session_id(hd->session_id());
verbose_on_data_send_callback(session, length, flags, stream_id, verbose_on_data_send_callback(session, length, flags, stream_id,
@ -975,7 +975,7 @@ int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code, (nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
void *user_data) void *user_data)
{ {
auto hd = reinterpret_cast<Http2Handler*>(user_data); auto hd = static_cast<Http2Handler*>(user_data);
hd->remove_stream(stream_id); hd->remove_stream(stream_id);
if(hd->get_config()->verbose) { if(hd->get_config()->verbose) {
print_session_id(hd->session_id()); print_session_id(hd->session_id());
@ -1061,8 +1061,7 @@ namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) void *arg)
{ {
auto next_proto = auto next_proto = static_cast<std::pair<unsigned char*, size_t>* >(arg);
reinterpret_cast<std::pair<unsigned char*, size_t>* >(arg);
*data = next_proto->first; *data = next_proto->first;
*len = next_proto->second; *len = next_proto->second;
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
@ -1082,7 +1081,7 @@ namespace {
void evlistener_acceptcb(evconnlistener *listener, int fd, void evlistener_acceptcb(evconnlistener *listener, int fd,
sockaddr *addr, int addrlen, void *arg) sockaddr *addr, int addrlen, void *arg)
{ {
auto handler = reinterpret_cast<ListenEventHandler*>(arg); auto handler = static_cast<ListenEventHandler*>(arg);
handler->accept_connection(fd, addr, addrlen); handler->accept_connection(fd, addr, addrlen);
} }
} // namespace } // namespace
@ -1170,7 +1169,7 @@ int alpn_select_proto_cb(SSL* ssl,
const unsigned char *in, unsigned int inlen, const unsigned char *in, unsigned int inlen,
void *arg) void *arg)
{ {
auto config = reinterpret_cast<HttpServer*>(arg)->get_config(); auto config = static_cast<HttpServer*>(arg)->get_config();
if(config->verbose) { if(config->verbose) {
std::cout << "[ALPN] client offers:" << std::endl; std::cout << "[ALPN] client offers:" << std::endl;
} }

View File

@ -888,7 +888,7 @@ int htp_msg_begincb(http_parser *htp)
namespace { namespace {
int htp_status_completecb(http_parser *htp) int htp_status_completecb(http_parser *htp)
{ {
auto client = reinterpret_cast<HttpClient*>(htp->data); auto client = static_cast<HttpClient*>(htp->data);
client->upgrade_response_status_code = htp->status_code; client->upgrade_response_status_code = htp->status_code;
return 0; return 0;
} }
@ -897,7 +897,7 @@ int htp_status_completecb(http_parser *htp)
namespace { namespace {
int htp_msg_completecb(http_parser *htp) int htp_msg_completecb(http_parser *htp)
{ {
auto client = reinterpret_cast<HttpClient*>(htp->data); auto client = static_cast<HttpClient*>(htp->data);
client->upgrade_response_complete = true; client->upgrade_response_complete = true;
return 0; return 0;
} }
@ -1026,7 +1026,7 @@ void update_html_parser(HttpClient *client, Request *req,
namespace { namespace {
HttpClient* get_session(void *user_data) HttpClient* get_session(void *user_data)
{ {
return reinterpret_cast<HttpClient*>(user_data); return static_cast<HttpClient*>(user_data);
} }
} // namespace } // namespace
@ -1302,7 +1302,7 @@ namespace {
void upgrade_readcb(bufferevent *bev, void *ptr) void upgrade_readcb(bufferevent *bev, void *ptr)
{ {
int rv; int rv;
auto client = reinterpret_cast<HttpClient*>(ptr); auto client = static_cast<HttpClient*>(ptr);
rv = client->on_upgrade_read(); rv = client->on_upgrade_read();
if(rv != 0) { if(rv != 0) {
client->disconnect(); client->disconnect();
@ -1314,7 +1314,7 @@ namespace {
void readcb(bufferevent *bev, void *ptr) void readcb(bufferevent *bev, void *ptr)
{ {
int rv; int rv;
auto client = reinterpret_cast<HttpClient*>(ptr); auto client = static_cast<HttpClient*>(ptr);
rv = client->on_read(); rv = client->on_read();
if(rv != 0) { if(rv != 0) {
client->disconnect(); client->disconnect();
@ -1329,7 +1329,7 @@ void writecb(bufferevent *bev, void *ptr)
return; return;
} }
int rv; int rv;
auto client = reinterpret_cast<HttpClient*>(ptr); auto client = static_cast<HttpClient*>(ptr);
rv = client->on_write(); rv = client->on_write();
if(rv != 0) { if(rv != 0) {
client->disconnect(); client->disconnect();
@ -1341,7 +1341,7 @@ namespace {
void eventcb(bufferevent *bev, short events, void *ptr) void eventcb(bufferevent *bev, short events, void *ptr)
{ {
int rv; int rv;
auto client = reinterpret_cast<HttpClient*>(ptr); auto client = static_cast<HttpClient*>(ptr);
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
client->state = STATE_CONNECTED; client->state = STATE_CONNECTED;
int fd = bufferevent_getfd(bev); int fd = bufferevent_getfd(bev);
@ -1420,7 +1420,7 @@ ssize_t client_send_callback(nghttp2_session *session,
const uint8_t *data, size_t len, int flags, const uint8_t *data, size_t len, int flags,
void *user_data) void *user_data)
{ {
auto client = reinterpret_cast<HttpClient*>(user_data); auto client = static_cast<HttpClient*>(user_data);
return client->sendcb(data, len); return client->sendcb(data, len);
} }
} // namespace } // namespace
@ -1430,7 +1430,7 @@ ssize_t client_recv_callback(nghttp2_session *session,
uint8_t *buf, size_t len, int flags, uint8_t *buf, size_t len, int flags,
void *user_data) void *user_data)
{ {
auto client = reinterpret_cast<HttpClient*>(user_data); auto client = static_cast<HttpClient*>(user_data);
return client->recvcb(buf, len); return client->recvcb(buf, len);
} }
} // namespace } // namespace

View File

@ -62,7 +62,7 @@ namespace {
void ssl_acceptcb(evconnlistener *listener, int fd, void ssl_acceptcb(evconnlistener *listener, int fd,
sockaddr *addr, int addrlen, void *arg) sockaddr *addr, int addrlen, void *arg)
{ {
auto handler = reinterpret_cast<ListenHandler*>(arg); auto handler = static_cast<ListenHandler*>(arg);
handler->accept_connection(fd, addr, addrlen); handler->accept_connection(fd, addr, addrlen);
} }
} // namespace } // namespace

View File

@ -47,7 +47,7 @@ namespace shrpx {
namespace { namespace {
void upstream_readcb(bufferevent *bev, void *arg) void upstream_readcb(bufferevent *bev, void *arg)
{ {
auto handler = reinterpret_cast<ClientHandler*>(arg); auto handler = static_cast<ClientHandler*>(arg);
int rv = handler->on_read(); int rv = handler->on_read();
if(rv != 0) { if(rv != 0) {
delete handler; delete handler;
@ -58,7 +58,7 @@ void upstream_readcb(bufferevent *bev, void *arg)
namespace { namespace {
void upstream_writecb(bufferevent *bev, void *arg) void upstream_writecb(bufferevent *bev, void *arg)
{ {
auto handler = reinterpret_cast<ClientHandler*>(arg); auto handler = static_cast<ClientHandler*>(arg);
// We actually depend on write low-warter mark == 0. // We actually depend on write low-warter mark == 0.
if(handler->get_outbuf_length() > 0) { if(handler->get_outbuf_length() > 0) {
// Possibly because of deferred callback, we may get this callback // Possibly because of deferred callback, we may get this callback
@ -80,7 +80,7 @@ void upstream_writecb(bufferevent *bev, void *arg)
namespace { namespace {
void upstream_eventcb(bufferevent *bev, short events, void *arg) void upstream_eventcb(bufferevent *bev, short events, void *arg)
{ {
auto handler = reinterpret_cast<ClientHandler*>(arg); auto handler = static_cast<ClientHandler*>(arg);
bool finish = false; bool finish = false;
if(events & BEV_EVENT_EOF) { if(events & BEV_EVENT_EOF) {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
@ -136,7 +136,7 @@ void upstream_http2_connhd_readcb(bufferevent *bev, void *arg)
{ {
// This callback assumes upstream is Http2Upstream. // This callback assumes upstream is Http2Upstream.
uint8_t data[NGHTTP2_CLIENT_CONNECTION_HEADER_LEN]; uint8_t data[NGHTTP2_CLIENT_CONNECTION_HEADER_LEN];
auto handler = reinterpret_cast<ClientHandler*>(arg); auto handler = static_cast<ClientHandler*>(arg);
auto leftlen = handler->get_left_connhd_len(); auto leftlen = handler->get_left_connhd_len();
auto input = bufferevent_get_input(bev); auto input = bufferevent_get_input(bev);
auto readlen = evbuffer_remove(input, data, leftlen); auto readlen = evbuffer_remove(input, data, leftlen);
@ -173,7 +173,7 @@ void upstream_http1_connhd_readcb(bufferevent *bev, void *arg)
{ {
// This callback assumes upstream is HttpsUpstream. // This callback assumes upstream is HttpsUpstream.
uint8_t data[NGHTTP2_CLIENT_CONNECTION_HEADER_LEN]; uint8_t data[NGHTTP2_CLIENT_CONNECTION_HEADER_LEN];
auto handler = reinterpret_cast<ClientHandler*>(arg); auto handler = static_cast<ClientHandler*>(arg);
auto leftlen = handler->get_left_connhd_len(); auto leftlen = handler->get_left_connhd_len();
auto input = bufferevent_get_input(bev); auto input = bufferevent_get_input(bev);
auto readlen = evbuffer_copyout(input, data, leftlen); auto readlen = evbuffer_copyout(input, data, leftlen);

View File

@ -158,12 +158,12 @@ ssize_t http2_data_read_callback(nghttp2_session *session,
nghttp2_data_source *source, nghttp2_data_source *source,
void *user_data) void *user_data)
{ {
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, stream_id)); (nghttp2_session_get_stream_user_data(session, stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
return NGHTTP2_ERR_DEFERRED; return NGHTTP2_ERR_DEFERRED;
} }
auto dconn = reinterpret_cast<Http2DownstreamConnection*>(source->ptr); auto dconn = static_cast<Http2DownstreamConnection*>(source->ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
if(!downstream) { if(!downstream) {
// In this case, RST_STREAM should have been issued. But depending // In this case, RST_STREAM should have been issued. But depending

View File

@ -148,7 +148,7 @@ namespace {
void notify_readcb(bufferevent *bev, void *arg) void notify_readcb(bufferevent *bev, void *arg)
{ {
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(arg); auto http2session = static_cast<Http2Session*>(arg);
http2session->clear_notify(); http2session->clear_notify();
switch(http2session->get_state()) { switch(http2session->get_state()) {
case Http2Session::DISCONNECTED: case Http2Session::DISCONNECTED:
@ -172,7 +172,7 @@ void notify_readcb(bufferevent *bev, void *arg)
namespace { namespace {
void notify_eventcb(bufferevent *bev, short events, void *arg) void notify_eventcb(bufferevent *bev, short events, void *arg)
{ {
auto http2session = reinterpret_cast<Http2Session*>(arg); auto http2session = static_cast<Http2Session*>(arg);
// TODO should DIE()? // TODO should DIE()?
if(events & BEV_EVENT_EOF) { if(events & BEV_EVENT_EOF) {
SSLOG(ERROR, http2session) << "Notification connection lost: EOF"; SSLOG(ERROR, http2session) << "Notification connection lost: EOF";
@ -222,7 +222,7 @@ namespace {
void readcb(bufferevent *bev, void *ptr) void readcb(bufferevent *bev, void *ptr)
{ {
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(ptr); auto http2session = static_cast<Http2Session*>(ptr);
rv = http2session->on_read(); rv = http2session->on_read();
if(rv != 0) { if(rv != 0) {
http2session->disconnect(); http2session->disconnect();
@ -237,7 +237,7 @@ void writecb(bufferevent *bev, void *ptr)
return; return;
} }
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(ptr); auto http2session = static_cast<Http2Session*>(ptr);
rv = http2session->on_write(); rv = http2session->on_write();
if(rv != 0) { if(rv != 0) {
http2session->disconnect(); http2session->disconnect();
@ -248,7 +248,7 @@ void writecb(bufferevent *bev, void *ptr)
namespace { namespace {
void eventcb(bufferevent *bev, short events, void *ptr) void eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto http2session = reinterpret_cast<Http2Session*>(ptr); auto http2session = static_cast<Http2Session*>(ptr);
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) << "Connection established"; SSLOG(INFO, http2session) << "Connection established";
@ -288,7 +288,7 @@ void eventcb(bufferevent *bev, short events, void *ptr)
namespace { namespace {
void proxy_readcb(bufferevent *bev, void *ptr) void proxy_readcb(bufferevent *bev, void *ptr)
{ {
auto http2session = reinterpret_cast<Http2Session*>(ptr); auto http2session = static_cast<Http2Session*>(ptr);
if(http2session->on_read_proxy() == 0) { if(http2session->on_read_proxy() == 0) {
switch(http2session->get_state()) { switch(http2session->get_state()) {
case Http2Session::PROXY_CONNECTED: case Http2Session::PROXY_CONNECTED:
@ -313,7 +313,7 @@ void proxy_readcb(bufferevent *bev, void *ptr)
namespace { namespace {
void proxy_eventcb(bufferevent *bev, short events, void *ptr) void proxy_eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto http2session = reinterpret_cast<Http2Session*>(ptr); auto http2session = static_cast<Http2Session*>(ptr);
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) << "Connected to the proxy"; SSLOG(INFO, http2session) << "Connected to the proxy";
@ -498,7 +498,7 @@ void Http2Session::unwrap_free_bev()
namespace { namespace {
int htp_hdrs_completecb(http_parser *htp) int htp_hdrs_completecb(http_parser *htp)
{ {
auto http2session = reinterpret_cast<Http2Session*>(htp->data); auto http2session = static_cast<Http2Session*>(htp->data);
// We just check status code here // We just check status code here
if(htp->status_code == 200) { if(htp->status_code == 200) {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
@ -693,7 +693,7 @@ ssize_t send_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
auto bev = http2session->get_bev(); auto bev = http2session->get_bev();
auto output = bufferevent_get_output(bev); auto output = bufferevent_get_output(bev);
// Check buffer length and return WOULDBLOCK if it is large enough. // Check buffer length and return WOULDBLOCK if it is large enough.
@ -717,12 +717,12 @@ int on_stream_close_callback
void *user_data) void *user_data)
{ {
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) << "Stream stream_id=" << stream_id SSLOG(INFO, http2session) << "Stream stream_id=" << stream_id
<< " is being closed"; << " is being closed";
} }
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, stream_id)); (nghttp2_session_get_stream_user_data(session, stream_id));
if(sd == 0) { if(sd == 0) {
// We might get this close callback when pushed streams are // We might get this close callback when pushed streams are
@ -756,7 +756,7 @@ int on_stream_close_callback
namespace { namespace {
void settings_timeout_cb(evutil_socket_t fd, short what, void *arg) void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{ {
auto http2session = reinterpret_cast<Http2Session*>(arg); auto http2session = static_cast<Http2Session*>(arg);
SSLOG(INFO, http2session) << "SETTINGS timeout"; SSLOG(INFO, http2session) << "SETTINGS timeout";
if(http2session->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) { if(http2session->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
http2session->disconnect(); http2session->disconnect();
@ -808,7 +808,7 @@ int on_header_callback(nghttp2_session *session,
frame->headers.cat != NGHTTP2_HCAT_RESPONSE) { frame->headers.cat != NGHTTP2_HCAT_RESPONSE) {
return 0; return 0;
} }
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
return 0; return 0;
@ -839,8 +839,8 @@ int on_end_headers_callback(nghttp2_session *session,
return 0; return 0;
} }
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
return 0; return 0;
@ -943,7 +943,7 @@ namespace {
int on_frame_recv_callback int on_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
switch(frame->hd.type) { switch(frame->hd.type) {
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) { if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
@ -955,7 +955,7 @@ int on_frame_recv_callback
if(frame->headers.cat != NGHTTP2_HCAT_RESPONSE) { if(frame->headers.cat != NGHTTP2_HCAT_RESPONSE) {
break; break;
} }
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
http2session->submit_rst_stream(frame->hd.stream_id, http2session->submit_rst_stream(frame->hd.stream_id,
@ -972,7 +972,7 @@ int on_frame_recv_callback
break; break;
} }
case NGHTTP2_RST_STREAM: { case NGHTTP2_RST_STREAM: {
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(sd && sd->dconn) { if(sd && sd->dconn) {
auto downstream = sd->dconn->get_downstream(); auto downstream = sd->dconn->get_downstream();
@ -1032,8 +1032,8 @@ int on_data_chunk_recv_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
int rv; int rv;
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, stream_id)); (nghttp2_session_get_stream_user_data(session, stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
http2session->submit_rst_stream(stream_id, NGHTTP2_INTERNAL_ERROR); http2session->submit_rst_stream(stream_id, NGHTTP2_INTERNAL_ERROR);
@ -1061,10 +1061,10 @@ int before_frame_send_callback(nghttp2_session *session,
const nghttp2_frame *frame, const nghttp2_frame *frame,
void *user_data) void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
if(frame->hd.type == NGHTTP2_HEADERS && if(frame->hd.type == NGHTTP2_HEADERS &&
frame->headers.cat == NGHTTP2_HCAT_REQUEST) { frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!sd || !sd->dconn) { if(!sd || !sd->dconn) {
http2session->submit_rst_stream(frame->hd.stream_id, NGHTTP2_CANCEL); http2session->submit_rst_stream(frame->hd.stream_id, NGHTTP2_CANCEL);
@ -1085,7 +1085,7 @@ namespace {
int on_frame_send_callback(nghttp2_session* session, int on_frame_send_callback(nghttp2_session* session,
const nghttp2_frame *frame, void *user_data) const nghttp2_frame *frame, void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
if(frame->hd.type == NGHTTP2_SETTINGS && if(frame->hd.type == NGHTTP2_SETTINGS &&
(frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) { (frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) {
if(http2session->start_settings_timer() != 0) { if(http2session->start_settings_timer() != 0) {
@ -1101,7 +1101,7 @@ int on_frame_not_send_callback(nghttp2_session *session,
const nghttp2_frame *frame, const nghttp2_frame *frame,
int lib_error_code, void *user_data) int lib_error_code, void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
SSLOG(WARNING, http2session) << "Failed to send control frame type=" SSLOG(WARNING, http2session) << "Failed to send control frame type="
<< frame->hd.type << ", " << frame->hd.type << ", "
<< "lib_error_code=" << lib_error_code << ":" << "lib_error_code=" << lib_error_code << ":"
@ -1110,7 +1110,7 @@ int on_frame_not_send_callback(nghttp2_session *session,
frame->headers.cat == NGHTTP2_HCAT_REQUEST) { frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
// To avoid stream hanging around, flag Downstream::MSG_RESET and // To avoid stream hanging around, flag Downstream::MSG_RESET and
// terminate the upstream and downstream connections. // terminate the upstream and downstream connections.
auto sd = reinterpret_cast<StreamData*> auto sd = static_cast<StreamData*>
(nghttp2_session_get_stream_user_data(session, frame->hd.stream_id)); (nghttp2_session_get_stream_user_data(session, frame->hd.stream_id));
if(!sd) { if(!sd) {
return 0; return 0;
@ -1138,7 +1138,7 @@ int on_frame_recv_parse_error_callback(nghttp2_session *session,
size_t payloadlen, int lib_error_code, size_t payloadlen, int lib_error_code,
void *user_data) void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) SSLOG(INFO, http2session)
<< "Failed to parse received control frame. type=" << "Failed to parse received control frame. type="
@ -1156,7 +1156,7 @@ int on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *payload, size_t payloadlen, const uint8_t *payload, size_t payloadlen,
void *user_data) void *user_data)
{ {
auto http2session = reinterpret_cast<Http2Session*>(user_data); auto http2session = static_cast<Http2Session*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
SSLOG(INFO, http2session) << "Received unknown control frame"; SSLOG(INFO, http2session) << "Received unknown control frame";
} }

View File

@ -54,7 +54,7 @@ ssize_t send_callback(nghttp2_session *session,
void *user_data) void *user_data)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
auto handler = upstream->get_client_handler(); auto handler = upstream->get_client_handler();
auto bev = handler->get_bev(); auto bev = handler->get_bev();
auto output = bufferevent_get_output(bev); auto output = bufferevent_get_output(bev);
@ -78,7 +78,7 @@ int on_stream_close_callback
(nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code, (nghttp2_session *session, int32_t stream_id, nghttp2_error_code error_code,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Stream stream_id=" << stream_id ULOG(INFO, upstream) << "Stream stream_id=" << stream_id
<< " is being closed"; << " is being closed";
@ -156,7 +156,7 @@ int Http2Upstream::upgrade_upstream(HttpsUpstream *http)
namespace { namespace {
void settings_timeout_cb(evutil_socket_t fd, short what, void *arg) void settings_timeout_cb(evutil_socket_t fd, short what, void *arg)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(arg); auto upstream = static_cast<Http2Upstream*>(arg);
ULOG(INFO, upstream) << "SETTINGS timeout"; ULOG(INFO, upstream) << "SETTINGS timeout";
if(upstream->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) { if(upstream->terminate_session(NGHTTP2_SETTINGS_TIMEOUT) != 0) {
delete upstream->get_client_handler(); delete upstream->get_client_handler();
@ -209,7 +209,7 @@ int on_header_callback(nghttp2_session *session,
frame->headers.cat != NGHTTP2_HCAT_REQUEST) { frame->headers.cat != NGHTTP2_HCAT_REQUEST) {
return 0; return 0;
} }
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
auto downstream = upstream->find_downstream(frame->hd.stream_id); auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) { if(!downstream) {
return 0; return 0;
@ -236,7 +236,7 @@ int on_end_headers_callback(nghttp2_session *session,
return 0; return 0;
} }
int rv; int rv;
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
auto downstream = upstream->find_downstream(frame->hd.stream_id); auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) { if(!downstream) {
return 0; return 0;
@ -337,7 +337,7 @@ int on_frame_recv_callback
(nghttp2_session *session, const nghttp2_frame *frame, void *user_data) (nghttp2_session *session, const nghttp2_frame *frame, void *user_data)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
switch(frame->hd.type) { switch(frame->hd.type) {
case NGHTTP2_HEADERS: { case NGHTTP2_HEADERS: {
if(frame->headers.cat != NGHTTP2_HCAT_REQUEST) { if(frame->headers.cat != NGHTTP2_HCAT_REQUEST) {
@ -392,7 +392,7 @@ int on_data_chunk_recv_callback(nghttp2_session *session,
const uint8_t *data, size_t len, const uint8_t *data, size_t len,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
auto downstream = upstream->find_downstream(stream_id); auto downstream = upstream->find_downstream(stream_id);
if(downstream) { if(downstream) {
if(downstream->push_upload_data_chunk(data, len) != 0) { if(downstream->push_upload_data_chunk(data, len) != 0) {
@ -409,7 +409,7 @@ int on_data_recv_callback(nghttp2_session *session,
uint16_t length, uint8_t flags, int32_t stream_id, uint16_t length, uint8_t flags, int32_t stream_id,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
auto downstream = upstream->find_downstream(stream_id); auto downstream = upstream->find_downstream(stream_id);
if(downstream && (flags & NGHTTP2_FLAG_END_STREAM)) { if(downstream && (flags & NGHTTP2_FLAG_END_STREAM)) {
downstream->end_upload_data(); downstream->end_upload_data();
@ -423,7 +423,7 @@ namespace {
int on_frame_send_callback(nghttp2_session* session, int on_frame_send_callback(nghttp2_session* session,
const nghttp2_frame *frame, void *user_data) const nghttp2_frame *frame, void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
if(frame->hd.type == NGHTTP2_SETTINGS && if(frame->hd.type == NGHTTP2_SETTINGS &&
(frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) { (frame->hd.flags & NGHTTP2_FLAG_ACK) == 0) {
if(upstream->start_settings_timer() != 0) { if(upstream->start_settings_timer() != 0) {
@ -439,7 +439,7 @@ int on_frame_not_send_callback(nghttp2_session *session,
const nghttp2_frame *frame, const nghttp2_frame *frame,
int lib_error_code, void *user_data) int lib_error_code, void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
ULOG(WARNING, upstream) << "Failed to send control frame type=" ULOG(WARNING, upstream) << "Failed to send control frame type="
<< static_cast<uint32_t>(frame->hd.type) << static_cast<uint32_t>(frame->hd.type)
<< ", lib_error_code=" << lib_error_code << ":" << ", lib_error_code=" << lib_error_code << ":"
@ -464,7 +464,7 @@ int on_frame_recv_parse_error_callback(nghttp2_session *session,
size_t payloadlen, int lib_error_code, size_t payloadlen, int lib_error_code,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Failed to parse received control frame. type=" ULOG(INFO, upstream) << "Failed to parse received control frame. type="
<< type << type
@ -481,7 +481,7 @@ int on_unknown_frame_recv_callback(nghttp2_session *session,
const uint8_t *payload, size_t payloadlen, const uint8_t *payload, size_t payloadlen,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<Http2Upstream*>(user_data); auto upstream = static_cast<Http2Upstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Received unknown control frame."; ULOG(INFO, upstream) << "Received unknown control frame.";
} }
@ -642,7 +642,7 @@ ClientHandler* Http2Upstream::get_client_handler() const
namespace { namespace {
void downstream_readcb(bufferevent *bev, void *ptr) void downstream_readcb(bufferevent *bev, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream()); auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream());
if(downstream->get_request_state() == Downstream::STREAM_CLOSED) { if(downstream->get_request_state() == Downstream::STREAM_CLOSED) {
@ -701,7 +701,7 @@ void downstream_writecb(bufferevent *bev, void *ptr)
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) { if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return; return;
} }
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream()); auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream());
upstream->resume_read(SHRPX_NO_BUFFER, downstream); upstream->resume_read(SHRPX_NO_BUFFER, downstream);
@ -711,7 +711,7 @@ void downstream_writecb(bufferevent *bev, void *ptr)
namespace { namespace {
void downstream_eventcb(bufferevent *bev, short events, void *ptr) void downstream_eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream()); auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream());
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
@ -879,8 +879,8 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
nghttp2_data_source *source, nghttp2_data_source *source,
void *user_data) void *user_data)
{ {
auto downstream = reinterpret_cast<Downstream*>(source->ptr); auto downstream = static_cast<Downstream*>(source->ptr);
auto upstream = reinterpret_cast<Http2Upstream*>(downstream->get_upstream()); auto upstream = static_cast<Http2Upstream*>(downstream->get_upstream());
auto handler = upstream->get_client_handler(); auto handler = upstream->get_client_handler();
auto body = downstream->get_response_body_buf(); auto body = downstream->get_response_body_buf();
assert(body); assert(body);

View File

@ -305,7 +305,7 @@ namespace {
// Gets called when DownstreamConnection is pooled in ClientHandler. // Gets called when DownstreamConnection is pooled in ClientHandler.
void idle_eventcb(bufferevent *bev, short events, void *arg) void idle_eventcb(bufferevent *bev, short events, void *arg)
{ {
auto dconn = reinterpret_cast<HttpDownstreamConnection*>(arg); auto dconn = static_cast<HttpDownstreamConnection*>(arg);
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
// Downstream was detached before connection established? // Downstream was detached before connection established?
// This may be safe to be left. // This may be safe to be left.
@ -381,7 +381,7 @@ bool HttpDownstreamConnection::get_output_buffer_full()
namespace { namespace {
int htp_hdrs_completecb(http_parser *htp) int htp_hdrs_completecb(http_parser *htp)
{ {
auto downstream = reinterpret_cast<Downstream*>(htp->data); auto downstream = static_cast<Downstream*>(htp->data);
downstream->set_response_http_status(htp->status_code); downstream->set_response_http_status(htp->status_code);
downstream->set_response_major(htp->http_major); downstream->set_response_major(htp->http_major);
downstream->set_response_minor(htp->http_minor); downstream->set_response_minor(htp->http_minor);
@ -425,7 +425,7 @@ int htp_hdrs_completecb(http_parser *htp)
namespace { namespace {
int htp_hdr_keycb(http_parser *htp, const char *data, size_t len) int htp_hdr_keycb(http_parser *htp, const char *data, size_t len)
{ {
auto downstream = reinterpret_cast<Downstream*>(htp->data); auto downstream = static_cast<Downstream*>(htp->data);
if(downstream->get_response_header_key_prev()) { if(downstream->get_response_header_key_prev()) {
downstream->append_last_response_header_key(data, len); downstream->append_last_response_header_key(data, len);
} else { } else {
@ -438,7 +438,7 @@ int htp_hdr_keycb(http_parser *htp, const char *data, size_t len)
namespace { namespace {
int htp_hdr_valcb(http_parser *htp, const char *data, size_t len) int htp_hdr_valcb(http_parser *htp, const char *data, size_t len)
{ {
auto downstream = reinterpret_cast<Downstream*>(htp->data); auto downstream = static_cast<Downstream*>(htp->data);
if(downstream->get_response_header_key_prev()) { if(downstream->get_response_header_key_prev()) {
downstream->set_last_response_header_value(std::string(data, len)); downstream->set_last_response_header_value(std::string(data, len));
} else { } else {
@ -451,7 +451,7 @@ int htp_hdr_valcb(http_parser *htp, const char *data, size_t len)
namespace { namespace {
int htp_bodycb(http_parser *htp, const char *data, size_t len) int htp_bodycb(http_parser *htp, const char *data, size_t len)
{ {
auto downstream = reinterpret_cast<Downstream*>(htp->data); auto downstream = static_cast<Downstream*>(htp->data);
return downstream->get_upstream()->on_downstream_body return downstream->get_upstream()->on_downstream_body
(downstream, reinterpret_cast<const uint8_t*>(data), len); (downstream, reinterpret_cast<const uint8_t*>(data), len);
} }
@ -460,7 +460,7 @@ int htp_bodycb(http_parser *htp, const char *data, size_t len)
namespace { namespace {
int htp_msg_completecb(http_parser *htp) int htp_msg_completecb(http_parser *htp)
{ {
auto downstream = reinterpret_cast<Downstream*>(htp->data); auto downstream = static_cast<Downstream*>(htp->data);
downstream->set_response_state(Downstream::MSG_COMPLETE); downstream->set_response_state(Downstream::MSG_COMPLETE);
// Block reading another response message from (broken?) // Block reading another response message from (broken?)
// server. This callback is not called if the connection is // server. This callback is not called if the connection is

View File

@ -71,7 +71,7 @@ void HttpsUpstream::reset_current_header_length()
namespace { namespace {
int htp_msg_begin(http_parser *htp) int htp_msg_begin(http_parser *htp)
{ {
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "HTTP request started"; ULOG(INFO, upstream) << "HTTP request started";
} }
@ -85,7 +85,7 @@ int htp_msg_begin(http_parser *htp)
namespace { namespace {
int htp_uricb(http_parser *htp, const char *data, size_t len) int htp_uricb(http_parser *htp, const char *data, size_t len)
{ {
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
auto downstream = upstream->get_downstream(); auto downstream = upstream->get_downstream();
downstream->append_request_path(data, len); downstream->append_request_path(data, len);
return 0; return 0;
@ -95,7 +95,7 @@ int htp_uricb(http_parser *htp, const char *data, size_t len)
namespace { namespace {
int htp_hdr_keycb(http_parser *htp, const char *data, size_t len) int htp_hdr_keycb(http_parser *htp, const char *data, size_t len)
{ {
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
auto downstream = upstream->get_downstream(); auto downstream = upstream->get_downstream();
if(downstream->get_request_header_key_prev()) { if(downstream->get_request_header_key_prev()) {
downstream->append_last_request_header_key(data, len); downstream->append_last_request_header_key(data, len);
@ -109,7 +109,7 @@ int htp_hdr_keycb(http_parser *htp, const char *data, size_t len)
namespace { namespace {
int htp_hdr_valcb(http_parser *htp, const char *data, size_t len) int htp_hdr_valcb(http_parser *htp, const char *data, size_t len)
{ {
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
auto downstream = upstream->get_downstream(); auto downstream = upstream->get_downstream();
if(downstream->get_request_header_key_prev()) { if(downstream->get_request_header_key_prev()) {
downstream->set_last_request_header_value(std::string(data, len)); downstream->set_last_request_header_value(std::string(data, len));
@ -124,7 +124,7 @@ namespace {
int htp_hdrs_completecb(http_parser *htp) int htp_hdrs_completecb(http_parser *htp)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "HTTP request headers completed"; ULOG(INFO, upstream) << "HTTP request headers completed";
} }
@ -199,7 +199,7 @@ namespace {
int htp_bodycb(http_parser *htp, const char *data, size_t len) int htp_bodycb(http_parser *htp, const char *data, size_t len)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
auto downstream = upstream->get_downstream(); auto downstream = upstream->get_downstream();
rv = downstream->push_upload_data_chunk rv = downstream->push_upload_data_chunk
(reinterpret_cast<const uint8_t*>(data), len); (reinterpret_cast<const uint8_t*>(data), len);
@ -214,7 +214,7 @@ namespace {
int htp_msg_completecb(http_parser *htp) int htp_msg_completecb(http_parser *htp)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<HttpsUpstream*>(htp->data); auto upstream = static_cast<HttpsUpstream*>(htp->data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "HTTP request completed"; ULOG(INFO, upstream) << "HTTP request completed";
} }
@ -393,7 +393,7 @@ int HttpsUpstream::resume_read(IOCtrlReason reason, Downstream *downstream)
namespace { namespace {
void https_downstream_readcb(bufferevent *bev, void *ptr) void https_downstream_readcb(bufferevent *bev, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream()); auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream());
int rv; int rv;
@ -481,7 +481,7 @@ void https_downstream_writecb(bufferevent *bev, void *ptr)
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) { if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return; return;
} }
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream()); auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream());
// May return -1 // May return -1
@ -492,7 +492,7 @@ void https_downstream_writecb(bufferevent *bev, void *ptr)
namespace { namespace {
void https_downstream_eventcb(bufferevent *bev, short events, void *ptr) void https_downstream_eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream()); auto upstream = static_cast<HttpsUpstream*>(downstream->get_upstream());
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {

View File

@ -54,7 +54,7 @@ ssize_t send_callback(spdylay_session *session,
void *user_data) void *user_data)
{ {
int rv; int rv;
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
auto handler = upstream->get_client_handler(); auto handler = upstream->get_client_handler();
auto bev = handler->get_bev(); auto bev = handler->get_bev();
auto output = bufferevent_get_output(bev); auto output = bufferevent_get_output(bev);
@ -77,7 +77,7 @@ namespace {
ssize_t recv_callback(spdylay_session *session, ssize_t recv_callback(spdylay_session *session,
uint8_t *data, size_t len, int flags, void *user_data) uint8_t *data, size_t len, int flags, void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
auto handler = upstream->get_client_handler(); auto handler = upstream->get_client_handler();
auto bev = handler->get_bev(); auto bev = handler->get_bev();
auto input = bufferevent_get_input(bev); auto input = bufferevent_get_input(bev);
@ -97,7 +97,7 @@ void on_stream_close_callback
(spdylay_session *session, int32_t stream_id, spdylay_status_code status_code, (spdylay_session *session, int32_t stream_id, spdylay_status_code status_code,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Stream stream_id=" << stream_id ULOG(INFO, upstream) << "Stream stream_id=" << stream_id
<< " is being closed"; << " is being closed";
@ -142,7 +142,7 @@ void on_ctrl_recv_callback
(spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame, (spdylay_session *session, spdylay_frame_type type, spdylay_frame *frame,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
switch(type) { switch(type) {
case SPDYLAY_SYN_STREAM: { case SPDYLAY_SYN_STREAM: {
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
@ -243,7 +243,7 @@ void on_data_chunk_recv_callback(spdylay_session *session,
const uint8_t *data, size_t len, const uint8_t *data, size_t len,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
auto downstream = upstream->find_downstream(stream_id); auto downstream = upstream->find_downstream(stream_id);
if(downstream) { if(downstream) {
if(downstream->push_upload_data_chunk(data, len) != 0) { if(downstream->push_upload_data_chunk(data, len) != 0) {
@ -290,7 +290,7 @@ namespace {
void on_data_recv_callback(spdylay_session *session, uint8_t flags, void on_data_recv_callback(spdylay_session *session, uint8_t flags,
int32_t stream_id, int32_t length, void *user_data) int32_t stream_id, int32_t length, void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
auto downstream = upstream->find_downstream(stream_id); auto downstream = upstream->find_downstream(stream_id);
if(downstream && (flags & SPDYLAY_DATA_FLAG_FIN)) { if(downstream && (flags & SPDYLAY_DATA_FLAG_FIN)) {
downstream->end_upload_data(); downstream->end_upload_data();
@ -305,7 +305,7 @@ void on_ctrl_not_send_callback(spdylay_session *session,
spdylay_frame *frame, spdylay_frame *frame,
int error_code, void *user_data) int error_code, void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
ULOG(WARNING, upstream) << "Failed to send control frame type=" << type ULOG(WARNING, upstream) << "Failed to send control frame type=" << type
<< ", error_code=" << error_code << ":" << ", error_code=" << error_code << ":"
<< spdylay_strerror(error_code); << spdylay_strerror(error_code);
@ -328,7 +328,7 @@ void on_ctrl_recv_parse_error_callback(spdylay_session *session,
size_t payloadlen, int error_code, size_t payloadlen, int error_code,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Failed to parse received control frame. type=" ULOG(INFO, upstream) << "Failed to parse received control frame. type="
<< type << type
@ -344,7 +344,7 @@ void on_unknown_ctrl_recv_callback(spdylay_session *session,
const uint8_t *payload, size_t payloadlen, const uint8_t *payload, size_t payloadlen,
void *user_data) void *user_data)
{ {
auto upstream = reinterpret_cast<SpdyUpstream*>(user_data); auto upstream = static_cast<SpdyUpstream*>(user_data);
if(LOG_ENABLED(INFO)) { if(LOG_ENABLED(INFO)) {
ULOG(INFO, upstream) << "Received unknown control frame."; ULOG(INFO, upstream) << "Received unknown control frame.";
} }
@ -500,7 +500,7 @@ ClientHandler* SpdyUpstream::get_client_handler() const
namespace { namespace {
void spdy_downstream_readcb(bufferevent *bev, void *ptr) void spdy_downstream_readcb(bufferevent *bev, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream()); auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream());
if(downstream->get_request_state() == Downstream::STREAM_CLOSED) { if(downstream->get_request_state() == Downstream::STREAM_CLOSED) {
@ -559,7 +559,7 @@ void spdy_downstream_writecb(bufferevent *bev, void *ptr)
if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) { if(evbuffer_get_length(bufferevent_get_output(bev)) > 0) {
return; return;
} }
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream()); auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream());
upstream->resume_read(SHRPX_NO_BUFFER, downstream); upstream->resume_read(SHRPX_NO_BUFFER, downstream);
@ -569,7 +569,7 @@ void spdy_downstream_writecb(bufferevent *bev, void *ptr)
namespace { namespace {
void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr) void spdy_downstream_eventcb(bufferevent *bev, short events, void *ptr)
{ {
auto dconn = reinterpret_cast<DownstreamConnection*>(ptr); auto dconn = static_cast<DownstreamConnection*>(ptr);
auto downstream = dconn->get_downstream(); auto downstream = dconn->get_downstream();
auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream()); auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream());
if(events & BEV_EVENT_CONNECTED) { if(events & BEV_EVENT_CONNECTED) {
@ -723,8 +723,8 @@ ssize_t spdy_data_read_callback(spdylay_session *session,
spdylay_data_source *source, spdylay_data_source *source,
void *user_data) void *user_data)
{ {
auto downstream = reinterpret_cast<Downstream*>(source->ptr); auto downstream = static_cast<Downstream*>(source->ptr);
auto upstream = reinterpret_cast<SpdyUpstream*>(downstream->get_upstream()); auto upstream = static_cast<SpdyUpstream*>(downstream->get_upstream());
auto handler = upstream->get_client_handler(); auto handler = upstream->get_client_handler();
auto body = downstream->get_response_body_buf(); auto body = downstream->get_response_body_buf();
assert(body); assert(body);

View File

@ -62,8 +62,7 @@ namespace {
int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len, int next_proto_cb(SSL *s, const unsigned char **data, unsigned int *len,
void *arg) void *arg)
{ {
auto next_proto = auto next_proto = static_cast<std::pair<unsigned char*, size_t>*>(arg);
reinterpret_cast<std::pair<unsigned char*, size_t>*>(arg);
*data = next_proto->first; *data = next_proto->first;
*len = next_proto->second; *len = next_proto->second;
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
@ -103,7 +102,7 @@ size_t set_npn_prefs(unsigned char *out, char **protos, size_t len)
namespace { namespace {
int ssl_pem_passwd_cb(char *buf, int size, int rwflag, void *user_data) int ssl_pem_passwd_cb(char *buf, int size, int rwflag, void *user_data)
{ {
auto config = reinterpret_cast<Config*>(user_data); auto config = static_cast<Config*>(user_data);
int len = (int)strlen(config->private_key_passwd); int len = (int)strlen(config->private_key_passwd);
if (size < len + 1) { if (size < len + 1) {
LOG(ERROR) << "ssl_pem_passwd_cb: buf is too small " << size; LOG(ERROR) << "ssl_pem_passwd_cb: buf is too small " << size;
@ -579,8 +578,8 @@ void get_altnames(X509 *cert,
std::vector<std::string>& ip_addrs, std::vector<std::string>& ip_addrs,
std::string& common_name) std::string& common_name)
{ {
GENERAL_NAMES* altnames; GENERAL_NAMES *altnames =
altnames = reinterpret_cast<GENERAL_NAMES*> static_cast<GENERAL_NAMES*>
(X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr)); (X509_get_ext_d2i(cert, NID_subject_alt_name, nullptr, nullptr));
if(altnames) { if(altnames) {
util::auto_delete<GENERAL_NAMES*> altnames_deleter(altnames, util::auto_delete<GENERAL_NAMES*> altnames_deleter(altnames,

View File

@ -57,7 +57,7 @@ Worker::~Worker()
namespace { namespace {
void readcb(bufferevent *bev, void *arg) void readcb(bufferevent *bev, void *arg)
{ {
auto receiver = reinterpret_cast<ThreadEventReceiver*>(arg); auto receiver = static_cast<ThreadEventReceiver*>(arg);
receiver->on_read(bev); receiver->on_read(bev);
} }
} // namespace } // namespace