v0.8.1

sleep3r/mtproto.zigv0.8.1Apr 7, 2026by sleep3r

Upgrading?

AI Summary

Fixes a critical bug causing CPU spikes and slot leaks during client disconnection.

Key Highlights

  • Fixes slot leak when client disconnects during `connecting_upstream`
  • Eliminates epoll busy-loop and CPU spikes
  • Added regression test for the fix
  • Updated Android evidence base

New Features

  • Bug fix for connection handling

Full Release Notes

## [0.8.1](https://github.com/sleep3r/mtproto.zig/compare/v0.8.0...v0.8.1) (2026-04-07)

### 🇷🇺 Release notes (RU)

**Проблемы, которые решает этот релиз**
- В редком, но критичном сценарии прокси мог не закрывать слот, если клиент разрывал соединение во время `connecting_upstream`.
- В этом случае возможен epoll busy-loop и всплеск утилизации CPU под connect/disconnect churn.

**Что исправлено и улучшено**
- **Точечная обработка fatal hangup**: во время `connecting_upstream` исключение применяется только к `upstream_fd` (ожидаемый `connect` error path), а `client_fd` теперь корректно закрывает слот.
- **Закрыт источник CPU spin**: client-side `EPOLLRDHUP/HUP/ERR` больше не оставляет зависшие слоты в цикле событий.
- **Добавлен регрессионный тест**: проверяет различие политики закрытия для `client_fd` и `upstream_fd` в `connecting_upstream`; без фикса тест падает.
- **Обновлена Android evidence-база в `.agent`**: ссылки в `client-behavior` обновлены на актуальный snapshot Telegram Android (`master`, commit `009e973...`).

**Важно**
- Релиз рекомендуется всем, кто наблюдал периодические CPU spikes при высоком churn подключений.
- Изменение обратно-совместимо по конфигу и не требует тюнинга параметров.

**Благодарности**
- Отдельное спасибо **@va4st** — помог закрыть этот баг в реальном продовом сценарии.

### 🇬🇧 Release notes (EN)

**Problems addressed in this release**
- In a rare but critical scenario, the proxy could keep a slot open when the client disconnected during `connecting_upstream`.
- This could cause an epoll busy-loop and CPU spikes under heavy connect/disconnect churn.

**What is fixed and improved**
- **Precise fatal hangup handling**: during `connecting_upstream`, the exception is now scoped to `upstream_fd` only (expected connect error path), while `client_fd` hangups close the slot immediately.
- **CPU spin source removed**: client-side `EPOLLRDHUP/HUP/ERR` no longer leaves stale slots in the event loop.
- **Regression test added**: verifies close-policy distinction between `client_fd` and `upstream_fd` in `connecting_upstream`; it fails without this fix.
- **Android evidence docs refreshed in `.agent`**: `client-behavior` links were updated to the current Telegram Android snapshot (`master`, commit `009e973...`).

**Important**
- This release is recommended for operators seeing periodic CPU spikes under high connection churn.
- The change is config-compatible and requires no parameter retuning.

**Acknowledgements**
- Special thanks to **@va4st** for helping close this bug in a real production scenario.

---

### Bug Fixes

* **proxy:** close slots on client hangup during upstream connect ([#84](https://github.com/sleep3r/mtproto.zig/issues/84)) ([353a9c4](https://github.com/sleep3r/mtproto.zig/commit/353a9c49c3c7f973e5f22326e926005913064c23))
* **docs(agent):** refresh Android client behavior sources to current Telegram Android snapshot (`009e973...`) ([353a9c4](https://github.com/sleep3r/mtproto.zig/commit/353a9c49c3c7f973e5f22326e926005913064c23))

---

This PR is managed by Release Please.

Related Repositories