diff mbox series

[ovs-dev] ovs-lib.in: Cleanup old socket and pidfiles in stop_daemon

Message ID 1ade75d3bd8462416a2081223b2eb35e02660a89.1549902173.git.tredaelli@redhat.com
State Accepted
Headers show
Series [ovs-dev] ovs-lib.in: Cleanup old socket and pidfiles in stop_daemon | expand

Commit Message

Timothy Redaelli Feb. 11, 2019, 4:22 p.m. UTC
Currently if a client crashes (signal 11) the unix socket (.ctl) and the
pidfile may not be deleted when you use ovs-ctl stop or restart.

Moreover since ovs-appctl is used on a closed socket some warnings are
printed.

This commit deletes the pidfile and the unix socket then returns without
running ovs-appctl if the pidfile point to a not-existing pid.

Reported-at: https://bugzilla.redhat.com/1667845
Reported-by: Candido Campos <ccamposr@redhat.com>
Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 utilities/ovs-lib.in | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ben Pfaff Feb. 11, 2019, 4:44 p.m. UTC | #1
On Mon, Feb 11, 2019 at 05:22:53PM +0100, Timothy Redaelli wrote:
> Currently if a client crashes (signal 11) the unix socket (.ctl) and the
> pidfile may not be deleted when you use ovs-ctl stop or restart.
> 
> Moreover since ovs-appctl is used on a closed socket some warnings are
> printed.
> 
> This commit deletes the pidfile and the unix socket then returns without
> running ovs-appctl if the pidfile point to a not-existing pid.
> 
> Reported-at: https://bugzilla.redhat.com/1667845
> Reported-by: Candido Campos <ccamposr@redhat.com>
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>

Thanks.  I applied this to master.
diff mbox series

Patch

diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 9a0af2e82..fa840ec63 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -235,6 +235,10 @@  start_daemon () {
 stop_daemon () {
     if test -e "$rundir/$1.pid"; then
         if pid=`cat "$rundir/$1.pid"`; then
+            if pid_exists "$pid" >/dev/null 2>&1; then :; else
+                rm -f $rundir/$1.$pid.ctl $rundir/$1.$pid
+                return 0
+            fi
 
             graceful="EXIT .1 .25 .65 1"
             actions="TERM .1 .25 .65 1 1 1 1 \