Shadowing special variables in threaded handlers

Duncan Bayne duncan at bayne.id.au
Sat Jan 1 00:21:06 UTC 2022


Stelian Ionescu writes:

> The whole point of special variables is to make it oblivious whether
> one is using the global binding or a thread-local binding, so code
> shouldn't be aware of that in general.

Attached is the patch I went with courtesy you and Chun Tian - it works
very nicely, thank you both :)

In summary, the approach I took was:

 1. Use a helper to create a handler closure that closes over the
 shadowed variables, thereby making the correct values available on all
 threads.

 2. Add the root path to the request class, conceptually treating
 requests as relative to a particular root, and handily avoiding the
 same threading + shadowed variable issue with *germinal-root*.

Now I can set a temporary context in my tests with a let form, and the
world is a happier place :)

Happy New Year :)

--
Duncan Bayne
+61 420 817 082 | https://duncan.bayne.id.au/

I usually check my mail every 24 - 48 hours.  If there's something
urgent going on, please send me an SMS or call me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Honor-shadowed-config-variables.patch
Type: text/x-diff
Size: 6619 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/usocket-devel/attachments/20220101/c630d091/attachment.patch>


More information about the usocket-devel mailing list