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

Đang mở Phù hợp với người mới
#5,983 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
70/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php, shell
Lĩnh vực
backend, devops

Hướng nghiên cứu

Bắt đầu với www/squid/src/opnsense/service/conf/actions.d/actions_proxy.conf và lần theo cách hành động dừng gọi script rc của Squid và killall. Kiểm tra cách script rc xử lý việc dừng và cách hành động có thể chờ Squid thoát trong một khoảng thời gian giới hạn. Sau đó, xác minh rằng lệnh configctl proxy start chạy ngay sau khi dừng thành công. Công việc hoàn tất khi thao tác dừng chờ tiến trình thoát hoặc đạt đến giới hạn thời gian và buộc tiến trình dừng trước khi trả về.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
1.2k
Fork
932
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opnsense/plugins

Tất cả issue của opnsense/plugins

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.