mirror of https://github.com/schoebel/mars
fix possible endless loop in msleep() upon signals
This commit is contained in:
parent
cbd156f307
commit
0eb4e62ecb
17
brick.c
17
brick.c
|
@ -12,6 +12,23 @@
|
||||||
#include "brick.h"
|
#include "brick.h"
|
||||||
#include "brick_mem.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
|
// messaging
|
||||||
|
|
5
brick.h
5
brick.h
|
@ -2,8 +2,6 @@
|
||||||
#ifndef BRICK_H
|
#ifndef BRICK_H
|
||||||
#define BRICK_H
|
#define BRICK_H
|
||||||
|
|
||||||
#define msleep msleep_interruptible
|
|
||||||
|
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
|
@ -23,6 +21,9 @@
|
||||||
#define _NORMAL_CODE(X) X
|
#define _NORMAL_CODE(X) X
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define msleep(msecs) brick_msleep(msecs, false)
|
||||||
|
extern int brick_msleep(int msecs, bool shorten);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// printk() replacements
|
// printk() replacements
|
||||||
|
|
Loading…
Reference in New Issue