h2_session *session = (h2_session*)ctx;
nghttp2_session_consume(session->ngh2, stream_id, bytes_read);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session(%ld-%d): consumed %ld bytes",
+ "h2_stream(%ld-%d): consumed %ld bytes",
session->id, stream_id, (long)bytes_read);
}
char buffer[256];
h2_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03063)
- "h2_session(%ld): recv invalid FRAME[%s], frames=%ld/%ld (r/s)",
- session->id, buffer, (long)session->frames_received,
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03063), session,
+ "recv invalid FRAME[%s], frames=%ld/%ld (r/s)"),
+ buffer, (long)session->frames_received,
(long)session->frames_sent);
}
return 0;
stream = get_stream(session, stream_id);
if (stream) {
if (error_code) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03065)
- H2_STREAM_MSG(stream, "closing with err=%d %s"),
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03065), stream,
+ "closing with err=%d %s"),
(int)error_code, h2_h2_err_description(error_code));
h2_stream_rst(stream, error_code);
}
(void)flags;
stream = get_stream(session, frame->hd.stream_id);
if (!stream) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
- APLOGNO(02920)
- "h2_session: stream(%ld-%d): on_header unknown stream",
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(02920)
+ "h2_stream(%ld-%d): on_header unknown stream",
session->id, (int)frame->hd.stream_id);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
char buffer[256];
h2_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03066)
- "h2_session(%ld): recv FRAME[%s], frames=%ld/%ld (r/s)",
- session->id, buffer, (long)session->frames_received,
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03066), session,
+ "recv FRAME[%s], frames=%ld/%ld (r/s)"),
+ buffer, (long)session->frames_received,
(long)session->frames_sent);
}
case NGHTTP2_DATA:
stream = get_stream(session, frame->hd.stream_id);
if (stream) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(02923)
- H2_STREAM_MSG(stream, "DATA, len=%ld, flags=%d"),
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(02923), stream,
+ "DATA, len=%ld, flags=%d"),
(long)frame->hd.length, frame->hd.flags);
h2_stream_recv_frame(stream, NGHTTP2_DATA, frame->hd.flags);
}
case NGHTTP2_PRIORITY:
session->reprioritize = 1;
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session: stream(%ld-%d): PRIORITY frame "
+ "h2_stream(%ld-%d): PRIORITY frame "
" weight=%d, dependsOn=%d, exclusive=%d",
session->id, (int)frame->hd.stream_id,
frame->priority.pri_spec.weight,
break;
case NGHTTP2_WINDOW_UPDATE:
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session: stream(%ld-%d): WINDOW_UPDATE "
- "incr=%d",
+ "h2_stream(%ld-%d): WINDOW_UPDATE incr=%d",
session->id, (int)frame->hd.stream_id,
frame->window_update.window_size_increment);
break;
case NGHTTP2_RST_STREAM:
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03067)
- "h2_session(%ld-%d): RST_STREAM by client, errror=%d",
+ "h2_stream(%ld-%d): RST_STREAM by client, errror=%d",
session->id, (int)frame->hd.stream_id,
(int)frame->rst_stream.error_code);
stream = get_stream(session, frame->hd.stream_id);
h2_util_frame_print(frame, buffer,
sizeof(buffer)/sizeof(buffer[0]));
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session: on_frame_rcv %s", buffer);
+ H2_SSSN_MSG(session, "on_frame_rcv %s"), buffer);
}
break;
}
}
padlen = (unsigned char)frame->data.padlen;
- ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_stream(%ld-%d): send_data_cb for %ld bytes",
- session->id, (int)stream_id, (long)length);
-
stream = get_stream(session, stream_id);
if (!stream) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_NOTFOUND, session->c,
APLOGNO(02924)
- "h2_stream(%ld-%d): send_data, lookup stream",
+ "h2_stream(%ld-%d): send_data, stream not found",
session->id, (int)stream_id);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
+ H2_STRM_MSG(stream, "send_data_cb for %ld bytes"),
+ (long)length);
+
status = h2_conn_io_write(&session->io, (const char *)framehd, 9);
if (padlen && status == APR_SUCCESS) {
status = h2_conn_io_write(&session->io, (const char *)&padlen, 1);
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
- H2_STREAM_MSG(stream, "writing frame header"));
+ H2_STRM_MSG(stream, "writing frame header"));
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
status = h2_stream_read_to(stream, session->bbtmp, &len, &eos);
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
- H2_STREAM_MSG(stream, "send_data_cb, reading stream"));
+ H2_STRM_MSG(stream, "send_data_cb, reading stream"));
apr_brigade_cleanup(session->bbtmp);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
else if (len != length) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, session->c,
- H2_STREAM_MSG(stream, "send_data_cb, wanted %ld bytes, "
+ H2_STRM_MSG(stream, "send_data_cb, wanted %ld bytes, "
"got %ld from stream"), (long)length, (long)len);
apr_brigade_cleanup(session->bbtmp);
return NGHTTP2_ERR_CALLBACK_FAILURE;
return 0;
}
else {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, APLOGNO(02925)
- H2_STREAM_MSG(stream, "failed send_data_cb"));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
+ H2_STRM_LOG(APLOGNO(02925), stream, "failed send_data_cb"));
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
char buffer[256];
h2_util_frame_print(frame, buffer, sizeof(buffer)/sizeof(buffer[0]));
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03068)
- "h2_session(%ld): sent FRAME[%s], frames=%ld/%ld (r/s)",
- session->id, buffer, (long)session->frames_received,
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03068), session,
+ "sent FRAME[%s], frames=%ld/%ld (r/s)"),
+ buffer, (long)session->frames_received,
(long)session->frames_sent);
}
if (APLOGcdebug(session->c)) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03456)
- "h2_session(%ld-%d): denying stream with invalid header "
- "'%s: %s'", session->id, (int)frame->hd.stream_id,
+ "h2_stream(%ld-%d): invalid header '%s: %s'",
+ session->id, (int)frame->hd.stream_id,
apr_pstrndup(session->pool, (const char *)name, namelen),
apr_pstrndup(session->pool, (const char *)value, valuelen));
}
if (status == APR_SUCCESS) {
status = h2_conn_io_flush(&session->io);
}
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03457)
- "session(%ld): sent shutdown notice", session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03457), session, "sent shutdown notice"));
return status;
}
if (status == APR_SUCCESS) {
status = h2_conn_io_flush(&session->io);
}
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03069)
- "session(%ld): sent GOAWAY, err=%d, msg=%s",
- session->id, error, msg? msg : "");
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03069), session,
+ "sent GOAWAY, err=%d, msg=%s"), error, msg? msg : "");
dispatch_event(session, H2_SESSION_EV_LOCAL_GOAWAY, error, msg);
return status;
}
{
h2_session *session = data;
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- "session(%ld): pool_cleanup", session->id);
+ H2_SSSN_MSG(session, "pool_cleanup"));
if (session->state != H2_SESSION_ST_DONE
&& session->state != H2_SESSION_ST_INIT) {
* connection when sending the next request, this has the effect
* that at least this one request will fail.
*/
- ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, session->c, APLOGNO(03199)
- "session(%ld): connection disappeared without proper "
- "goodbye, clients will be confused, should not happen",
- session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03199), session,
+ "connection disappeared without proper "
+ "goodbye, clients will be confused, should not happen"));
}
transit(session, "pool cleanup", H2_SESSION_ST_CLEANUP);
return APR_SUCCESS;
}
-static void *session_malloc(size_t size, void *ctx)
-{
- h2_session *session = ctx;
- ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
- "h2_session(%ld): malloc(%ld)",
- session->id, (long)size);
- return malloc(size);
-}
-
-static void session_free(void *p, void *ctx)
-{
- h2_session *session = ctx;
-
- ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
- "h2_session(%ld): free()",
- session->id);
- free(p);
-}
-
-static void *session_calloc(size_t n, size_t size, void *ctx)
-{
- h2_session *session = ctx;
-
- ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
- "h2_session(%ld): calloc(%ld, %ld)",
- session->id, (long)n, (long)size);
- return calloc(n, size);
-}
-
-static void *session_realloc(void *p, size_t size, void *ctx)
-{
- h2_session *session = ctx;
- ap_log_cerror(APLOG_MARK, APLOG_TRACE6, 0, session->c,
- "h2_session(%ld): realloc(%ld)",
- session->id, (long)size);
- return realloc(p, size);
-}
-
static h2_session *h2_session_create_int(conn_rec *c,
request_rec *r,
h2_ctx *ctx,
session = apr_pcalloc(pool, sizeof(h2_session));
if (session) {
int rv;
- nghttp2_mem *mem;
-
session->id = c->id;
session->c = c;
session->r = r;
* get flooded by nghttp2. */
nghttp2_option_set_no_auto_window_update(options, 1);
- if (APLOGctrace6(c)) {
- mem = apr_pcalloc(session->pool, sizeof(nghttp2_mem));
- mem->mem_user_data = session;
- mem->malloc = session_malloc;
- mem->free = session_free;
- mem->calloc = session_calloc;
- mem->realloc = session_realloc;
-
- rv = nghttp2_session_server_new3(&session->ngh2, callbacks,
- session, options, mem);
- }
- else {
- rv = nghttp2_session_server_new2(&session->ngh2, callbacks,
- session, options);
- }
+ rv = nghttp2_session_server_new2(&session->ngh2, callbacks,
+ session, options);
nghttp2_session_callbacks_del(callbacks);
nghttp2_option_del(options);
session->push_diary = h2_push_diary_create(session->pool, n);
if (APLOGcdebug(c)) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(03200)
- "h2_session(%ld) created, max_streams=%d, "
- "stream_mem=%d, workers_limit=%d, workers_max=%d, "
- "push_diary(type=%d,N=%d)",
- session->id, (int)session->max_stream_count,
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c,
+ H2_SSSN_LOG(APLOGNO(03200), session,
+ "created, max_streams=%d, stream_mem=%d, "
+ "workers_limit=%d, workers_max=%d, "
+ "push_diary(type=%d,N=%d)"),
+ (int)session->max_stream_count,
(int)session->max_stream_mem,
session->mplx->workers_limit,
session->mplx->workers_max,
++slen;
}
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, APLOGNO(03201)
- "h2_session(%ld): start, INITIAL_WINDOW_SIZE=%ld, "
- "MAX_CONCURRENT_STREAMS=%d",
- session->id, (long)win_size, (int)session->max_stream_count);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
+ H2_SSSN_LOG(APLOGNO(03201), session,
+ "start, INITIAL_WINDOW_SIZE=%ld, MAX_CONCURRENT_STREAMS=%d"),
+ (long)win_size, (int)session->max_stream_count);
*rv = nghttp2_submit_settings(session->ngh2, NGHTTP2_FLAG_NONE,
settings, slen);
if (*rv != 0) {
status = APR_EGENERAL;
ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c,
- APLOGNO(02935) "nghttp2_submit_settings: %s",
- nghttp2_strerror(*rv));
+ H2_SSSN_LOG(APLOGNO(02935), session,
+ "nghttp2_submit_settings: %s"), nghttp2_strerror(*rv));
}
else {
/* use maximum possible value for connection window size. We are only
if (*rv != 0) {
status = APR_EGENERAL;
ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c,
- APLOGNO(02970) "nghttp2_submit_window_update: %s",
+ H2_SSSN_LOG(APLOGNO(02970), session,
+ "nghttp2_submit_window_update: %s"),
nghttp2_strerror(*rv));
}
}
if (!stream) {
ap_log_cerror(APLOG_MARK, APLOG_ERR, 0, session->c,
APLOGNO(02937)
- "h2_stream(%ld-%d): data requested but stream not found",
+ "h2_stream(%ld-%d): data_cb, stream not found",
session->id, (int)stream_id);
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
status = h2_stream_out_prepare(stream, &nread, &eos, NULL);
if (nread) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- H2_STREAM_MSG(stream, "prepared no_copy, len=%ld, eos=%d"),
+ H2_STRM_MSG(stream, "prepared no_copy, len=%ld, eos=%d"),
(long)nread, eos);
*data_flags |= NGHTTP2_DATA_FLAG_NO_COPY;
}
* it. Remember at our h2_stream that we need to do this.
*/
nread = 0;
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03071)
- H2_STREAM_MSG(stream, "suspending"));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03071), stream, "suspending"));
return NGHTTP2_ERR_DEFERRED;
default:
nread = 0;
- ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c, APLOGNO(02938)
- H2_STREAM_MSG(stream, "reading data"));
+ ap_log_cerror(APLOG_MARK, APLOG_ERR, status, session->c,
+ H2_STRM_LOG(APLOGNO(02938), stream, "reading data"));
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
nid = nghttp2_submit_push_promise(session->ngh2, 0, is->id,
ngh->nv, ngh->nvlen, NULL);
if (nid <= 0) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03075)
- H2_STREAM_MSG(is, "submitting push promise fail: %s"),
- nghttp2_strerror(nid));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03075), is,
+ "submitting push promise fail: %s"), nghttp2_strerror(nid));
return NULL;
}
++session->pushes_promised;
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03076)
- H2_STREAM_MSG(is, "SERVER_PUSH %d for %s %s on %d"),
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03076), is, "SERVER_PUSH %d for %s %s on %d"),
nid, push->req->method, push->req->path, is->id);
stream = h2_session_open_stream(session, nid, is->id);
if (!stream) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03077)
- H2_STREAM_MSG(stream, "failed to create stream obj %d"),
- nid);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03077), stream,
+ "failed to create stream obj %d"), nid);
/* kill the push_promise */
nghttp2_submit_rst_stream(session->ngh2, NGHTTP2_FLAG_NONE, nid,
NGHTTP2_INTERNAL_ERROR);
s = nghttp2_session_find_stream(session->ngh2, stream->id);
if (!s) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "lookup of nghttp2_stream failed"));
+ H2_STRM_MSG(stream, "lookup of nghttp2_stream failed"));
return APR_EINVAL;
}
rv = nghttp2_session_change_stream_priority(session->ngh2, stream->id, &ps);
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03203)
- H2_STREAM_MSG(stream, "PUSH %s, weight=%d, depends=%d, returned=%d"),
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ ""H2_STRM_LOG(APLOGNO(03203), stream,
+ "PUSH %s, weight=%d, depends=%d, returned=%d"),
ptype, ps.weight, ps.stream_id, rv);
status = (rv < 0)? APR_EGENERAL : APR_SUCCESS;
}
ap_assert(session);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- H2_STREAM_MSG(stream, "on_headers"));
+ H2_STRM_MSG(stream, "on_headers"));
if (headers->status < 100) {
h2_stream_rst(stream, headers->status);
goto leave;
h2_ngheader *nh;
nh = h2_util_ngheader_make(stream->pool, headers->headers);
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03072)
- H2_STREAM_MSG(stream, "submit %d trailers"), (int)nh->nvlen);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03072), stream, "submit %d trailers"), (int)nh->nvlen);
rv = nghttp2_submit_trailer(session->ngh2, stream->id, nh->nv, nh->nvlen);
goto leave;
}
apr_table_t *hout;
const char *note;
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03073)
- H2_STREAM_MSG(stream, "submit response %d, REMOTE_WINDOW_SIZE=%u"),
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03073), stream, "submit response %d, REMOTE_WINDOW_SIZE=%u"),
headers->status,
(unsigned int)nghttp2_session_get_stream_remote_window_size(session->ngh2, stream->id));
ap_assert(stream);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- H2_STREAM_MSG(stream, "on_resume"));
+ H2_STRM_MSG(stream, "on_resume"));
send_headers:
headers = NULL;
status = h2_stream_out_prepare(stream, &len, &eos, &headers);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, session->c,
- H2_STREAM_MSG(stream, "prepared len=%ld, eos=%d"),
+ H2_STRM_MSG(stream, "prepared len=%ld, eos=%d"),
(long)len, eos);
if (headers) {
status = on_stream_headers(session, stream, headers, len, eos);
/* we have DATA to send */
if (!stream->has_response) {
/* but no response */
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03466)
- H2_STREAM_MSG(stream, "no response, RST_STREAM"));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03466), stream, "no response, RST_STREAM"));
h2_stream_rst(stream, H2_ERR_PROTOCOL_ERROR);
return APR_SUCCESS;
}
rv = nghttp2_session_resume_data(session->ngh2, stream->id);
session->have_written = 1;
ap_log_cerror(APLOG_MARK, nghttp2_is_fatal(rv)?
- APLOG_ERR : APLOG_DEBUG, 0, session->c, APLOGNO(02936)
- H2_STREAM_MSG(stream, "resumed"));
+ APLOG_ERR : APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(02936), stream, "resumed"));
}
return status;
}
if (len > 0) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session(%ld): feeding %ld bytes to nghttp2",
- session->id, (long)len);
+ H2_SSSN_MSG(session, "feeding %ld bytes to nghttp2"),
+ (long)len);
n = nghttp2_session_mem_recv(session->ngh2, (const uint8_t *)data, len);
if (n < 0) {
if (nghttp2_is_fatal((int)n)) {
|| APR_STATUS_IS_EOF(status)
|| APR_STATUS_IS_EBADF(status)) {
/* common status for a client that has left */
- ap_log_cerror( APLOG_MARK, APLOG_TRACE1, status, c,
- "h2_session(%ld): input gone", session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, c,
+ H2_SSSN_MSG(session, "input gone"));
}
else {
/* uncommon status, log on INFO so that we see this */
ap_log_cerror( APLOG_MARK, APLOG_DEBUG, status, c,
- APLOGNO(02950)
- "h2_session(%ld): error reading, terminating",
- session->id);
+ H2_SSSN_LOG(APLOGNO(02950), session,
+ "error reading, terminating"));
}
return status;
}
if ((session->io.bytes_read - read_start) > (64*1024)) {
/* read enough in one go, give write a chance */
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, c,
- "h2_session(%ld): read 64k, returning", session->id);
+ H2_SSSN_MSG(session, "read 64k, returning"));
break;
}
}
"CLEANUP", /* H2_SESSION_ST_CLEANUP */
};
-static const char *state_name(h2_session_state state)
+const char *h2_session_state_str(h2_session_state state)
{
if (state >= (sizeof(StateNames)/sizeof(StateNames[0]))) {
return "unknown";
|| (session->state == H2_SESSION_ST_WAIT && nstate == H2_SESSION_ST_BUSY)){
loglvl = APLOG_TRACE1;
}
- ap_log_cerror(APLOG_MARK, loglvl, 0, session->c, APLOGNO(03078)
- "h2_session(%ld): transit [%s] -- %s --> [%s]", session->id,
- state_name(session->state), action, state_name(nstate));
+ ap_log_cerror(APLOG_MARK, loglvl, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03078), session,
+ "transit [%s] -- %s --> [%s]"),
+ h2_session_state_str(session->state), action,
+ h2_session_state_str(nstate));
session->state = nstate;
switch (session->state) {
case H2_SESSION_ST_IDLE:
break;
default:
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03401)
- "h2_session(%ld): conn error -> shutdown", session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03401), session,
+ "conn error -> shutdown"));
h2_session_shutdown(session, arg, msg, 0);
break;
}
static void h2_session_ev_proto_error(h2_session *session, int arg, const char *msg)
{
if (!session->local.shutdown) {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03402)
- "h2_session(%ld): proto error -> shutdown", session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_SSSN_LOG(APLOGNO(03402), session,
+ "proto error -> shutdown"));
h2_session_shutdown(session, arg, msg, 0);
}
}
* - we have finished all streams and the client has sent GO_AWAY
*/
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- "h2_session(%ld): NO_IO event, %d streams open",
- session->id, session->open_streams);
+ H2_SSSN_MSG(session, "NO_IO event, %d streams open"),
+ session->open_streams);
h2_conn_io_flush(&session->io);
if (session->open_streams > 0) {
if (h2_mplx_awaits_data(session->mplx)) {
if (stream->request) {
const h2_request *r = stream->request;
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "schedule %s %s://%s%s chunked=%d"),
+ H2_STRM_MSG(stream, "schedule %s %s://%s%s chunked=%d"),
r->method, r->scheme, r->authority, r->path, r->chunked);
stream->scheduled = 1;
h2_mplx_process(session->mplx, stream, stream_pri_cmp, session);
h2_session *session = ctx;
/* stream entered a new state */
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, session->c,
- H2_STREAM_MSG(stream, "entered state"));
+ H2_STRM_MSG(stream, "entered state"));
switch (stream->state) {
case H2_SS_IDLE: /* stream was created */
++session->open_streams;
break;
default:
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- "h2_session(%ld): unknown event %d",
- session->id, ev);
+ H2_SSSN_MSG(session, "unknown event %d"), ev);
break;
}
}
on_stream_resume, session);
if (status == APR_EAGAIN) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, session->c,
- "h2_session(%ld): no master event available", session->id);
+ H2_SSSN_MSG(session, "no master event available"));
}
else if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, session->c,
- "h2_session(%ld): dispatch error", session->id);
+ H2_SSSN_MSG(session, "dispatch error"));
dispatch_event(session, H2_SESSION_EV_CONN_ERROR,
H2_ERR_INTERNAL_ERROR, "dispatch error");
}
if (trace) {
ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): process start, async=%d",
- session->id, async);
+ H2_SSSN_MSG(session, "process start, async=%d"), async);
}
while (session->state != H2_SESSION_ST_DONE) {
case H2_SESSION_ST_INIT:
ap_update_child_status_from_conn(c->sbh, SERVER_BUSY_READ, c);
if (!h2_is_acceptable_connection(c, 1)) {
- update_child_status(session, SERVER_BUSY_READ, "inadequate security");
- h2_session_shutdown(session, NGHTTP2_INADEQUATE_SECURITY, NULL, 1);
+ update_child_status(session, SERVER_BUSY_READ,
+ "inadequate security");
+ h2_session_shutdown(session,
+ NGHTTP2_INADEQUATE_SECURITY, NULL, 1);
}
else {
update_child_status(session, SERVER_BUSY_READ, "init");
status = h2_session_start(session, &rv);
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, c, APLOGNO(03079)
- "h2_session(%ld): started on %s:%d", session->id,
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, c,
+ H2_SSSN_LOG(APLOGNO(03079), session,
+ "started on %s:%d"),
session->s->server_hostname,
c->local_addr->port);
if (status != APR_SUCCESS) {
- dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, NULL);
+ dispatch_event(session,
+ H2_SESSION_EV_CONN_ERROR, 0, NULL);
}
dispatch_event(session, H2_SESSION_EV_INIT, 0, NULL);
}
if (!session->keep_sync_until && async && !session->open_streams
&& !session->r && session->remote.emitted_count) {
if (trace) {
- ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): async idle, nonblock read, "
- "%d streams open", session->id,
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, c,
+ H2_SSSN_MSG(session,
+ "nonblock read, %d streams open"),
session->open_streams);
}
status = h2_session_read(session, 0);
session->have_read = 1;
dispatch_event(session, H2_SESSION_EV_DATA_READ, 0, NULL);
}
- else if (APR_STATUS_IS_EAGAIN(status) || APR_STATUS_IS_TIMEUP(status)) {
+ else if (APR_STATUS_IS_EAGAIN(status)
+ || APR_STATUS_IS_TIMEUP(status)) {
if (apr_time_now() > session->idle_until) {
- dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, NULL);
+ dispatch_event(session,
+ H2_SESSION_EV_CONN_TIMEOUT, 0, NULL);
}
else {
status = APR_EAGAIN;
}
}
else {
- ap_log_cerror( APLOG_MARK, APLOG_DEBUG, status, c,
- APLOGNO(03403)
- "h2_session(%ld): idle, no data, error",
- session->id);
- dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, "timeout");
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, c,
+ H2_SSSN_LOG(APLOGNO(03403), session,
+ "no data, error"));
+ dispatch_event(session,
+ H2_SESSION_EV_CONN_ERROR, 0, "timeout");
}
}
else {
if (trace) {
- ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): sync idle, stutter 1-sec, "
- "%d streams open", session->id,
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, c,
+ H2_SSSN_MSG(session,
+ "sync, stutter 1-sec, %d streams open"),
session->open_streams);
}
/* We wait in smaller increments, using a 1 second timeout.
}
if (now > session->idle_until) {
if (trace) {
- ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): keepalive timeout",
- session->id);
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, c,
+ H2_SSSN_MSG(session,
+ "keepalive timeout"));
}
- dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, "timeout");
+ dispatch_event(session,
+ H2_SESSION_EV_CONN_TIMEOUT, 0, "timeout");
}
else if (trace) {
- ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): keepalive, %f sec left",
- session->id, (session->idle_until - now) / 1000000.0f);
+ ap_log_cerror(APLOG_MARK, APLOG_TRACE3, status, c,
+ H2_SSSN_MSG(session,
+ "keepalive, %f sec left"),
+ (session->idle_until - now) / 1000000.0f);
}
/* continue reading handling */
}
|| APR_STATUS_IS_EOF(status)
|| APR_STATUS_IS_EBADF(status)) {
ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): input gone", session->id);
+ H2_SSSN_MSG(session, "input gone"));
dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, NULL);
}
else {
ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): idle(1 sec timeout) "
- "read failed", session->id);
+ H2_SSSN_MSG(session,
+ "(1 sec timeout) read failed"));
dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, "error");
}
}
}
else {
ap_log_cerror(APLOG_MARK, APLOG_WARNING, status, c,
- APLOGNO(03404)
- "h2_session(%ld): waiting on conditional",
- session->id);
+ H2_SSSN_LOG(APLOGNO(03404), session,
+ "waiting on conditional"));
h2_session_shutdown(session, H2_ERR_INTERNAL_ERROR,
"cond wait error", 0);
}
default:
ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_EGENERAL, c,
- APLOGNO(03080)
- "h2_session(%ld): unknown state %d", session->id, session->state);
+ H2_SSSN_LOG(APLOGNO(03080), session,
+ "unknown state"));
dispatch_event(session, H2_SESSION_EV_PROTO_ERROR, 0, NULL);
break;
}
out:
if (trace) {
ap_log_cerror( APLOG_MARK, APLOG_TRACE3, status, c,
- "h2_session(%ld): [%s] process returns",
- session->id, state_name(session->state));
+ H2_SSSN_MSG(session, "process returns"));
}
if ((session->state != H2_SESSION_ST_DONE)
apr_status_t h2_session_pre_close(h2_session *session, int async)
{
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- "h2_session(%ld): pre_close", session->id);
+ H2_SSSN_MSG(session, "pre_close"));
dispatch_event(session, H2_SESSION_EV_PRE_CLOSE, 0,
(session->state == H2_SESSION_ST_IDLE)? "timeout" : NULL);
return APR_SUCCESS;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "closing input"));
+ H2_STRM_MSG(stream, "closing input"));
if (stream->rst_error) {
return APR_ECONNRESET;
}
APR_BRIGADE_INSERT_TAIL(tmp, b);
stream->trailers = NULL;
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, stream->session->c,
- H2_STREAM_MSG(stream, "added trailers"));
+ H2_STRM_MSG(stream, "added trailers"));
}
b = apr_bucket_eos_create(c->bucket_alloc);
return APR_SUCCESS;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "closing output"));
+ H2_STRM_MSG(stream, "closing output"));
return h2_beam_leave(stream->output);
}
}
/* stream got an event/frame invalid in its state */
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "invalid state event"));
+ H2_STRM_MSG(stream, "invalid state event"));
switch (stream->state) {
case H2_SS_OPEN:
case H2_SS_RSVD_L:
return APR_SUCCESS;
}
else if (new_state < 0) {
- ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, stream->session->c, APLOGNO(03081)
- H2_STREAM_MSG(stream, "invalid transition"));
+ ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, stream->session->c,
+ H2_STRM_LOG(APLOGNO(03081), stream, "invalid transition"));
on_state_invalid(stream);
return APR_EINVAL;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "transit to [%s]"), h2_ss_str(new_state));
+ H2_STRM_MSG(stream, "transit to [%s]"), h2_ss_str(new_state));
stream->state = new_state;
switch (new_state) {
case H2_SS_IDLE:
int new_state;
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, stream->session->c,
- H2_STREAM_MSG(stream, "dispatch event %d"), ev);
+ H2_STRM_MSG(stream, "dispatch event %d"), ev);
new_state = on_event(stream->state, ev);
if (new_state < 0) {
- ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, stream->session->c, APLOGNO(03081)
- H2_STREAM_MSG(stream, "invalid event %d"), ev);
+ ap_log_cerror(APLOG_MARK, APLOG_WARNING, 0, stream->session->c,
+ H2_STRM_LOG(APLOGNO(10002), stream, "invalid event %d"), ev);
on_state_invalid(stream);
AP_DEBUG_ASSERT(new_state > S_XXX);
return;
else if (new_state == stream->state) {
/* nop */
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, stream->session->c,
- H2_STREAM_MSG(stream, "ignored event %d"), ev);
+ H2_STRM_MSG(stream, "ignored event %d"), ev);
return;
}
else {
new_state = on_frame_send(stream->state, ftype);
if (new_state < 0) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "invalid frame %d send"), ftype);
+ H2_STRM_MSG(stream, "invalid frame %d send"), ftype);
AP_DEBUG_ASSERT(new_state > S_XXX);
return transit(stream, new_state);
}
break;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "send frame %d, eos=%d"), ftype, eos);
+ H2_STRM_MSG(stream, "send frame %d, eos=%d"), ftype, eos);
status = transit(stream, new_state);
if (status == APR_SUCCESS && eos) {
status = transit(stream, on_event(stream->state, H2_SEV_CLOSED_L));
new_state = on_frame_recv(stream->state, ftype);
if (new_state < 0) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "invalid frame %d recv"), ftype);
+ H2_STRM_MSG(stream, "invalid frame %d recv"), ftype);
AP_DEBUG_ASSERT(new_state > S_XXX);
return transit(stream, new_state);
}
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, session->c,
- H2_STREAM_MSG(stream, "recv DATA, len=%d"), (int)len);
+ H2_STRM_MSG(stream, "recv DATA, len=%d"), (int)len);
tmp = apr_brigade_create(stream->pool, session->c->bucket_alloc);
apr_brigade_write(tmp, NULL, NULL, (const char *)data, len);
h2_beam_send_from(stream->input, stream->pool);
h2_beam_create(&stream->output, pool, id, "output", H2_BEAM_OWNER_RECV, 0);
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, APLOGNO(03082)
- H2_STREAM_MSG(stream, "created"));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
+ H2_STRM_LOG(APLOGNO(03082), stream, "created"));
on_state_enter(stream);
return stream;
}
status = h2_beam_wait_empty(stream->input, APR_NONBLOCK_READ);
if (status == APR_EAGAIN) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, stream->session->c,
- H2_STREAM_MSG(stream, "wait on input drain"));
+ H2_STRM_MSG(stream, "wait on input drain"));
status = h2_beam_wait_empty(stream->input, APR_BLOCK_READ);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, stream->session->c,
- H2_STREAM_MSG(stream, "input drain returned"));
+ H2_STRM_MSG(stream, "input drain returned"));
}
}
{
ap_assert(stream);
ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, stream->session->c,
- H2_STREAM_MSG(stream, "destroy"));
+ H2_STRM_MSG(stream, "destroy"));
if (stream->pool) {
apr_pool_destroy(stream->pool);
stream->pool = NULL;
h2_beam_abort(stream->input);
h2_beam_leave(stream->output);
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "reset, error=%d"), error_code);
+ H2_STRM_MSG(stream, "reset, error=%d"), error_code);
h2_stream_dispatch(stream, H2_SEV_CANCELLED);
}
}
status = h2_request_rcreate(&req, stream->pool, r);
if (status == APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(03058)
- H2_STREAM_MSG(stream, "set_request_rec %s host=%s://%s%s"),
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r,
+ H2_STRM_LOG(APLOGNO(03058), stream,
+ "set_request_rec %s host=%s://%s%s"),
req->method, req->scheme, req->authority, req->path);
stream->rtmp = req;
/* simulate the frames that led to this */
char *hname, *hvalue;
if (nlen == 0 || name[0] == ':') {
- ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_EINVAL, c, APLOGNO(03060)
- H2_STREAM_MSG(stream, "pseudo header in trailer"));
+ ap_log_cerror(APLOG_MARK, APLOG_DEBUG, APR_EINVAL, c,
+ H2_STRM_LOG(APLOGNO(03060), stream,
+ "pseudo header in trailer"));
return APR_EINVAL;
}
if (h2_req_ignore_trailer(name, nlen)) {
if ((vlen) > session->s->limit_req_line) {
/* pseudo header: approximation of request line size check */
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "pseudo %s too long"), name);
+ H2_STRM_MSG(stream, "pseudo %s too long"), name);
error = HTTP_REQUEST_URI_TOO_LARGE;
}
}
else if ((nlen + 2 + vlen) > session->s->limit_req_fieldsize) {
/* header too long */
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "header %s too long"), name);
+ H2_STRM_MSG(stream, "header %s too long"), name);
error = HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE;
}
return APR_ECONNRESET;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "too many header lines"));
+ H2_STRM_MSG(stream, "too many header lines"));
error = HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE;
}
}
if (status != APR_SUCCESS) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c,
- H2_STREAM_MSG(stream, "header %s not accepted"), name);
+ H2_STRM_MSG(stream, "header %s not accepted"), name);
h2_stream_dispatch(stream, H2_SEV_CANCELLED);
}
return status;
status = h2_beam_receive(stream->output, stream->out_buffer,
APR_NONBLOCK_READ, amount);
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, stream->session->c,
- H2_STREAM_MSG(stream, "beam_received"));
+ H2_STRM_MSG(stream, "beam_received"));
return status;
}
if (status == APR_SUCCESS) {
if (presponse && *presponse) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, c,
- H2_STREAM_MSG(stream, "prepare, response %d"),
+ H2_STRM_MSG(stream, "prepare, response %d"),
(*presponse)->status);
}
else if (*peos || *plen) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, c,
- H2_STREAM_MSG(stream, "prepare, len=%ld eos=%d"),
+ H2_STRM_MSG(stream, "prepare, len=%ld eos=%d"),
(long)*plen, *peos);
}
else {
status = APR_EAGAIN;
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, c,
- H2_STREAM_MSG(stream, "prepare, no data"));
+ H2_STRM_MSG(stream, "prepare, no data"));
}
}
return status;
status = APR_EAGAIN;
}
ap_log_cerror(APLOG_MARK, APLOG_TRACE2, status, c,
- H2_STREAM_MSG(stream, "read_to, len=%ld eos=%d"),
+ H2_STRM_MSG(stream, "read_to, len=%ld eos=%d"),
(long)*plen, *peos);
return status;
}
pushes = h2_push_collect_update(stream, stream->request, response);
if (pushes && !apr_is_empty_array(pushes)) {
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, stream->session->c,
- H2_STREAM_MSG(stream, "found %d push candidates"),
+ H2_STRM_MSG(stream, "found %d push candidates"),
pushes->nelts);
for (i = 0; i < pushes->nelts; ++i) {
h2_push *push = APR_ARRAY_IDX(pushes, i, h2_push*);