www/squid: configctl proxy stop returns before Squid exits, so stop+start (e.g. Monit restart) fails

オープン 初心者向け
#5,983 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, shell
領域
backend, devops

調査の方向性

www/squid/src/opnsense/service/conf/actions.d/actions_proxy.confから始め、その停止アクションがSquidのrcスクリプトとkillallをどのように呼び出すかを追ってください。rcスクリプトの停止時の動作と、アクションが制限時間内にSquidの終了を待てる方法を確認してください。その後、停止直後にconfigctl proxy startを実行して成功することを検証してください。停止が終了を待つか、戻る前に制限時間付きの強制終了に至れば完了です。

索引モデルが issue の本文から書いたものです。

説明

support

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug
configctl proxy stop returns before Squid has exited. A start issued right after it (for example by a Monit service check that runs stop then start) launches a new Squid while the old one is still shutting down and holding its ports, so the new instance fails and the proxy stays down until something starts it again.

The [stop] action in www/squid/src/opnsense/service/conf/actions.d/actions_proxy.conf is:

/usr/local/etc/rc.d/squid stop;
/usr/bin/killall squid;
/usr/local/sbin/pluginctl -c webproxy stop;
exit 0

Squid's graceful shutdown waits up to shutdown_lifetime (30 s by default, not set in the generated squid.conf), and nothing in the action waits for the process to exit. In our case configctl proxy stop returned right away while Squid kept shutting down for roughly 30 seconds.

This matters most when the proxy is transparent: with port-forward rules pointing HTTP/HTTPS at Squid, every stop-then-start that loses this race means a client-facing web outage.

To Reproduce

  1. Enable the web proxy (transparent HTTP/HTTPS is where it hurts).
  2. Run configctl proxy stop; configctl proxy start.
  3. pgrep squid right after stop still shows the old Squid for up to ~30 s; the start fails (ports in use / pid still present) and the proxy is not running afterwards.
  4. Same result with a Monit service for Squid using configctl proxy stop / configctl proxy start and a connection test with "restart" as action.

Expected behavior
configctl proxy stop returns only after Squid has exited (or after a bounded wait, then a hard kill), so a following start is reliable.

Suggested fix
Wait for the Squid processes to exit before returning, for example after the existing killall:

i=0; while pgrep -qx squid && [ $i -lt 40 ]; do sleep 1; i=$((i+1)); done
pgrep -qx squid && /usr/bin/killall -9 squid

(or make the rc script's stop wait for the pid). Setting a shorter shutdown_lifetime alone would only narrow the window.

Additional context
We worked around it with a Monit stop script that runs configctl proxy stop, waits up to 50 s for the process to exit, then kills it. With that, restarts are reliable (~40 s round trip). configctl proxy restart is not a substitute in Monit because it fails when Squid is not running.

Environment
OPNsense 26.7.10 (amd64), os-squid 1.5_1, squid 7.7. The [stop] action on master is unchanged.

主要言語
PHP
スター
1.2k
フォーク
932
平均マージ
1日 11時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opnsense/plugins のほかの issue

opnsense/plugins の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。