nbd.c: sock_xmit: cleanup signal related code
sock_xmit() re-implements sigprocmask() and dequeue_signal_lock(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: Paul Clements <paul.clements@steeleye.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Родитель
3e1ac130d0
Коммит
be0ef957c9
|
@ -122,17 +122,12 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
|
||||||
int result;
|
int result;
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct kvec iov;
|
struct kvec iov;
|
||||||
unsigned long flags;
|
sigset_t blocked, oldset;
|
||||||
sigset_t oldset;
|
|
||||||
|
|
||||||
/* Allow interception of SIGKILL only
|
/* Allow interception of SIGKILL only
|
||||||
* Don't allow other signals to interrupt the transmission */
|
* Don't allow other signals to interrupt the transmission */
|
||||||
spin_lock_irqsave(¤t->sighand->siglock, flags);
|
siginitsetinv(&blocked, sigmask(SIGKILL));
|
||||||
oldset = current->blocked;
|
sigprocmask(SIG_SETMASK, &blocked, &oldset);
|
||||||
sigfillset(¤t->blocked);
|
|
||||||
sigdelsetmask(¤t->blocked, sigmask(SIGKILL));
|
|
||||||
recalc_sigpending();
|
|
||||||
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sock->sk->sk_allocation = GFP_NOIO;
|
sock->sk->sk_allocation = GFP_NOIO;
|
||||||
|
@ -151,11 +146,9 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
|
||||||
|
|
||||||
if (signal_pending(current)) {
|
if (signal_pending(current)) {
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
spin_lock_irqsave(¤t->sighand->siglock, flags);
|
|
||||||
printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
|
printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
|
||||||
current->pid, current->comm,
|
current->pid, current->comm,
|
||||||
dequeue_signal(current, ¤t->blocked, &info));
|
dequeue_signal_lock(current, ¤t->blocked, &info));
|
||||||
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
|
|
||||||
result = -EINTR;
|
result = -EINTR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,10 +162,7 @@ static int sock_xmit(struct socket *sock, int send, void *buf, int size,
|
||||||
buf += result;
|
buf += result;
|
||||||
} while (size > 0);
|
} while (size > 0);
|
||||||
|
|
||||||
spin_lock_irqsave(¤t->sighand->siglock, flags);
|
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
||||||
current->blocked = oldset;
|
|
||||||
recalc_sigpending();
|
|
||||||
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче