lkml.org 
[lkml]   [2006]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[ 03/23] [Suspend2] Allow a notifier to remove itself from the notifier list.
    Date

    This is Christoph Lameter's original patch, posted to LKML some time ago,
    but as yet unmerged.

    Allow a notifier to remove itself from the notifier list.

    If the next pointer is retrieved before notifier_call then the notifier can
    remove itself from the chain.

    Signed-off-by: Christoph Lameter <christoph@lameter.com>
    Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

    kernel/sys.c | 7 +++++--
    1 files changed, 5 insertions(+), 2 deletions(-)

    diff --git a/kernel/sys.c b/kernel/sys.c
    index d09cac2..46455fa 100644
    --- a/kernel/sys.c
    +++ b/kernel/sys.c
    @@ -174,15 +174,18 @@ int __kprobes notifier_call_chain(struct
    {
    int ret=NOTIFY_DONE;
    struct notifier_block *nb = *n;
    + struct notifier_block *next;

    while(nb)
    {
    - ret=nb->notifier_call(nb,val,v);
    + /* Determining next here allows the notifier to unregister itself */
    + next = nb->next;
    + ret = nb->notifier_call(nb,val,v);
    if(ret&NOTIFY_STOP_MASK)
    {
    return ret;
    }
    - nb=nb->next;
    + nb = next;
    }
    return ret;
    }
    --
    Nigel Cunningham nigel at suspend2 dot net
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-01-26 04:58    [W:0.022 / U:64.828 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site