Commit 1cbb5a3d authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Update tutorial

parent 65137119
......@@ -249,17 +249,18 @@ data is available to read in the bufferevent input buffer::
static void readcb(struct bufferevent *bev, void *ptr)
{
http2_session_data *session_data = (http2_session_data*)ptr;
int rv;
ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(bev);
size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) {
warnx("Fatal error: %s", nghttp2_strerror(rv));
readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
delete_http2_session_data(session_data);
return;
}
evbuffer_drain(input, rv);
evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) {
delete_http2_session_data(session_data);
return;
......
......@@ -34,11 +34,10 @@ life time::
void *arg)
{
*data = next_proto_list;
*len = next_proto_list_len;
*len = (unsigned int)next_proto_list_len;
return SSL_TLSEXT_ERR_OK;
}
static SSL_CTX* create_ssl_ctx(const char *key_file, const char *cert_file)
{
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)
{
int rv;
ssize_t readlen;
struct evbuffer *input = bufferevent_get_input(session_data->bev);
size_t datalen = evbuffer_get_length(input);
unsigned char *data = evbuffer_pullup(input, -1);
rv = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(rv < 0) {
warnx("Fatal error: %s", nghttp2_strerror(rv));
readlen = nghttp2_session_mem_recv(session_data->session, data, datalen);
if(readlen < 0) {
warnx("Fatal error: %s", nghttp2_strerror((int)readlen));
return -1;
}
evbuffer_drain(input, rv);
evbuffer_drain(input, readlen);
if(session_send(session_data) != 0) {
return -1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment