初步完成HTTP应答侧解析功能,并修正一系类错误处理类的问题。

This commit is contained in:
Lu Qiuwen
2018-09-23 17:33:05 +08:00
parent 7b6dbb06aa
commit 2798783641
10 changed files with 223 additions and 49 deletions

View File

@@ -660,6 +660,7 @@ void ssl_upstream_create_on_success(future_result_t * result, void * user)
void ssl_upstream_create_on_fail(enum e_future_error err, const char * what, void * user)
{
return;
assert(0);
}
@@ -672,7 +673,7 @@ struct tfe_stream * tfe_stream_create(struct tfe_proxy * pxy, struct tfe_thread_
unsigned int total_plugin_count = tfe_plugin_total_counts();
_stream->plugin_ctxs = ALLOC(struct plugin_ctx, total_plugin_count);
return (struct tfe_stream *) &_stream->head;
return &_stream->head;
}
void __stream_access_log_write(struct tfe_stream_private * stream)
@@ -733,6 +734,7 @@ void tfe_stream_destory(struct tfe_stream_private * stream)
{
future_destroy(stream->future_upstream_create);
}
stream->proxy_ref = NULL;
free(stream);
thread->load--;
@@ -878,7 +880,7 @@ void __stream_fd_option_setup(struct tfe_stream_private * _stream, evutil_socket
return;
}
void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downstream, evutil_socket_t fd_upstream)
int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downstream, evutil_socket_t fd_upstream)
{
struct tfe_stream_private * _stream = container_of(stream, struct tfe_stream_private, head);
struct event_base * ev_base = _stream->thread_ref->evbase;
@@ -890,13 +892,14 @@ void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downs
__stream_fd_option_setup(_stream, fd_upstream);
_stream->head.addr = __stream_addr_create_by_fds(stream, fd_downstream);
_stream->str_stream_addr = tfe_stream_addr_to_str(_stream->head.addr);
if (unlikely(_stream->head.addr == NULL))
{
assert(0);
TFE_LOG_ERROR(_stream->stream_logger, "Failed to fetch address for fd %d, %d, terminate fds.",
fd_downstream, fd_upstream); goto __errout;
}
_stream->str_stream_addr = tfe_stream_addr_to_str(_stream->head.addr);
if (_stream->session_type == STREAM_PROTO_PLAIN)
{
_stream->conn_downstream = __conn_private_create_by_fd(_stream, fd_downstream);
@@ -921,7 +924,10 @@ void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downs
_stream->ssl_mgr, fd_upstream, fd_downstream, ev_base);
}
return;
return 0;
__errout:
return -1;
}
int tfe_stream_option_set(struct tfe_stream * stream, enum tfe_stream_option opt, const void * arg, size_t sz_arg)
@@ -949,9 +955,10 @@ void tfe_stream_write_access_log(const struct tfe_stream * stream, int level, co
struct tfe_stream_private * _stream = container_of(stream, struct tfe_stream_private, head);
/* Format input content */
char __tmp_buffer[TFE_STRING_MAX];
vsnprintf(__tmp_buffer, sizeof(__tmp_buffer), fmt, arg_ptr);
char * __tmp_buffer;
vasprintf(&__tmp_buffer, fmt, arg_ptr);
/* Log content with stream tag */
MESA_handle_runtime_log(_stream->stream_logger, level, "S-DETAIL", "%s %s", _stream->str_stream_addr, __tmp_buffer);
MESA_handle_runtime_log(_stream->stream_logger, level, "access", "%s %s", _stream->str_stream_addr, __tmp_buffer);
free(__tmp_buffer);
}