mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-11 07:34:59 +03:00
fix(hwid): serialize the device-limit write with its trim (#6591)
setClientLimitHwidByEmail wrote clients.limit_hwid and then trimmed client_hwids as two independent statements. A traffic-cycle Save that read the record before the limit changed could write the stale value back after it, and a failed trim committed the new limit anyway. Both halves now run inside runSerializedTx, the transaction the traffic writer already owns. setClientLimitHwidByEmailTx and clearClientHwidsBySubIDTx refuse a handle that is not that transaction (errClientHwidWriteNotSerialized) instead of falling back to the shared handle. Client delete moves onto the same writer, and BulkCreate withdraws a re-created client's tombstone before applying its optional HWID limit. TestSetClientLimitHwidIsSerializedWithSyncInbound holds a stale traffic-cycle Save open across the limit change and fails without the serialization (limit_hwid = 5, want 1).
This commit is contained in:
@@ -153,7 +153,7 @@ func TestClientHwidGateRegistersAndBlocks(t *testing.T) {
|
||||
t.Fatalf("updated HWID metadata missing: %#v", list)
|
||||
}
|
||||
|
||||
if err := svc.setClientLimitHwidByEmail(nil, rec.Email, 1); err != nil {
|
||||
if err := svc.setClientLimitHwidByEmail(rec.Email, 1); err != nil {
|
||||
t.Fatalf("lower limit: %v", err)
|
||||
}
|
||||
var count int64
|
||||
|
||||
Reference in New Issue
Block a user