From: ericm Date: Wed, 18 Mar 2009 17:31:13 +0000 (+0000) Subject: branch: b1_6 X-Git-Tag: GIT_EPOCH_B1_6~2^5~118 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=341dc5e3c5beef29eecaee9c1684c682aeb6d4f4;p=fs%2Flustre-release.git branch: b1_6 fix the logic of ptlrpc_pinger_register_timeout(). b=18662 r=wangdi --- diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index d332175..d0412ae 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -415,32 +415,28 @@ static struct timeout_item* ptlrpc_pinger_register_timeout(int time, enum timeout_event event, timeout_cb_t cb, void *data) { - struct timeout_item *item; - struct timeout_item *ti = NULL; + struct timeout_item *item, *tmp; LASSERT_SEM_LOCKED(&pinger_sem); - list_for_each_entry_reverse(item, &timeout_list, ti_chain) { - if (item->ti_event == event) { - ti = item; - break; - } - if (item->ti_timeout < ti->ti_timeout) { - ti = ptlrpc_new_timeout(time, event, cb, data); - if (!ti) { - ti = ERR_PTR(-ENOMEM); - break; + + list_for_each_entry(item, &timeout_list, ti_chain) + if (item->ti_event == event) + goto out; + + item = ptlrpc_new_timeout(time, event, cb, data); + if (item) { + list_for_each_entry_reverse(tmp, &timeout_list, ti_chain) { + if (tmp->ti_timeout < time) { + list_add(&item->ti_chain, &tmp->ti_chain); + goto out; } - list_add(&ti->ti_chain, &item->ti_chain); } + list_add(&item->ti_chain, &timeout_list); } - if (!ti) { - ti = ptlrpc_new_timeout(time, event, cb, data); - if (ti) - list_add(&ti->ti_chain, &timeout_list); - } - - return ti; +out: + return item; } + /* Add a client_obd to the timeout event list, when timeout(@time) * happens, the callback(@cb) will be called. */