Closed
Description
Describe the bug
This is a really weird one. Sometimes the dinitctl enable
get stuck after the "enabled" message.
To Reproduce
- Have a minimal service set (including
boot
andboot.d
) - Add a fail-fast service (for example a service with non-exist executable path).
- Create a loop with disable and enable:
#!/bin/sh
SERVICE="srv"
SOCKET="/tmp/dinitctl"
i=0
while :; do
i=$(( i + 1 ))
echo $i
dinitctl disable "$SERVICE" --socket-path "$SOCKET"
dinitctl enable "$SERVICE" --socket-path "$SOCKET"
done
- It will stuck after a random number of tries.
Expected behavior
It should not stuck.
Additional context
The dinitctl enables a service with this process:
- dinitctl loads a service
- dinitctl finds a
waits-for.d
and add the service in that directory - dinitctl starts the service
- dinitctl checks the current state of service with
SERVICESTATUS
command - dinit responds.
- if the status of service wasn't something that dinitctl expects, run
wait_service_state()
- Report the success or failure.
The problem is dinitctl expects a SERVICEEVENT
but sometimes it's missing and dinitctl will stuck on read()
syscall (int r = rbuffer.fill_to(socknum, 2);
).