fix possible endless loop in msleep() upon signals

This commit is contained in:
Thomas Schoebel-Theuer 2011-11-08 11:17:41 +01:00 committed by Thomas Schoebel-Theuer
parent cbd156f307
commit 0eb4e62ecb
2 changed files with 20 additions and 2 deletions

17
brick.c
View File

@ -12,6 +12,23 @@
#include "brick.h"
#include "brick_mem.h"
int brick_msleep(int msecs, bool shorten)
{
unsigned long timeout;
if (msecs <= 0) {
schedule();
return 0;
}
timeout = msecs_to_jiffies(msecs) + 1;
if (shorten)
timeout = schedule_timeout_interruptible(timeout);
else
while (timeout)
timeout = schedule_timeout_interruptible(timeout);
return jiffies_to_msecs(timeout);
}
EXPORT_SYMBOL_GPL(brick_msleep);
/////////////////////////////////////////////////////////////////////
// messaging

View File

@ -2,8 +2,6 @@
#ifndef BRICK_H
#define BRICK_H
#define msleep msleep_interruptible
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
@ -23,6 +21,9 @@
#define _NORMAL_CODE(X) X
#endif
#define msleep(msecs) brick_msleep(msecs, false)
extern int brick_msleep(int msecs, bool shorten);
/////////////////////////////////////////////////////////////////////////
// printk() replacements