You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2021/12/08 20:37:17 UTC

[GitHub] [trafficserver] bneradt commented on a change in pull request #8550: TSUserArg: add value type checking

bneradt commented on a change in pull request #8550:
URL: https://github.com/apache/trafficserver/pull/8550#discussion_r765226892



##########
File path: include/tscore/PluginUserArgs.h
##########
@@ -35,6 +35,40 @@ static constexpr std::array<size_t, TS_USER_ARGS_COUNT> MAX_USER_ARGS = {{
   128 /* max number of user arguments for GLB */
 }};
 
+/** Stagger each user argument value so we can detect mismatched
+ * indices.
+ *
+ * For example, say a plugin associates data with both sessions and
+ * transactions and that its session index is 2 and its transaction index is 4.
+ * In this case, we'll hand back to the plugin 2002 for its session index and
+ * 1004 for its transaction index. If it then accidentally uses its session
+ * index to reference its transaction index, it will pass back 2002 instead of
+ * 1004, which we will identify as belonging to the wrong user argument type
+ * because it is in the 2000 session block rather than the expected 1000
+ * transaction block.
+ *
+ * Note that these higher value 1000 block indices are only used when
+ * interfacing with the plugin. Internally the lower valued index is used.
+ * That is, for a transaction, expect internally a value of 3 instead of 1003.
+ */
+static constexpr std::array<size_t, TS_USER_ARGS_COUNT> USER_ARGS_OFFSETS = {{
+  1000, /* max number of user arguments for TXN */
+  2000, /* max number of user arguments for SSN */
+  3000, /* max number of user arguments for VCONN */
+  4000  /* max number of user arguments for GLB */
+}};

Review comment:
       I like this idea.




-- 
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: github-unsubscribe@trafficserver.apache.org

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