mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 771489: Use standard threadsafe refcounting in host resolver. r=sworkman
This commit is contained in:
parent
c5c89211d2
commit
4880d7e328
@ -149,8 +149,7 @@ private:
|
||||
#define RES_KEY_FLAGS(_f) ((_f) & nsHostResolver::RES_CANON_NAME)
|
||||
|
||||
nsHostRecord::nsHostRecord(const nsHostKey *key)
|
||||
: _refc(1)
|
||||
, addr_info_lock("nsHostRecord.addr_info_lock")
|
||||
: addr_info_lock("nsHostRecord.addr_info_lock")
|
||||
, addr_info_gencnt(0)
|
||||
, addr_info(nsnull)
|
||||
, addr(nsnull)
|
||||
@ -164,7 +163,6 @@ nsHostRecord::nsHostRecord(const nsHostKey *key)
|
||||
flags = key->flags;
|
||||
af = key->af;
|
||||
|
||||
NS_LOG_ADDREF(this, 1, "nsHostRecord", sizeof(nsHostRecord));
|
||||
expiration = NowInMinutes();
|
||||
|
||||
PR_INIT_CLIST(this);
|
||||
@ -181,6 +179,7 @@ nsHostRecord::Create(const nsHostKey *key, nsHostRecord **result)
|
||||
// allocated after it.
|
||||
void *place = ::operator new(size);
|
||||
*result = new(place) nsHostRecord(key);
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -22,24 +22,6 @@ class nsHostResolver;
|
||||
class nsHostRecord;
|
||||
class nsResolveHostCallback;
|
||||
|
||||
/* XXX move this someplace more generic */
|
||||
#define NS_DECL_REFCOUNTED_THREADSAFE(classname) \
|
||||
private: \
|
||||
nsAutoRefCnt _refc; \
|
||||
public: \
|
||||
PRInt32 AddRef() { \
|
||||
PRInt32 n = NS_AtomicIncrementRefcnt(_refc); \
|
||||
NS_LOG_ADDREF(this, n, #classname, sizeof(classname)); \
|
||||
return n; \
|
||||
} \
|
||||
PRInt32 Release() { \
|
||||
PRInt32 n = NS_AtomicDecrementRefcnt(_refc); \
|
||||
NS_LOG_RELEASE(this, n, #classname); \
|
||||
if (n == 0) \
|
||||
delete this; \
|
||||
return n; \
|
||||
}
|
||||
|
||||
#define MAX_RESOLVER_THREADS_FOR_ANY_PRIORITY 3
|
||||
#define MAX_RESOLVER_THREADS_FOR_HIGH_PRIORITY 5
|
||||
#define MAX_NON_PRIORITY_REQUESTS 150
|
||||
@ -62,7 +44,7 @@ class nsHostRecord : public PRCList, public nsHostKey
|
||||
typedef mozilla::Mutex Mutex;
|
||||
|
||||
public:
|
||||
NS_DECL_REFCOUNTED_THREADSAFE(nsHostRecord)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHostRecord)
|
||||
|
||||
/* instantiates a new host record */
|
||||
static nsresult Create(const nsHostKey *key, nsHostRecord **record);
|
||||
@ -178,7 +160,7 @@ public:
|
||||
/**
|
||||
* host resolver instances are reference counted.
|
||||
*/
|
||||
NS_DECL_REFCOUNTED_THREADSAFE(nsHostResolver)
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHostResolver)
|
||||
|
||||
/**
|
||||
* creates an addref'd instance of a nsHostResolver object.
|
||||
|
Loading…
Reference in New Issue
Block a user