| Age | Commit message (Collapse) | Author | Lines |
|
Two gboolean (gint) fields cost 8 padded bytes plus alignment per
wrapper. Each wrapper only needs two bits, so use unsigned:1
bitfields instead. struct rspamd_lua_upstream shrinks from 24 to
16 bytes on 64-bit targets.
No behaviour change.
|
|
Lua plugin code can drop a get_upstream_*() wrapper without ever
calling :ok or :fail (e.g. when an async callback never fires or is
written incorrectly). Without retirement, the C-side inflight counter
introduced for P2C scoring leaks indefinitely and biases selection
away from the affected upstream.
Add acquired/retired bookkeeping on the Lua wrapper:
- lua_push_upstream() takes an explicit acquired flag. The three
get_upstream_* bindings pass TRUE; all_upstreams() inserter passes
FALSE since it returns a view, not a fresh inflight reference.
- The watcher path inlines lua_newuserdata; explicitly zero the new
fields there so uninitialised stack memory doesn't trigger spurious
retire calls.
- :ok and :fail set retired = TRUE so the destructor doesn't double
retire when the caller did pair properly.
- The __gc destructor calls rspamd_upstream_release when
acquired && !retired, decrementing inflight without affecting error
counts or latency.
Lua GC is non-deterministic, so retirement may lag for some time;
that's acceptable noise for a load comparator and strictly better
than an unbounded leak.
Tests in test/lua/unit/upstream.lua cover smoke-level API usage,
the abandoned-wrapper path, view safety from all_upstreams(), and
double-retirement protection.
|
|
The PENDING_RESOLVE upstream state introduced earlier kept pending
entries out of the alive list, but `:all_upstreams()` walks the full
`ups` array and exposes them to Lua callers - which then crashed in
`s:get_addr()` because `rspamd_upstream_addr_next/cur/port` indexed
a NULL `addrs.addr`.
Defensive fix at the C accessor layer:
* rspamd_upstream_addr_next / _cur now return NULL when the upstream
has no addresses (NULL or empty array). This is the safe layer that
every other consumer eventually goes through.
* rspamd_upstream_port returns the parsed `deferred_port` for pending
upstreams (so callers that just want a port get a sensible answer)
and -1 if even that is unknown.
* lua_upstream:get_addr() pushes nil when the C side has no address.
Audit of `:all_upstreams()` callers, all updated to skip pending:
* lua_redis prepare_redis_call (SCRIPT LOAD broadcast): if
`s:get_addr()` is nil, mark the slot as "tempfail" so the next
retry will pick it up once DNS comes back, log, and skip it.
* rspamadm statistics_dump connect_to_upstream: log and return early
before opening a redis connection with a nil host.
* clickhouse plugin check_clickhouse_upstream: skip with an info log
so the periodic check tries again next tick.
The DKIM Vault helper already passes `upstream = ... or nil` to
http.request and lets the HTTP layer fall back to URL-based connect,
which remains the right behaviour.
|
|
|
|
|
|
No meaningful changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LuaJIT limits lightuserdata usage to 47 bits. On Arm64, this leads to
break of the C <-> Lua interoperability using this type.
This rework has changed traceback function behaviour from lightuserdata
opaque pointer (GString * in particular) to luaL_Buffer.
Issue: #2906
|
|
Previously, upstream.get_addr function returned the new address of the
upstream. Unfortunately, it was used for printing addresses. It caused
the following situation: let's imagine we have A1 and A2 where A1 was
initially selected. So the connection was performed to A1:
Current addr Selected addr
Connect+---------+ A2+------>A1 A1
|
+-+Print failure<---+ A1+------>A2 A2
| +----+
+->Mark failure+-------->+ A2 |
+----+
But the failure OP as well as log message told about `A2` where the real
problem happened with `A1`.
This commit adds distinguishing between getting the next and the current
address of the upstream resolving this issue.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This reverts commit e0483657ff6cf1adc828ccce457814d61fe90a0d.
|
|
|
|
|
|
|
|
|
|
|
|
* Add lua utility library for basic utils.
* Fixes lua_buffer code.
Fix lua loading error.
Added some other lua utility functions.
|
|
Some polishing of lua task api.
|
|
|