You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/12 01:51:25 UTC

[GitHub] [apisix] starsz commented on a diff in pull request #7648: fix: use a new way to manage clean_handler

starsz commented on code in PR #7648:
URL: https://github.com/apache/apisix/pull/7648#discussion_r944058151


##########
apisix/core/config_util.lua:
##########
@@ -56,23 +58,56 @@ end
 -- or cancelled. Note that Nginx worker exit doesn't trigger the clean handler.
 -- Return an index so that we can cancel it later.
 function _M.add_clean_handler(item, func)
-    local idx = #item.clean_handlers + 1
-    item.clean_handlers[idx] = func
-    return idx
+    if not item.clean_handlers._id then
+        item.clean_handlers._id = 1
+    end
+
+    local id = item.clean_handlers._id
+    item.clean_handlers._id = item.clean_handlers._id + 1

Review Comment:
   If `item.clean_handlers._id` is nil. The result will be two because we set `item.clean_handlers._id = 1` at line 62.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org