Update tutorial

This commit is contained in:
Tatsuhiro Tsujikawa 2014-06-14 22:47:56 +09:00
parent 6513711943
commit 1cbb5a3d8f
2 changed files with 13 additions and 12 deletions

View File

@ -249,17 +249,18 @@ data is available to read in the bufferevent input buffer::
static void readcb(struct bufferevent *bev, void *ptr) static void readcb(struct bufferevent *bev, void *ptr)
{ {
http2_session_data *session_data = (http2_session_data*)ptr; http2_session_data *session_data = (http2_session_data*)ptr;
int rv; ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(bev); struct evbuffer *input = bufferevent_get_input(bev);
size_t datalen = evbuffer_get_length(input); size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1); unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) { readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
warnx("Fatal error: %s", nghttp2_strerror(rv)); if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
delete_http2_session_data(session_data); delete_http2_session_data(session_data);
return; return;
} }
evbuffer_drain(input, rv); evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) { if(session_send(session_data) != 0) {
delete_http2_session_data(session_data); delete_http2_session_data(session_data);
return; return;

View File

@ -34,11 +34,10 @@ life time::
void *arg) void *arg)
{ {
*data = next_proto_list; *data = next_proto_list;
*len = next_proto_list_len; *len = (unsigned int)next_proto_list_len;
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
static SSL_CTX* create_ssl_ctx(const char *key_file, const char *cert_file) static SSL_CTX* create_ssl_ctx(const char *key_file, const char *cert_file)
{ {
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
@ -287,16 +286,17 @@ functions for these pending data. To process received data, we call
static int session_recv(http2_session_data *session_data) static int session_recv(http2_session_data *session_data)
{ {
int rv; ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(session_data->bev); struct evbuffer *input = bufferevent_get_input(session_data->bev);
size_t datalen = evbuffer_get_length(input); size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1); unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) { readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
warnx("Fatal error: %s", nghttp2_strerror(rv)); if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
return -1; return -1;
} }
evbuffer_drain(input, rv); evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) { if(session_send(session_data) != 0) {
return -1; return -1;
} }