GH-572: Mark MemoryAllocation() and related methods deprecated

This commit is contained in:
Tim Wojtulewicz 2021-05-26 12:42:44 -07:00
parent e6e41ac5d9
commit a7fd34375f
31 changed files with 158 additions and 6 deletions

View file

@ -293,7 +293,10 @@ unsigned int Manager::SessionMemoryUsage()
return 0;
for ( const auto& entry : session_map )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
mem += entry.second->MemoryAllocation();
#pragma GCC diagnostic pop
return mem;
}
@ -307,7 +310,10 @@ unsigned int Manager::SessionMemoryUsageVals()
return 0;
for ( const auto& entry : session_map )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
mem += entry.second->MemoryAllocationVal();
#pragma GCC diagnostic pop
return mem;
}
@ -318,12 +324,15 @@ unsigned int Manager::MemoryAllocation()
// Connections have been flushed already.
return 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return SessionMemoryUsage()
+ padded_sizeof(*this)
+ (session_map.size() * (sizeof(SessionMap::key_type) + sizeof(SessionMap::value_type)))
+ zeek::detail::fragment_mgr->MemoryAllocation();
// FIXME: MemoryAllocation() not implemented for rest.
;
#pragma GCC diagnostic pop
}
void Manager::InsertSession(detail::Key key, Session* session)

View file

@ -92,14 +92,29 @@ public:
[[deprecated("Remove in v5.1. Use CurrentSessions().")]]
unsigned int CurrentConnections() { return CurrentSessions(); }
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
unsigned int SessionMemoryUsage();
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
unsigned int SessionMemoryUsageVals();
[[deprecated("Remove in v5.1. Use SessionMemoryUsage().")]]
unsigned int ConnectionMemoryUsage() { return SessionMemoryUsage(); }
unsigned int ConnectionMemoryUsage()
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return SessionMemoryUsage();
#pragma GCC diagnostic pop
}
[[deprecated("Remove in v5.1. Use SessionMemoryUsageVals().")]]
unsigned int ConnectionMemoryUsageConnVals() { return SessionMemoryUsageVals(); }
unsigned int ConnectionMemoryUsageConnVals()
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return SessionMemoryUsageVals();
#pragma GCC diagnostic pop
}
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
unsigned int MemoryAllocation();
private:

View file

@ -105,14 +105,22 @@ public:
* Return the memory allocation required by the session record. This requires at
* least one call to Get() first in order to setup the record object.
*/
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
virtual unsigned int MemoryAllocationVal() const = 0;
[[deprecated("Remove in v5.1. Use MemoryAllocationVal().")]]
unsigned int MemoryAllocationConnVal() const { return MemoryAllocationVal(); }
unsigned int MemoryAllocationConnVal() const
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return MemoryAllocationVal();
#pragma GCC diagnostic pop
}
/**
* A lower-bound calculation of how much memory a session object is using.
*/
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
virtual unsigned int MemoryAllocation() const;
/**