2018-05-26
2018-05-26 09:30:31 by Stephen R. van den Berg <srb@cuci.nl>
-
e7efba79d447bfb31213b1a6482ac8883314efc0
(10 lines)
(+5/-5)
[
Show
| Annotate
]
Branch: master
pgsql: Delay started() lock release to prevent early unlock by sendcmd().
516: Inside #if defined(PG_DEBUGRACE)
PD("Nostash locked by %s\n",
describe_backtrace(nostash->current_locking_thread()->backtrace()));
#endif
- while (lock = (waitforreal ? nostash->lock : nostash->trylock)(1)) {
+ if (lock = (waitforreal ? nostash->lock : nostash->trylock)(1)) {
stashcount->wait_till_drained();
#ifdef PG_DEBUGRACE
conxsess sess = conxsess(this);
#endif
- started = lock;
- lock = 0; // Release often, release early
+
int mode;
if (sizeof(stash) && (mode = getstash(KEEP)) > KEEP)
- sendcmd(mode); // Force out stash to the server
+ sendcmd(mode); // Force out stash to the server
+ started = lock; // sendcmd() clears started, so delay assignment
#ifdef PG_DEBUGRACE
return sess;
#else
612:
}
} while (0);
started = 0;
- if (sizeof(stash) && (started = nostash->trylock(1))) {
+ if (sizeof(stash) && (started = nostash->trylock(2))) {
#ifdef PG_DEBUGRACE
conxsess sess = conxsess(this);
sess->sendcmd(SENDOUT);