Hey Guys, I have tried to implement this dynamic thing to regex_policy plugin. In reference to my talk with Henrik yesterday, we discussed that there could be a autoreload variable, and when made true it will continuously poll for changes in default regex policy file. And it it is made false, it will stop polling, checking for modifications. Sticking to the discussion, the code I wrote is
void autoReload_Regex_Policy(Session *, sql_var_t) { if(policy->sysvar_autoreload) { while(1) { if (not policy->loadFile()) { errmsg_printf(error::ERROR, _("Could not load regex policy file: %s\n"), (policy ? policy->getError().str().c_str() : _("Unknown"))); return; } sleep(60); if(!policy->sysvar_autoreload) break; } } else { } } This function handles the case when you change the value of autoreload from drizzle client. The problem is as the function is using sleep recursively, when trying to change autoreload value by "SET GLOBAL", the client hangs. This is obviously due to function recursive structure. Initially, I thought that it would change the variable and then polls. Now, coming to the discussion earlier in this mail, even if I create a pthread from this function which will check for modification using stat() or inotify(), this function won't exit untill its thread stop working. And as thread will continuously polls for changes, it wont exit. Is there any solution for this scenario, except adding the refresh command for refreshing the policy file? On Fri, Mar 30, 2012 at 10:34 PM, Clint Byrum <cl...@fewbar.com> wrote: > Excerpts from Henrik Ingo's message of Thu Mar 29 21:16:26 -0700 2012: > > Daniel: > > > > Have you thought about authorization for this? I mean we wouldn't want > > any old logged in user to be able to > > > > SET GLOBAL auth_file.users=/home/hingo/igivemyselfrootpowers.users > > > > (Making the plugin reload the existing file will be helpful. But it > > might not be a good idea to allow to change that value.) > > > > Agreed. I'd like to see plugins like auth_file and regex_policy given > a generic way to "watch" their files. There are a number of ways to do > this, but I don't think each plugin should implement its own method. > > Thoughts I've had on this: > > * A thread which uses either inotify or falls back to polling > with stat(), and whenever there is a change, calls any registered code > to update that file's effect. > > * An admin command like REFRESH '/etc/drizzle/regex.policy' which does > the same thing as the thread without the inotify/polling. > > * Cache the stat() call on the file and periodically expire the cache > and refresh the contents if stat() indicates that it has changed. > > _______________________________________________ > Mailing list: https://launchpad.net/~drizzle-discuss > Post to : drizzle-discuss@lists.launchpad.net > Unsubscribe : https://launchpad.net/~drizzle-discuss > More help : https://help.launchpad.net/ListHelp > -- Regards, Ansh
_______________________________________________ Mailing list: https://launchpad.net/~drizzle-discuss Post to : drizzle-discuss@lists.launchpad.net Unsubscribe : https://launchpad.net/~drizzle-discuss More help : https://help.launchpad.net/ListHelp