Skip to content

Commit

Permalink
powermand: fix assertion failure on teardown
Browse files Browse the repository at this point in the history
Problem: an assertion failure is seen when powermand tears
down with a tcp-connected device:

powermand: device_tcp.c:266: tcp_disconnect:
  Assertion `dev->magic == DEV_MAGIC' failed.

This is because dev_destroy sets dev->magic = 0 before it calls
dev->disconnect.  When dev->disconnect points to tcp_disconnect()
the assertion triggers.

Fixes #106
  • Loading branch information
garlick committed Feb 4, 2024
1 parent a6f30a9 commit 5b58a03
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/powerman/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,6 @@ void dev_destroy(Device * dev)
int i;

assert(dev->magic == DEV_MAGIC);
dev->magic = 0;

if (dev->connect_state == DEV_CONNECTED)
dev->disconnect(dev);
Expand All @@ -1327,6 +1326,7 @@ void dev_destroy(Device * dev)
cbuf_destroy(dev->to);
cbuf_destroy(dev->from);
xregex_match_destroy(dev->xmatch);
dev->magic = 0;
xfree(dev);
}

Expand Down

0 comments on commit 5b58a03

Please sign in to comment.