Repository: trafficserver Updated Branches: refs/heads/master 343810126 -> 0d4c680e1
TS-4008: Cleanup SPDY ClientSessionSession / SpdyRequest Allocate and Deallocate code Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/0d4c680e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/0d4c680e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/0d4c680e Branch: refs/heads/master Commit: 0d4c680e155dade5ac38fff6eeae1f01fd3e33bf Parents: 3438101 Author: Can Selcik <[email protected]> Authored: Mon Nov 9 23:25:03 2015 -0800 Committer: Brian Geffon <[email protected]> Committed: Mon Nov 9 23:25:03 2015 -0800 ---------------------------------------------------------------------- proxy/spdy/SpdyCallbacks.cc | 2 +- proxy/spdy/SpdyClientSession.cc | 17 +++++++++++++++-- proxy/spdy/SpdyClientSession.h | 23 +++++++++++++---------- 3 files changed, 29 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d4c680e/proxy/spdy/SpdyCallbacks.cc ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyCallbacks.cc b/proxy/spdy/SpdyCallbacks.cc index 69b40c8..6b3c02b 100644 --- a/proxy/spdy/SpdyCallbacks.cc +++ b/proxy/spdy/SpdyCallbacks.cc @@ -309,7 +309,7 @@ spdy_on_ctrl_recv_callback(spdylay_session *session, spdylay_frame_type type, sp switch (type) { case SPDYLAY_SYN_STREAM: stream_id = frame->syn_stream.stream_id; - req = spdyRequestAllocator.alloc(); + req = SpdyRequest::alloc(); req->init(sm, stream_id); req->append_nv(frame->syn_stream.nv); sm->req_map[stream_id] = req; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d4c680e/proxy/spdy/SpdyClientSession.cc ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc index c3d23b3..ae7c737 100644 --- a/proxy/spdy/SpdyClientSession.cc +++ b/proxy/spdy/SpdyClientSession.cc @@ -47,6 +47,20 @@ static int spdy_process_fetch_header(TSEvent event, SpdyClientSession *sm, TSFet static int spdy_process_fetch_body(TSEvent event, SpdyClientSession *sm, TSFetchSM fetch_sm, SpdyRequest *req); static uint64_t g_sm_id = 1; +SpdyRequest * +SpdyRequest::alloc() +{ + return spdyRequestAllocator.alloc(); +} + +void +SpdyRequest::destroy() +{ + this->clear(); + spdyRequestAllocator.free(this); +} + + void SpdyRequest::init(SpdyClientSession *sm, int id) { @@ -136,8 +150,7 @@ SpdyClientSession::clear() for (; iter != endIter; ++iter) { SpdyRequest *req = iter->second; if (req) { - req->clear(); - spdyRequestAllocator.free(req); + req->destroy(); } else { Error("req null in SpdSM::clear"); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/0d4c680e/proxy/spdy/SpdyClientSession.h ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyClientSession.h b/proxy/spdy/SpdyClientSession.h index 516a34c..5e5d183 100644 --- a/proxy/spdy/SpdyClientSession.h +++ b/proxy/spdy/SpdyClientSession.h @@ -38,23 +38,24 @@ class SpdyRequest { public: SpdyRequest() - : spdy_sm(NULL), stream_id(-1), fetch_sm(NULL), has_submitted_data(false), need_resume_data(false), fetch_data_len(0), - delta_window_size(0), fetch_body_completed(false) + : event(0), spdy_sm(NULL), stream_id(-1), start_time(0), fetch_sm(NULL), has_submitted_data(false), need_resume_data(false), + fetch_data_len(0), delta_window_size(0), fetch_body_completed(false) { } SpdyRequest(SpdyClientSession *sm, int id) - : spdy_sm(NULL), stream_id(-1), fetch_sm(NULL), has_submitted_data(false), need_resume_data(false), fetch_data_len(0), - delta_window_size(0), fetch_body_completed(false) + : event(0), spdy_sm(NULL), stream_id(-1), start_time(0), fetch_sm(NULL), has_submitted_data(false), need_resume_data(false), + fetch_data_len(0), delta_window_size(0), fetch_body_completed(false) { init(sm, id); } - ~SpdyRequest() { clear(); } - void init(SpdyClientSession *sm, int id); void clear(); + static SpdyRequest *alloc(); + void destroy(); + void append_nv(char **nv) { @@ -93,9 +94,12 @@ class SpdyClientSession : public ProxyClientSession, public PluginIdentity { public: typedef ProxyClientSession super; ///< Parent type. - SpdyClientSession() {} + SpdyClientSession() + : sm_id(0), version(spdy::SessionVersion::SESSION_VERSION_3_1), total_size(0), start_time(0), vc(NULL), req_buffer(NULL), + req_reader(NULL), resp_buffer(NULL), resp_reader(NULL), read_vio(NULL), write_vio(NULL), event(0), session(NULL) + { + } - ~SpdyClientSession() { clear(); } void init(NetVConnection *netvc); void clear(); @@ -178,8 +182,7 @@ public: { SpdyRequest *req = this->find_request(streamId); if (req) { - req->clear(); - spdyRequestAllocator.free(req); + req->destroy(); this->req_map.erase(streamId); } if (req_map.empty() == true) {
