Re: [PATCH] OAuth: fix performance bug with stuck multiplexer events
Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Jacob Champion <jacob.champion@enterprisedb.com>
Cc: Thomas Munro <thomas.munro@gmail.com>, PostgreSQL Hackers
<pgsql-hackers@lists.postgresql.org>, Daniel Gustafsson
<daniel@yesql.se>, Peter Eisentraut <peter@eisentraut.org>
Date: 2025-08-08T21:16:22Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
oauth: Always link with -lm for floor()
- e76738e59790 18.0 landed
- 52ecd05aeef8 19 (unreleased) landed
-
oauth: Add unit tests for multiplexer handling
- 4e1e417330d4 19 (unreleased) landed
- 1443b6c0eaa2 19 (unreleased) landed
-
oauth: Ensure unused socket registrations are removed
- 16b0c48583a5 18.0 landed
- 3d9c03429a82 19 (unreleased) landed
-
oauth: Remove expired timers from the multiplexer
- e507e08acf63 18.0 landed
- 1749a12f0d20 19 (unreleased) landed
-
oauth: Remove stale events from the kqueue multiplexer
- ff181d1f876f 18.0 landed
- ff5b0824b3b0 19 (unreleased) landed
-
oauth: Track total call count during a client flow
- 41aac1483a6c 18.0 landed
- 3e311664e497 19 (unreleased) landed
Jacob Champion <jacob.champion@enterprisedb.com> writes:
> On Fri, Aug 8, 2025 at 1:07 PM Dagfinn Ilmari Mannsåker
> <ilmari@ilmari.org> wrote:
>> $ perl -MJSON::PP=encode_json -E 'say encode_json([1, 2, 3])'
>> [1,2,3]
>>
>> $ perl -MJSON::PP=encode_json -E 'say encode_json([1 => (2, 3)])'
>> [1,2,3]
>
> I swear, this language.
>
> But:
>
> $ perl -MJSON::PP=encode_json -E 'say encode_json(1,2)'
> Too many arguments for JSON::PP::encode_json at -e line 1, near "2)
> $ perl -MJSON::PP=encode_json -E 'say encode_json((1,2))'
> 2
>
> So what's going on there? (Google is not very helpful for these sorts
> of Perl problems; I don't even know how to describe this.)
That's because encode_json has a prototype[1], which changes how the
argument list is parsed: no longer just as a flat list of values like a
normal function. Specifically, it has a prototype of '$', which means
it only takes one argument, which is evaluated in scalar context. So
the first example is a syntax error, but in the second example the
parenthesised expression is the single argument. Becuse it's in scalar
context, the comma is actually the scalar comma operator, not the list
element separator, so the return value is the right-hand side of the
comma (just like in C), not the length of the would-be list.
Onfusingly, they are both 2 here (which is why 1,2,3,... are bad values
to use when exploring presedence/context issues in Perl, sorry for doing
that in my example). More clearly (fsvo):
$ perl -MJSON::PP=encode_json -E 'say encode_json((11,12))'
12
- ilmari
[1] https://perldoc.perl.org/perlsub#Prototypes