Skip to content

Commit d9807dd

Browse files
authored
Call constructors and destructors for H1/2 Session/Transaction via ClassAllocator (#7584)
1 parent aeddf9b commit d9807dd

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
@@ -57,7 +57,7 @@ ink_mutex debug_cs_list_mutex;
5757

5858
#endif /* USE_HTTP_DEBUG_LISTS */
5959

60-
ClassAllocator<Http1ClientSession> http1ClientSessionAllocator("http1ClientSessionAllocator");
60+
ClassAllocator<Http1ClientSession, true> http1ClientSessionAllocator("http1ClientSessionAllocator");
6161

6262
Http1ClientSession::Http1ClientSession() : super(), trans(this) {}
6363

@@ -120,7 +120,6 @@ Http1ClientSession::free()
120120
_vc = nullptr;
121121
}
122122

123-
this->~Http1ClientSession();
124123
THREAD_FREE(this, http1ClientSessionAllocator, this_thread());
125124
}
126125

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
@@ -1819,7 +1819,6 @@ HttpSM::state_http_server_open(int event, void *data)
18191819
Http1ServerSession *session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == httpSessionManager.get_pool_type()) ?
18201820
THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) :
18211821
httpServerSessionAllocator.alloc();
1822-
new (session) Http1ServerSession();
18231822
session->sharing_pool = static_cast<TSServerSessionSharingPoolType>(t_state.http_config_param->server_session_sharing_pool);
18241823
session->sharing_match = static_cast<TSServerSessionSharingMatchMask>(t_state.txn_conf->server_session_sharing_match);
18251824

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
@@ -47,7 +47,7 @@
4747
this->session_handler = (handler); \
4848
} while (0)
4949

50-
ClassAllocator<Http2ClientSession> http2ClientSessionAllocator("http2ClientSessionAllocator");
50+
ClassAllocator<Http2ClientSession, true> http2ClientSessionAllocator("http2ClientSessionAllocator");
5151

5252
// memcpy the requested bytes from the IOBufferReader, returning how many were
5353
// actually copied.
@@ -163,7 +163,6 @@ Http2ClientSession::free()
163163

164164
free_MIOBuffer(this->read_buffer);
165165
free_MIOBuffer(this->write_buffer);
166-
this->~Http2ClientSession();
167166
THREAD_FREE(this, http2ClientSessionAllocator, this_ethread());
168167
}
169168

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)