mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Upgrade gperftools to 2.9 for GCP/GMC/GMP/GMD. (#2247)
This commit is contained in:
parent
63da0dca92
commit
44e9dc83e9
346 changed files with 169666 additions and 78 deletions
|
@ -917,7 +917,7 @@ srs_error_t SrsServer::start(SrsWaitGroup* wg)
|
|||
void SrsServer::stop()
|
||||
{
|
||||
#ifdef SRS_GPERF_MC
|
||||
destroy();
|
||||
dispose();
|
||||
|
||||
// remark, for gmc, never invoke the exit().
|
||||
srs_warn("sleep a long time for system st-threads to cleanup.");
|
||||
|
|
|
@ -9,50 +9,62 @@
|
|||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
/**
|
||||
* To free the instance in the current scope, for instance, MyClass* ptr,
|
||||
* which is a ptr and this class will:
|
||||
* 1. free the ptr.
|
||||
* 2. set ptr to NULL.
|
||||
*
|
||||
* Usage:
|
||||
* MyClass* po = new MyClass();
|
||||
* // ...... use po
|
||||
* SrsAutoFree(MyClass, po);
|
||||
*
|
||||
* Usage for array:
|
||||
* MyClass** pa = new MyClass*[size];
|
||||
* // ....... use pa
|
||||
* SrsAutoFreeA(MyClass*, pa);
|
||||
*
|
||||
* @remark the MyClass can be basic type, for instance, SrsAutoFreeA(char, pstr),
|
||||
* where the char* pstr = new char[size].
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
// To free the instance in the current scope, for instance, MyClass* ptr,
|
||||
// which is a ptr and this class will:
|
||||
// 1. free the ptr.
|
||||
// 2. set ptr to NULL.
|
||||
//
|
||||
// Usage:
|
||||
// MyClass* po = new MyClass();
|
||||
// // ...... use po
|
||||
// SrsAutoFree(MyClass, po);
|
||||
//
|
||||
// Usage for array:
|
||||
// MyClass** pa = new MyClass*[size];
|
||||
// // ....... use pa
|
||||
// SrsAutoFreeA(MyClass*, pa);
|
||||
//
|
||||
// @remark the MyClass can be basic type, for instance, SrsAutoFreeA(char, pstr),
|
||||
// where the char* pstr = new char[size].
|
||||
// To delete object.
|
||||
#define SrsAutoFree(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false)
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, false)
|
||||
// To delete array.
|
||||
#define SrsAutoFreeA(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true)
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true, false)
|
||||
// Use free instead of delete.
|
||||
#define SrsAutoFreeF(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, true)
|
||||
// The template implementation.
|
||||
template<class T>
|
||||
class impl_SrsAutoFree
|
||||
{
|
||||
private:
|
||||
T** ptr;
|
||||
bool is_array;
|
||||
bool _use_free;
|
||||
public:
|
||||
impl_SrsAutoFree(T** p, bool array) {
|
||||
impl_SrsAutoFree(T** p, bool array, bool use_free) {
|
||||
ptr = p;
|
||||
is_array = array;
|
||||
_use_free = use_free;
|
||||
}
|
||||
|
||||
virtual ~impl_SrsAutoFree() {
|
||||
if (ptr == NULL || *ptr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array) {
|
||||
delete[] *ptr;
|
||||
|
||||
if (_use_free) {
|
||||
free(*ptr);
|
||||
} else {
|
||||
delete *ptr;
|
||||
if (is_array) {
|
||||
delete[] *ptr;
|
||||
} else {
|
||||
delete *ptr;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = NULL;
|
||||
|
|
|
@ -248,7 +248,7 @@ srs_error_t srs_tcp_listen(std::string ip, int port, srs_netfd_t* pfd)
|
|||
hints.ai_flags = AI_NUMERICHOST;
|
||||
|
||||
addrinfo* r = NULL;
|
||||
SrsAutoFree(addrinfo, r);
|
||||
SrsAutoFreeF(addrinfo, r);
|
||||
if(getaddrinfo(ip.c_str(), sport, (const addrinfo*)&hints, &r)) {
|
||||
return srs_error_new(ERROR_SYSTEM_IP_INVALID, "getaddrinfo hints=(%d,%d,%d)",
|
||||
hints.ai_family, hints.ai_socktype, hints.ai_flags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue