ywkaras commented on a change in pull request #7281:
URL: https://github.com/apache/trafficserver/pull/7281#discussion_r510247738



##########
File path: plugins/s3_auth/s3_auth.cc
##########
@@ -897,6 +980,74 @@ event_handler(TSCont cont, TSEvent event, void *edata)
   return 0;
 }
 
+// Calculate the delay to schedule the auto config reload continuation.
+// Since the tokens expire right at the expiration time, we try to schedule
+// a little ahead of it (up to 5 minutes with 1 minute increments), e.g.
+// if the time till expiration is 1000 seconds in the future, we will try
+// to schedule the reload to happen 700 seconds in the future; if the
+// expiration is 100 seconds in the future, we'll try to schedule the reload
+// 100 - 60 = 40 seconds in the future; if the expiration is 220 seconds
+// in the future, we'll still try to schedule the reload 220 - 60 * 3 = 40
+// seconds in the future.
+static long
+cal_reload_delay(long time_diff)
+{
+  if (time_diff > 300) {
+    return time_diff - 300;
+  } else {
+    for (int i = 0; i < 5; ++i) {
+      if (time_diff - 60 <= 0) {
+        break;
+      } else {
+        time_diff -= 60;
+      }
+    }
+    return time_diff;
+  }
+}
+
+int
+config_reloader(TSCont cont, TSEvent event, void *edata)
+{
+  TSDebug(PLUGIN_NAME, "reloading configs");
+  S3Config *s3          = static_cast<S3Config *>(TSContDataGet(cont));
+  S3Config *file_config = gConfCache.get(s3->conf_fname());

Review comment:
       But isn't there a risk that two instances of the plugin, that both use 
the same config file, will try to reload it at the same time?




----------------------------------------------------------------
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]


Reply via email to