Skip to content

Commit 61d9346

Browse files
authored
Require and call destructors on ClassAllocated objects (#12676)
* Update ClassAllocator to require and call destructors on ClassAllocated objects * Cleanup and add HttpSM destructor * The two classes that are now destructed that were previously cleaned up manually are cripts::Context and HttpSM
1 parent 5c7cffe commit 61d9346

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+460
-130
lines changed

include/iocore/eventsystem/Event.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class Event : public Action
289289
//
290290
// Event Allocator
291291
//
292-
extern ClassAllocator<Event> eventAllocator;
292+
extern ClassAllocator<Event, false> eventAllocator;
293293

294294
inline void
295295
Event::free()

include/iocore/eventsystem/IOBuffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class IOBufferData : public RefCountObj
251251
IOBufferData &operator=(const IOBufferData &) = delete;
252252
};
253253

254-
extern ClassAllocator<IOBufferData> ioDataAllocator;
254+
extern ClassAllocator<IOBufferData, false> ioDataAllocator;
255255

256256
/**
257257
A linkable portion of IOBufferData. IOBufferBlock is a chainable
@@ -494,7 +494,7 @@ class IOBufferBlock : public RefCountObj
494494
IOBufferBlock &operator=(const IOBufferBlock &) = delete;
495495
};
496496

497-
extern ClassAllocator<IOBufferBlock> ioBlockAllocator;
497+
extern ClassAllocator<IOBufferBlock, false> ioBlockAllocator;
498498

499499
/** A class for holding a chain of IO buffer blocks.
500500
This class is intended to be used as a member variable for other classes that

include/iocore/eventsystem/Lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class ProxyMutex : public RefCountObj
247247
};
248248

249249
// The ClassAllocator for ProxyMutexes
250-
extern ClassAllocator<ProxyMutex> mutexAllocator;
250+
extern ClassAllocator<ProxyMutex, false> mutexAllocator;
251251

252252
inline bool
253253
Mutex_trylock(

include/iocore/utils/OneWayMultiTunnel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ struct OneWayMultiTunnel : public OneWayTunnel {
131131
VIO *vioTargets[ONE_WAY_MULTI_TUNNEL_LIMIT];
132132
};
133133

134-
extern ClassAllocator<OneWayMultiTunnel> OneWayMultiTunnelAllocator;
134+
extern ClassAllocator<OneWayMultiTunnel, false> OneWayMultiTunnelAllocator;

include/proxy/http/Http1ClientSession.h

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

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

include/proxy/http/Http1ServerSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Http1ServerSession : public PoolableSession
105105
Http1ServerTransaction trans;
106106
};
107107

108-
extern ClassAllocator<Http1ServerSession, true> httpServerSessionAllocator;
108+
extern ClassAllocator<Http1ServerSession> httpServerSessionAllocator;
109109

110110
////////////////////////////////////////////
111111
// INLINE

include/proxy/http/HttpSM.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class HttpSM : public Continuation, public PluginUserArgs<TS_USER_ARGS_TXN>
187187

188188
public:
189189
HttpSM();
190-
void cleanup();
190+
~HttpSM() override;
191191
virtual void destroy();
192192

193193
static HttpSM *allocate();

include/proxy/http/HttpTransact.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ class HttpTransact
851851
// memset((void *)&host_db_info, 0, sizeof(host_db_info));
852852
}
853853

854+
~State() { destroy(); }
855+
854856
void
855857
destroy()
856858
{
@@ -859,8 +861,10 @@ class HttpTransact
859861
free_internal_msg_buffer();
860862
ats_free(internal_msg_buffer_type);
861863

862-
ParentConfig::release(parent_params);
863-
parent_params = nullptr;
864+
if (parent_params != nullptr) {
865+
ParentConfig::release(parent_params);
866+
parent_params = nullptr;
867+
}
864868

865869
hdr_info.client_request.destroy();
866870
hdr_info.client_response.destroy();
@@ -879,7 +883,6 @@ class HttpTransact
879883
url_map.clear();
880884
arena.reset();
881885
unmapped_url.clear();
882-
dns_info.~ResolveInfo();
883886
outbound_conn_track_state.clear();
884887

885888
delete[] ranges;

include/proxy/http/PreWarmManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class PreWarmSM;
138138
class PreWarmManager;
139139
class SNIConfigParams;
140140

141-
extern ClassAllocator<PreWarmSM> preWarmSMAllocator;
142-
extern PreWarmManager prewarmManager;
141+
extern PreWarmManager prewarmManager;
143142

144143
/**
145144
@class PreWarmSM
@@ -230,6 +229,8 @@ class PreWarmSM : public Continuation
230229
Event *_retry_event = nullptr;
231230
};
232231

232+
extern ClassAllocator<PreWarmSM, false> preWarmSMAllocator;
233+
233234
/**
234235
@class PreWarmQueue
235236
@detail

include/proxy/http2/Http2ClientSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ class Http2ClientSession : public ProxySession, public Http2CommonSession
7979
IpEndpoint cached_local_addr;
8080
};
8181

82-
extern ClassAllocator<Http2ClientSession, true> http2ClientSessionAllocator;
82+
extern ClassAllocator<Http2ClientSession> http2ClientSessionAllocator;

0 commit comments

Comments
 (0)