Luci function Map.on_after_commit being called before commit has finshed being written to disk

Has anyone got any information or thoughts in this one.

I have been trying to get luci-access-control to work on the latest release and I have had to make an ugly one hack to get it too work properly.
/usr/sbin/inetacd.lua is called by

function mr.on_after_commit (self)
    os.execute("/init.d/inetac restart >/dev/null 2>dev/null")
end

Where mr is a luci Map object.
Unfortunately on the wrt1900acs v2 router I am testing this it appears that /usr/sbin/inetacd.lua executes before the config file changes have actually finished being written to disk.
I suspect this is a multi-processor/multi-threading concurrency problem.
My ugly hack is to put a 5 second sleep at the start of inetacd.lua. This works.
So is Luci thread safe? Is there a better way to fix this?
Thoughts anyone.

Roger

The safest way would be to add procd_add_reload_trigger "foo" to /etc/init.d/inetac where foo refers to the /etc/config/foo file used. This way procd takes care of properly restarting the service when the underlying uci config gets changed. After that, you can remove the on_after_commit hook completely.

Thanks Jo-Philipp,

I will give that a try. It looks much cleaner.

I am not familiar with either lua the language or the openwrt luci implementation. There does not seem much point in having an on_after_commit hook function where the callback is called before the condition is true.

Roger