summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <[email protected]>2024-02-05 03:26:26 +0000
committerroot <[email protected]>2024-02-05 03:26:26 +0000
commitbe8e1d87cb8993c4df7054ec0205c60473c23f41 (patch)
tree16f66e90d68d25370e3460e4e4e476593e92f20b
parentf711e8a81c8888119b20e1a47aca95a62517debf (diff)
bugfix: 对于fair-share和split-by类型的profile,也需要等一次consume命令执行完,才执行下一次
-rw-r--r--shaping/CMakeLists.txt4
-rw-r--r--shaping/src/main.cpp4
-rw-r--r--shaping/src/shaper.cpp7
3 files changed, 9 insertions, 6 deletions
diff --git a/shaping/CMakeLists.txt b/shaping/CMakeLists.txt
index dea4cc2..c85bbba 100644
--- a/shaping/CMakeLists.txt
+++ b/shaping/CMakeLists.txt
@@ -17,4 +17,8 @@ target_link_libraries(shaping_engine PUBLIC jemalloc)
install(TARGETS shaping_engine RUNTIME DESTINATION bin COMPONENT Program)
+# 在安装时创建一个子目录log
+install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/log)
+
+
add_subdirectory(test) \ No newline at end of file
diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp
index d31f768..54e2f60 100644
--- a/shaping/src/main.cpp
+++ b/shaping/src/main.cpp
@@ -58,7 +58,7 @@ static void sig_handler(int signo)
swarmkv_reload_log_level();
}
- if (signo == SIGQUIT) {
+ if (signo == SIGQUIT || signo == SIGTERM) {
quit = 1;
}
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
return -1;
}
- if (signal(SIGQUIT, sig_handler) == SIG_ERR)
+ if (signal(SIGQUIT, sig_handler) == SIG_ERR || signal(SIGTERM, sig_handler) == SIG_ERR)
{
LOG_ERROR("%s: unable to register SIGQUIT signal handler, error %d: %s", LOG_TAG_SHAPING, errno, strerror(errno));
LOG_CLOSE();
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp
index 76e1c53..54f1308 100644
--- a/shaping/src/shaper.cpp
+++ b/shaping/src/shaper.cpp
@@ -486,9 +486,7 @@ static void shaper_token_get_cb(const struct swarmkv_reply *reply, void * cb_arg
}
END:
- if (profile->type == PROFILE_TYPE_GENERIC) {
- pf_hash_node->tconsume_ref_cnt--;
- }
+ pf_hash_node->tconsume_ref_cnt--;
if (reply->type != SWARMKV_REPLY_INTEGER || reply->integer == 0) {
switch (profile->type) {
@@ -588,6 +586,7 @@ static int shaper_token_get_from_profile(struct shaping_thread_ctx *ctx, struct
}
snprintf(key, sizeof(key), "tsg-shaping-%d-%s", pf_info->id, direction == SHAPING_DIR_OUT ? "outgoing" : "incoming");
+
arg = (struct shaping_tconsume_cb_arg *)calloc(1, sizeof(struct shaping_tconsume_cb_arg));
arg->ctx = ctx;
arg->profile = pf_info;
@@ -758,7 +757,7 @@ static int shaping_swarmkv_is_too_short_interval(long long curr_time_ms, struct
static int shaper_token_consume(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, struct shaping_profile_info *profile, int profile_type, int req_token_bytes, unsigned char direction, struct timespec *curr_timespec)
{
- if (profile_type == PROFILE_IN_RULE_TYPE_BORROW && !(sf->flag & SESSION_BORROW)) {
+ if (profile_type == PROFILE_IN_RULE_TYPE_BORROW && !(sf->flag & SESSION_BORROW)) {//TODO: 会减慢swarmkv请求速度
return SHAPER_TOKEN_GET_FAILED;
}