What's new

Addon page suppresses Dnsmasq restart

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

thelonelycoder

Part of the Furniture
I have a peculiar problem which I can reproduce on 384.17.
When Changing a state through the Diversion WebUI, the following relevant events are logged in syslog:
Code:
rc_service: httpd 6400:notify_rc restart_diversion
custom_script: Running /jffs/scripts/service-event (args: restart diversion)
Diversion: WebUI action, ad-blocking state changed to off
rc_service: service 21086:notify_rc restart_dnsmasq
rc_service: waitting "restart_diversion" via httpd ...
rc_service: skip the event: restart_dnsmasq.

The httpd requests service restart_diversion which runs a Diversion file that sets the new state of services, then issues a restart of Dnsmasq.
But that request is skipped over and consequently leaves Diversion in a state where the service is disabled in its settings, but the changes are not written to dnsmasq.conf.

Is there any way I can force a service restart_dnsmasq?
I have lowered the httpd wait time to 4 and 1 secs in the page: <input type="hidden" name="action_wait" value="4">
Still no luck.
@RMerlin ?
 
I found it is too recursive to issue a service restart command when in a script (service-event) that is blocking an existing service start/restart command from completing.
 
You might consider issuing "restart_diversion;restart_dnsmasq" from your page in parallel, and use dnsmasq.postconf to read the new settings from custom_settings. It's what I ended up doing in one of my pages.
 
You might consider issuing "restart_diversion;restart_dnsmasq" from your page in parallel, and use dnsmasq.postconf to read the new settings from custom_settings. It's what I ended up doing in one of my pages.
This will not work for me. I first have to set the states in Diversion before I can issue a Dnsmasq restart, they can be complicated with pixelserv-tls and other services Diversion offers.
Doing a Dnsmasq restart through the webui would trigger it without those sertings written to its config file.
 
This will not work for me. I first have to set the states in Diversion before I can issue a Dnsmasq restart, they can be complicated with pixelserv-tls and other services Diversion offers.
Doing a Dnsmasq restart through the webui would trigger it without those sertings written to its config file.
I don't know if it would make a difference, but what if you catch "restart_diversion" in service-event-end instead of service-event?
 
I don't know if it would make a difference, but what if you catch "restart_diversion" in service-event-end instead of service-event?
Ah, let me check that.
But one problem still remains: When Diversion writes its config file, the associated states are written to custom_settings.txt, which then are reflected when the web page refreshes.
This would not work wit that event-end script.
 
Since restart_diversion is taking too long and tripping the timer to skip dnsmasq, it it possible to break the diversion restart into two pieces....

diversion1 calls diversion2 calls dnsmasq

Maybe have diversion2 wait for some event before continuing....
 
Since restart_diversion is taking too long and tripping the timer to skip dnsmasq, it it possible to break the diversion restart into two pieces....

diversion1 calls diversion2 calls dnsmasq
But after 1 or 0 secs "spinning wait" it should still do the job.
I might just run a delayed separate script that runs after 5 secs or so.
 
I need to double check....but I think the 'skip' timer is 15sec....so the router doesn't think that diversion has completed by then...
 
I need to double check....but I think the 'skip' timer is 15sec....so the router doesn't think that diversion has completed by then...
What is that timer for then, can we add that separate timeout somehow to the page?
 
I need to double check....but I think the 'skip' timer is 15sec....so the router doesn't think that diversion has completed by then...
That syslog action posted above only takes about 1 second for Diversion to process.
 
notify_rc is closed source in Merlin now, but in John's fork you can see it's waiting for the previous service command to finish before processing the next. But in service-event, you're blocking the previous event from finishing (restart_diversion) because you're waiting for restart_dnsmasq to run from within restart_diversion.

https://github.com/john9527/asuswrt...ate/release/src/router/shared/notify_rc.c#L89

It messes with your head. Until the rc_service and rc_service_pid nvram get cleared, I think it's never going to complete. Even service-event-end runs before the nvram is cleared.

It's a 25 second wait in John's fork.

Try forking service restart_dnsmasq?
 
OK, with a 10 sec delayed forked job it works, but it leaves a stale taste in my mouth. I am not happy that way.
It would mean I'd have three states to consider, the webui, Diversion settings file and Dnsmasq.
I might just abandon that WebUI project if there's no better way, too much work for not much gain.
 
Would
Code:
exec service restart_dnsmasq
work? I haven't tested it myself, away from router
Nope: rc_service: skip the event: restart_dnsmasq.
 
I think it's worth testing restart_diversion;restart_dnsmasq because it looks like they are processed sequentially in services.c ("goto again").
Diversion is - lets say - complicated with how certain events are executed. Which means I cannot have the web page issue a Dnsmasq restart.
It all has to run in precise order and only Diversion itself can handle that sequence properly.
 
Diversion is - lets say - complicated with how certain events are executed. Which means I cannot have the web page issue a Dnsmasq restart.
It all has to run in precise order and only Diversion itself can handle that sequence properly.

Uh oh. Something tells me your weekend is going to get eaten up by this. But we’ll benefit from the resulting update...somehow and eventually.
Go team!


Sent from my iPhone using Tapatalk
 
Looks like if I set <input type="hidden" name="action_wait" value="10"> and a delayed Dnsmasq by also 10 secs it works.
Or would that trigger a cat and mouse game down the road?
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top