--- 2.6/drivers/net/shaper.c 2004-01-17 12:19:27.000000000 +0100 +++ build-2.6/drivers/net/shaper.c 2004-01-17 12:34:19.000000000 +0100 @@ -83,6 +83,7 @@ #include #include #include +#include #include #include @@ -106,17 +107,27 @@ static int shaper_lock(struct shaper *sh) { + DECLARE_WAITQUEUE(wait, current); + /* * Lock in an interrupt must fail */ - while (test_and_set_bit(0, &sh->locked)) - { - if (!in_interrupt()) - sleep_on(&sh->wait_queue); - else + if (in_interrupt()) { + if (test_and_set_bit(0, &sh->locked)) { return 0; - + } else { + return 1; + } + } + add_wait_queue(&sh->wait_queue, &wait); + for (;;) { + set_current_state(TASK_UNINTERRUPTIBLE); + if (test_and_set_bit(0, &sh->locked) == 0) + break; + schedule(); } + remove_wait_queue(&sh->wait_queue, &wait); + __set_current_state(TASK_RUNNING); return 1; }