ywkaras commented on a change in pull request #6980: URL: https://github.com/apache/trafficserver/pull/6980#discussion_r453105732
########## File path: plugins/experimental/maxmind_acl/maxmind_acl.cc ########## @@ -0,0 +1,114 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "mmdb.h" + +static int +config_handler(TSCont cont, TSEvent event, void *edata) +{ + TSMutex mutex; + + mutex = TSContMutexGet(cont); + TSMutexLock(mutex); + + TSDebug(PLUGIN_NAME, "In config Handler"); + Acl *a = static_cast<Acl *>(TSContDataGet(cont)); + + a->init(a->get_state()->config_file.c_str()); + TSMutexUnlock(mutex); + + // Don't reschedule for TS_EVENT_MGMT_UPDATE + if (event == TS_EVENT_TIMEOUT) { + TSContScheduleOnPool(cont, CONFIG_TMOUT, TS_THREAD_POOL_TASK); Review comment: This seems really wrong. I think what this function should simply look like is: ``` static int config_handler(TSCont cont, TSEvent event, void *edata) { TSDebug(PLUGIN_NAME, "In config Handler"); Acl *a = static_cast<Acl *>(TSContDataGet(cont)); a->init(a->get_state()->config_file.c_str()); return 0; } ``` It looks like ConfigUpdateCallback::event_handler() will execute this continuation function if it can lock the mutex. If it can't, it will schedule the continuation with a 10 millisecond delay. After the delay, the event system will keep retrying to lock the mutex. When it succeeds in locking the mutex, the continuation function will be executed. I don't think the continuation function needs to have any retry logic of its own. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
