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

Abierto Apto para principiantes
#5,983 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, shell
Área
backend, devops

Línea de trabajo

Empieza por www/squid/src/opnsense/service/conf/actions.d/actions_proxy.conf y sigue cómo su acción de detención invoca el script rc de Squid y killall. Comprueba el comportamiento de detención del script rc y cómo la acción puede esperar dentro de un límite de tiempo a que Squid termine. Después, verifica que un configctl proxy start inmediato se ejecute correctamente tras la detención. La tarea está completa cuando la detención espera a que el proceso termine o alcanza un límite y lo fuerza a terminar antes de regresar.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
PHP
Estrellas
1.2k
Forks
932
Merge medio
1 d 11 h
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de opnsense/plugins

Todos los issues de opnsense/plugins

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.