Remove race conditions
Former-commit-id: 5a8cb77d0df7f319809ff965a72fe46925f49289
This commit is contained in:
parent
1c1260d71f
commit
03769b5c17
@ -55,7 +55,7 @@ typedef ucontext_t sigcontext_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool g_fInCrash = false;
|
int g_fInCrash = false;
|
||||||
|
|
||||||
/* ================================= Debugging ============================== */
|
/* ================================= Debugging ============================== */
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#define UNUSED(x) ((void)x)
|
#define UNUSED(x) ((void)x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern int g_fInCrash;
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
*
|
*
|
||||||
@ -150,7 +151,7 @@ class DeadlockDetector
|
|||||||
public:
|
public:
|
||||||
void registerwait(fastlock *lock, pid_t thispid)
|
void registerwait(fastlock *lock, pid_t thispid)
|
||||||
{
|
{
|
||||||
if (lock == &m_lock)
|
if (lock == &m_lock || g_fInCrash)
|
||||||
return;
|
return;
|
||||||
fastlock_lock(&m_lock);
|
fastlock_lock(&m_lock);
|
||||||
m_mapwait.insert(std::make_pair(thispid, lock));
|
m_mapwait.insert(std::make_pair(thispid, lock));
|
||||||
@ -191,7 +192,7 @@ public:
|
|||||||
|
|
||||||
void clearwait(fastlock *lock, pid_t thispid)
|
void clearwait(fastlock *lock, pid_t thispid)
|
||||||
{
|
{
|
||||||
if (lock == &m_lock)
|
if (lock == &m_lock || g_fInCrash)
|
||||||
return;
|
return;
|
||||||
fastlock_lock(&m_lock);
|
fastlock_lock(&m_lock);
|
||||||
m_mapwait.erase(thispid);
|
m_mapwait.erase(thispid);
|
||||||
|
@ -1509,7 +1509,6 @@ int writeToClient(int fd, client *c, int handler_installed) {
|
|||||||
} else {
|
} else {
|
||||||
serverLog(LL_VERBOSE,
|
serverLog(LL_VERBOSE,
|
||||||
"Error writing to client: %s", strerror(errno));
|
"Error writing to client: %s", strerror(errno));
|
||||||
lock.unlock();
|
|
||||||
freeClientAsync(c);
|
freeClientAsync(c);
|
||||||
|
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
@ -1528,7 +1527,6 @@ int writeToClient(int fd, client *c, int handler_installed) {
|
|||||||
|
|
||||||
/* Close connection after entire reply has been sent. */
|
/* Close connection after entire reply has been sent. */
|
||||||
if (c->flags & CLIENT_CLOSE_AFTER_REPLY) {
|
if (c->flags & CLIENT_CLOSE_AFTER_REPLY) {
|
||||||
lock.unlock();
|
|
||||||
freeClientAsync(c);
|
freeClientAsync(c);
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
}
|
}
|
||||||
@ -3000,7 +2998,6 @@ int processEventsWhileBlocked(int iel) {
|
|||||||
int iterations = 4; /* See the function top-comment. */
|
int iterations = 4; /* See the function top-comment. */
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
aeReleaseLock();
|
|
||||||
while (iterations--) {
|
while (iterations--) {
|
||||||
int events = 0;
|
int events = 0;
|
||||||
events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT);
|
events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT);
|
||||||
@ -3008,7 +3005,6 @@ int processEventsWhileBlocked(int iel) {
|
|||||||
if (!events) break;
|
if (!events) break;
|
||||||
count += events;
|
count += events;
|
||||||
}
|
}
|
||||||
aeAcquireLock();
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +173,8 @@ typedef struct redisConfig {
|
|||||||
sds appendonly;
|
sds appendonly;
|
||||||
} redisConfig;
|
} redisConfig;
|
||||||
|
|
||||||
|
int g_fInCrash = false;
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
|
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask);
|
||||||
static void createMissingClients(client c);
|
static void createMissingClients(client c);
|
||||||
|
@ -90,6 +90,8 @@ int spectrum_palette_mono[] = {0,233,234,235,237,239,241,243,245,247,249,251,253
|
|||||||
int *spectrum_palette;
|
int *spectrum_palette;
|
||||||
int spectrum_palette_size;
|
int spectrum_palette_size;
|
||||||
|
|
||||||
|
int g_fInCrash = false;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Utility functions
|
* Utility functions
|
||||||
*--------------------------------------------------------------------------- */
|
*--------------------------------------------------------------------------- */
|
||||||
|
@ -2797,7 +2797,7 @@ void xorDigest(unsigned char *digest, const void *ptr, size_t len);
|
|||||||
int populateCommandTableParseFlags(struct redisCommand *c, const char *strflags);
|
int populateCommandTableParseFlags(struct redisCommand *c, const char *strflags);
|
||||||
|
|
||||||
int moduleGILAcquiredByModule(void);
|
int moduleGILAcquiredByModule(void);
|
||||||
extern bool g_fInCrash;
|
extern int g_fInCrash;
|
||||||
static inline int GlobalLocksAcquired(void) // Used in asserts to verify all global locks are correctly acquired for a server-thread to operate
|
static inline int GlobalLocksAcquired(void) // Used in asserts to verify all global locks are correctly acquired for a server-thread to operate
|
||||||
{
|
{
|
||||||
return aeThreadOwnsLock() || moduleGILAcquiredByModule() || g_fInCrash;
|
return aeThreadOwnsLock() || moduleGILAcquiredByModule() || g_fInCrash;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user