Skip to content

Commit

Permalink
Bluetooth: rfcomm: Remove unnecessary krfcommd event
Browse files Browse the repository at this point in the history
Removed superfluous event handling which was used to signal
that the rfcomm kthread had been woken. This appears to have been
used to prevent lost wakeups. Correctly ordering when the task
state is set to TASK_INTERRUPTIBLE is sufficient to prevent lost wakeups.

To prevent wakeups which occurred prior to initially setting
TASK_INTERRUPTIBLE from being lost, the main work of the thread loop -
rfcomm_process_sessions() - is performed prior to sleeping.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
Peter Hurley authored and Gustavo F. Padovan committed Aug 11, 2011
1 parent 8e7c3d2 commit e5842cd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions net/bluetooth/rfcomm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ static DEFINE_MUTEX(rfcomm_mutex);
#define rfcomm_lock() mutex_lock(&rfcomm_mutex)
#define rfcomm_unlock() mutex_unlock(&rfcomm_mutex)

static unsigned long rfcomm_event;

static LIST_HEAD(session_list);

Expand Down Expand Up @@ -120,7 +119,6 @@ static inline void rfcomm_schedule(void)
{
if (!rfcomm_thread)
return;
set_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
wake_up_process(rfcomm_thread);
}

Expand Down Expand Up @@ -2038,19 +2036,18 @@ static int rfcomm_run(void *unused)

rfcomm_add_listener(BDADDR_ANY);

while (!kthread_should_stop()) {
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
if (!test_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event)) {
/* No pending events. Let's sleep.
* Incoming connections and data will wake us up. */
schedule();
}
set_current_state(TASK_RUNNING);

if (kthread_should_stop())
break;

/* Process stuff */
clear_bit(RFCOMM_SCHED_WAKEUP, &rfcomm_event);
rfcomm_process_sessions();

schedule();
}
__set_current_state(TASK_RUNNING);

rfcomm_kill_listener();

Expand Down

0 comments on commit e5842cd

Please sign in to comment.