serrislew commented on code in PR #9483:
URL: https://github.com/apache/trafficserver/pull/9483#discussion_r1137582313


##########
plugins/experimental/wasm/wasm_main.cc:
##########
@@ -60,23 +59,32 @@ schedule_handler(TSCont contp, TSEvent /*event*/, void * 
/*data*/)
 
   c->onTick(0); // use 0 as  token
 
-  if (!wasm_config->wasm) {
-    TSError("[wasm][%s] Configuration object is null", __FUNCTION__);
+  if (wasm_config->configs.empty()) {
+    TSError("[wasm][%s] Configuration objects are empty", __FUNCTION__);
     TSMutexUnlock(old_wasm->mutex());
     return 0;
   }
 
-  if (c->wasm() == wasm_config->wasm.get()) {
-    auto *wasm               = static_cast<ats_wasm::Wasm *>(c->wasm());
-    uint32_t root_context_id = c->id();
-    if (wasm->existsTimerPeriod(root_context_id)) {
-      TSDebug(WASM_DEBUG_TAG, "[%s] reschedule continuation", __FUNCTION__);
-      std::chrono::milliseconds period = wasm->getTimerPeriod(root_context_id);
-      TSContScheduleOnPool(contp, static_cast<TSHRTime>(period.count()), 
TS_THREAD_POOL_NET);
-    } else {
-      TSDebug(WASM_DEBUG_TAG, "[%s] can't find period for root context id: 
%d", __FUNCTION__, root_context_id);
+  bool found = false;
+  for (auto it = wasm_config->configs.begin(); it != 
wasm_config->configs.end(); it++) {
+    std::shared_ptr<ats_wasm::Wasm> wbp = it->first;
+    if (wbp.get() == old_wasm) {
+      found                    = true;
+      auto *wasm               = static_cast<ats_wasm::Wasm *>(c->wasm());
+      uint32_t root_context_id = c->id();
+      if (wasm->existsTimerPeriod(root_context_id)) {
+        TSDebug(WASM_DEBUG_TAG, "[%s] reschedule continuation", __FUNCTION__);
+        std::chrono::milliseconds period = 
wasm->getTimerPeriod(root_context_id);
+        TSContScheduleOnPool(contp, static_cast<TSHRTime>(period.count()), 
TS_THREAD_POOL_NET);
+      } else {
+        TSDebug(WASM_DEBUG_TAG, "[%s] can't find period for root context id: 
%d", __FUNCTION__, root_context_id);
+      }
     }
-  } else {
+
+    break;

Review Comment:
   shouldn't this `break` be within the `if` bracket so we stop looking if we 
found a matching wasm?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to