From 9c5e477fa80c674649c255a62efdcedafde05267 Mon Sep 17 00:00:00 2001 From: Bjarne von Horn Date: Wed, 22 Nov 2023 16:18:01 +0100 Subject: [PATCH] Avoid race condition when starting master By first removing the non-native driver module and then checking for success. It's better to ask for forgiveness than to ask for permission. --- script/ethercatctl.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script/ethercatctl.in b/script/ethercatctl.in index ab3f45a8..7516b42d 100755 --- a/script/ethercatctl.in +++ b/script/ethercatctl.in @@ -126,12 +126,12 @@ start) fi if [ "${MODULE}" != "generic" ] && [ "${MODULE}" != "ccat" ]; then - # try to unload standard module + # unload standard module and check if unloading was successful + ${RMMOD} "${MODULE}" 2> /dev/null || true if ${LSMOD} | grep "^${MODULE} " > /dev/null; then - if ! ${RMMOD} "${MODULE}"; then - ${RMMOD} ${LOADED_MODULES} - exit 1 - fi + # could not unload module + ${RMMOD} ${LOADED_MODULES} + exit 1 fi fi