aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/llc/af_llc.c65
1 files changed, 27 insertions, 38 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 436c8db67f55..95444f227510 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -37,10 +37,10 @@ static u16 llc_ui_sap_link_no_max[256];
37static struct sockaddr_llc llc_ui_addrnull; 37static struct sockaddr_llc llc_ui_addrnull;
38static struct proto_ops llc_ui_ops; 38static struct proto_ops llc_ui_ops;
39 39
40static int llc_ui_wait_for_conn(struct sock *sk, int timeout); 40static int llc_ui_wait_for_conn(struct sock *sk, long timeout);
41static int llc_ui_wait_for_disc(struct sock *sk, int timeout); 41static int llc_ui_wait_for_disc(struct sock *sk, long timeout);
42static int llc_ui_wait_for_data(struct sock *sk, int timeout); 42static int llc_ui_wait_for_data(struct sock *sk, long timeout);
43static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout); 43static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
44 44
45#if 0 45#if 0
46#define dprintk(args...) printk(KERN_DEBUG args) 46#define dprintk(args...) printk(KERN_DEBUG args)
@@ -117,7 +117,7 @@ static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
117 int rc = 0; 117 int rc = 0;
118 118
119 if (llc_data_accept_state(llc->state) || llc->p_flag) { 119 if (llc_data_accept_state(llc->state) || llc->p_flag) {
120 int timeout = sock_sndtimeo(sk, noblock); 120 long timeout = sock_sndtimeo(sk, noblock);
121 121
122 rc = llc_ui_wait_for_busy_core(sk, timeout); 122 rc = llc_ui_wait_for_busy_core(sk, timeout);
123 } 123 }
@@ -428,7 +428,7 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
428 } 428 }
429 429
430 if (sk->sk_state == TCP_SYN_SENT) { 430 if (sk->sk_state == TCP_SYN_SENT) {
431 const int timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); 431 const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
432 432
433 if (!timeo || !llc_ui_wait_for_conn(sk, timeo)) 433 if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
434 goto out; 434 goto out;
@@ -488,16 +488,15 @@ out:
488 return rc; 488 return rc;
489} 489}
490 490
491static int llc_ui_wait_for_disc(struct sock *sk, int timeout) 491static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
492{ 492{
493 DEFINE_WAIT(wait); 493 DEFINE_WAIT(wait);
494 int rc = 0; 494 int rc = 0;
495 495
496 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 496 while (1) {
497 while (sk->sk_state != TCP_CLOSE) { 497 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
498 release_sock(sk); 498 if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE))
499 timeout = schedule_timeout(timeout); 499 break;
500 lock_sock(sk);
501 rc = -ERESTARTSYS; 500 rc = -ERESTARTSYS;
502 if (signal_pending(current)) 501 if (signal_pending(current))
503 break; 502 break;
@@ -505,44 +504,37 @@ static int llc_ui_wait_for_disc(struct sock *sk, int timeout)
505 if (!timeout) 504 if (!timeout)
506 break; 505 break;
507 rc = 0; 506 rc = 0;
508 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
509 } 507 }
510 finish_wait(sk->sk_sleep, &wait); 508 finish_wait(sk->sk_sleep, &wait);
511 return rc; 509 return rc;
512} 510}
513 511
514static int llc_ui_wait_for_conn(struct sock *sk, int timeout) 512static int llc_ui_wait_for_conn(struct sock *sk, long timeout)
515{ 513{
516 DEFINE_WAIT(wait); 514 DEFINE_WAIT(wait);
517 515
518 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 516 while (1) {
519 517 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
520 while (sk->sk_state == TCP_SYN_SENT) { 518 if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT))
521 release_sock(sk); 519 break;
522 timeout = schedule_timeout(timeout);
523 lock_sock(sk);
524 if (signal_pending(current) || !timeout) 520 if (signal_pending(current) || !timeout)
525 break; 521 break;
526 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
527 } 522 }
528 finish_wait(sk->sk_sleep, &wait); 523 finish_wait(sk->sk_sleep, &wait);
529 return timeout; 524 return timeout;
530} 525}
531 526
532static int llc_ui_wait_for_data(struct sock *sk, int timeout) 527static int llc_ui_wait_for_data(struct sock *sk, long timeout)
533{ 528{
534 DEFINE_WAIT(wait); 529 DEFINE_WAIT(wait);
535 int rc = 0; 530 int rc = 0;
536 531
537 for (;;) { 532 while (1) {
538 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 533 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
539 if (sk->sk_shutdown & RCV_SHUTDOWN) 534 if (sk_wait_event(sk, &timeout,
540 break; 535 (sk->sk_shutdown & RCV_SHUTDOWN) ||
541 if (!skb_queue_empty(&sk->sk_receive_queue)) 536 (!skb_queue_empty(&sk->sk_receive_queue))))
542 break; 537 break;
543 release_sock(sk);
544 timeout = schedule_timeout(timeout);
545 lock_sock(sk);
546 rc = -ERESTARTSYS; 538 rc = -ERESTARTSYS;
547 if (signal_pending(current)) 539 if (signal_pending(current))
548 break; 540 break;
@@ -555,23 +547,20 @@ static int llc_ui_wait_for_data(struct sock *sk, int timeout)
555 return rc; 547 return rc;
556} 548}
557 549
558static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout) 550static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
559{ 551{
560 DEFINE_WAIT(wait); 552 DEFINE_WAIT(wait);
561 struct llc_sock *llc = llc_sk(sk); 553 struct llc_sock *llc = llc_sk(sk);
562 int rc; 554 int rc;
563 555
564 for (;;) { 556 while (1) {
565 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 557 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
566 rc = -ENOTCONN;
567 if (sk->sk_shutdown & RCV_SHUTDOWN)
568 break;
569 rc = 0; 558 rc = 0;
570 if (!llc_data_accept_state(llc->state) && !llc->p_flag) 559 if (sk_wait_event(sk, &timeout,
560 (sk->sk_shutdown & RCV_SHUTDOWN) ||
561 (!llc_data_accept_state(llc->state) &&
562 !llc->p_flag)))
571 break; 563 break;
572 release_sock(sk);
573 timeout = schedule_timeout(timeout);
574 lock_sock(sk);
575 rc = -ERESTARTSYS; 564 rc = -ERESTARTSYS;
576 if (signal_pending(current)) 565 if (signal_pending(current))
577 break; 566 break;