TS-2191 we should not simply reschdule the http_sm if the sm_list`s mutex is not acquired, because the client_vc`s timeout events maybe triggered. The race may lead http_sm received a event after it is deleted. Sub task (TS-2192)
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a27b9e73 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a27b9e73 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a27b9e73 Branch: refs/heads/5.0.x Commit: a27b9e73a5e113a0231d56817e86fbad27583180 Parents: e8672a8 Author: weijin <taorui...@taobao.com> Authored: Mon Sep 9 23:36:34 2013 +0800 Committer: weijin <taorui...@taobao.com> Committed: Mon Sep 9 23:51:29 2013 +0800 ---------------------------------------------------------------------- CHANGES | 2 ++ proxy/http/HttpSM.cc | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a27b9e73/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 1c7d948..878b55b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 4.1.0 + + *) [TS-2191] not reschedule http_sm when the sm_list`s lock is not acquired. *) [TS-1086] Avoid edge case returning 304 to an unconditional request. Diagnosis and patch by Mohamad Khateeb. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a27b9e73/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 3804c50..113a89b 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -520,13 +520,11 @@ HttpSM::state_add_to_list(int event, void * /* data ATS_UNUSED */) int bucket = ((unsigned int) sm_id % HTTP_LIST_BUCKETS); MUTEX_TRY_LOCK(lock, HttpSMList[bucket].mutex, mutex->thread_holding); - if (!lock) { - HTTP_SM_SET_DEFAULT_HANDLER(&HttpSM::state_add_to_list); - mutex->thread_holding->schedule_in(this, HTTP_LIST_RETRY); - return EVENT_DONE; - } - - HttpSMList[bucket].sm_list.push(this); + // the client_vc`s timeout events can be triggered, so we should not + // reschedule the http_sm when the lock is not acquired. + // FIXME: the sm_list may miss some http_sms when the lock contention + if (lock) + HttpSMList[bucket].sm_list.push(this); } t_state.api_next_action = HttpTransact::HTTP_API_SM_START;