Ensure pipeline is locked during authentication phase
This commit is contained in:
parent
137422601b
commit
6f9e9770cf
18
wire.ts
18
wire.ts
@ -8,7 +8,6 @@ import {
|
||||
from_utf8,
|
||||
jit,
|
||||
semaphore,
|
||||
semaphore_fast,
|
||||
to_base64,
|
||||
to_utf8,
|
||||
TypedEmitter,
|
||||
@ -684,8 +683,8 @@ function wire_impl(
|
||||
}
|
||||
|
||||
// https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-PIPELINING
|
||||
const rlock = semaphore_fast();
|
||||
const wlock = semaphore_fast();
|
||||
const rlock = semaphore();
|
||||
const wlock = semaphore();
|
||||
|
||||
function pipeline<T>(
|
||||
w: () => void | PromiseLike<void>,
|
||||
@ -697,8 +696,8 @@ function wire_impl(
|
||||
});
|
||||
}
|
||||
|
||||
function pipeline_read<T>(r: () => T | PromiseLike<T>) {
|
||||
return rlock(async function pipeline_read() {
|
||||
async function pipeline_read<T>(r: () => T | PromiseLike<T>) {
|
||||
using _rlock = await rlock();
|
||||
try {
|
||||
return await r();
|
||||
} finally {
|
||||
@ -710,11 +709,10 @@ function wire_impl(
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function pipeline_write<T>(w: () => T | PromiseLike<T>) {
|
||||
return wlock(async function pipeline_write() {
|
||||
async function pipeline_write<T>(w: () => T | PromiseLike<T>) {
|
||||
using _wlock = await wlock();
|
||||
try {
|
||||
return await w();
|
||||
} finally {
|
||||
@ -724,11 +722,13 @@ function wire_impl(
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-START-UP
|
||||
async function auth() {
|
||||
using _rlock = await rlock();
|
||||
using _wlock = await wlock();
|
||||
|
||||
await write(StartupMessage, {
|
||||
version: 196608,
|
||||
params: {
|
||||
|
Loading…
Reference in New Issue
Block a user