Skip to content

Commit a0dd3c2

Browse files
maskitzwoop
authored andcommitted
Call constructors and destructors for H1/2 Session/Transaction via ClassAllocator (#7584)
(cherry picked from commit d9807dd)
1 parent b24f62f commit a0dd3c2

12 files changed

+12
-18
lines changed

proxy/http/Http1ClientSession.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ink_mutex debug_cs_list_mutex;
5555

5656
#endif /* USE_HTTP_DEBUG_LISTS */
5757

58-
ClassAllocator<Http1ClientSession> http1ClientSessionAllocator("http1ClientSessionAllocator");
58+
ClassAllocator<Http1ClientSession, true> http1ClientSessionAllocator("http1ClientSessionAllocator");
5959

6060
Http1ClientSession::Http1ClientSession() : super(), trans(this) {}
6161

@@ -118,7 +118,6 @@ Http1ClientSession::free()
118118
_vc = nullptr;
119119
}
120120

121-
this->~Http1ClientSession();
122121
THREAD_FREE(this, http1ClientSessionAllocator, this_thread());
123122
}
124123

proxy/http/Http1ClientSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ class Http1ClientSession : public ProxySession
129129
Http1Transaction trans;
130130
};
131131

132-
extern ClassAllocator<Http1ClientSession> http1ClientSessionAllocator;
132+
extern ClassAllocator<Http1ClientSession, true> http1ClientSessionAllocator;

proxy/http/Http1ServerSession.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "HttpSessionManager.h"
3737
#include "HttpSM.h"
3838

39-
ClassAllocator<Http1ServerSession> httpServerSessionAllocator("httpServerSessionAllocator");
39+
ClassAllocator<Http1ServerSession, true> httpServerSessionAllocator("httpServerSessionAllocator");
4040

4141
void
4242
Http1ServerSession::destroy()
@@ -50,7 +50,6 @@ Http1ServerSession::destroy()
5050
}
5151

5252
mutex.clear();
53-
this->~Http1ServerSession();
5453
if (httpSessionManager.get_pool_type() == TS_SERVER_SESSION_SHARING_POOL_THREAD) {
5554
THREAD_FREE(this, httpServerSessionAllocator, this_thread());
5655
} else {

proxy/http/Http1ServerSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Http1ServerSession : public PoolableSession
107107
IOBufferReader *buf_reader = nullptr;
108108
};
109109

110-
extern ClassAllocator<Http1ServerSession> httpServerSessionAllocator;
110+
extern ClassAllocator<Http1ServerSession, true> httpServerSessionAllocator;
111111

112112
////////////////////////////////////////////
113113
// INLINE

proxy/http/HttpSM.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,6 @@ HttpSM::state_http_server_open(int event, void *data)
18311831
Http1ServerSession *session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == httpSessionManager.get_pool_type()) ?
18321832
THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) :
18331833
httpServerSessionAllocator.alloc();
1834-
new (session) Http1ServerSession();
18351834
session->sharing_pool = static_cast<TSServerSessionSharingPoolType>(t_state.http_config_param->server_session_sharing_pool);
18361835
session->sharing_match = static_cast<TSServerSessionSharingMatchMask>(t_state.txn_conf->server_session_sharing_match);
18371836

proxy/http/HttpSessionAccept.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ HttpSessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReade
5050
}
5151

5252
Http1ClientSession *new_session = THREAD_ALLOC_INIT(http1ClientSessionAllocator, this_ethread());
53-
new (new_session) Http1ClientSession();
5453

5554
new_session->accept_options = static_cast<Options *>(this);
5655
new_session->acl = std::move(acl);

proxy/http2/Http2ClientSession.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
this->session_handler = (handler); \
4646
} while (0)
4747

48-
ClassAllocator<Http2ClientSession> http2ClientSessionAllocator("http2ClientSessionAllocator");
48+
ClassAllocator<Http2ClientSession, true> http2ClientSessionAllocator("http2ClientSessionAllocator");
4949

5050
// memcpy the requested bytes from the IOBufferReader, returning how many were
5151
// actually copied.
@@ -161,7 +161,6 @@ Http2ClientSession::free()
161161

162162
free_MIOBuffer(this->read_buffer);
163163
free_MIOBuffer(this->write_buffer);
164-
this->~Http2ClientSession();
165164
THREAD_FREE(this, http2ClientSessionAllocator, this_ethread());
166165
}
167166

proxy/http2/Http2ClientSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Http2ClientSession : public ProxySession
175175
bool cur_frame_from_early_data = false;
176176
};
177177

178-
extern ClassAllocator<Http2ClientSession> http2ClientSessionAllocator;
178+
extern ClassAllocator<Http2ClientSession, true> http2ClientSessionAllocator;
179179

180180
///////////////////////////////////////////////
181181
// INLINE

proxy/http2/Http2ConnectionState.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,8 +1220,8 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error)
12201220
}
12211221
}
12221222

1223-
Http2Stream *new_stream = THREAD_ALLOC_INIT(http2StreamAllocator, this_ethread());
1224-
new (new_stream) Http2Stream(ua_session, new_id, client_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
1223+
Http2Stream *new_stream = THREAD_ALLOC_INIT(http2StreamAllocator, this_ethread(), ua_session, new_id,
1224+
client_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE));
12251225

12261226
ink_assert(nullptr != new_stream);
12271227
ink_assert(!stream_list.in(new_stream));

proxy/http2/Http2SessionAccept.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ Http2SessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferRead
5454
}
5555

5656
Http2ClientSession *new_session = THREAD_ALLOC_INIT(http2ClientSessionAllocator, this_ethread());
57-
new (new_session) Http2ClientSession();
58-
new_session->acl = std::move(session_acl);
59-
new_session->accept_options = &options;
57+
new_session->acl = std::move(session_acl);
58+
new_session->accept_options = &options;
6059

6160
// Pin session to current ET_NET thread
6261
new_session->setThreadAffinity(this_ethread());

0 commit comments

Comments
 (0)