MCPcopy Create free account
hub / github.com/Tencent/phxsql / HasToken

Method HasToken

phxsqlproxy/plugin/requestfilter/freqctrlconfig.cpp:74–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool FreqCtrlBucket::HasToken(int * for_check) {
75 uint32_t last_refill_time = (unsigned int) time(NULL);
76 last_refill_time = last_refill_time - last_refill_time % (db_token_.period);
77
78 if (db_bucket_struct_.last_refill_time != last_refill_time) {
79 db_bucket_struct_.last_refill_time = last_refill_time;
80 db_bucket_struct_.read_bucket = db_token_.read_token;
81 db_bucket_struct_.write_bucket = db_token_.write_token;
82 }
83
84 return *for_check > 0;
85}
86
87bool FreqCtrlBucket::HasReadToken() {
88 return HasToken(&db_bucket_struct_.read_bucket);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected