2018-05-26
2018-05-26 09:32:52 by Stephen R. van den Berg <srb@cuci.nl>
-
9c553a6cf66d9f999f0c5bdb703bdc0cff1018a0
(10 lines)
(+5/-5)
[
Show
| Annotate
]
Branch: 8.0
pgsql: Delay started() lock release to prevent early unlock by sendcmd().
468: 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
564:
}
} 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);