Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[LLC]: Use the sk_wait_event primitive

Signed-off-by: Jochen Friedrich <jochen@scram.de>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>

+27 -38
+27 -38
net/llc/af_llc.c
··· 37 37 static struct sockaddr_llc llc_ui_addrnull; 38 38 static struct proto_ops llc_ui_ops; 39 39 40 - static int llc_ui_wait_for_conn(struct sock *sk, int timeout); 41 - static int llc_ui_wait_for_disc(struct sock *sk, int timeout); 42 - static int llc_ui_wait_for_data(struct sock *sk, int timeout); 43 - static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout); 40 + static int llc_ui_wait_for_conn(struct sock *sk, long timeout); 41 + static int llc_ui_wait_for_disc(struct sock *sk, long timeout); 42 + static int llc_ui_wait_for_data(struct sock *sk, long timeout); 43 + static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout); 44 44 45 45 #if 0 46 46 #define dprintk(args...) printk(KERN_DEBUG args) ··· 117 117 int rc = 0; 118 118 119 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 122 rc = llc_ui_wait_for_busy_core(sk, timeout); 123 123 } ··· 428 428 } 429 429 430 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 433 if (!timeo || !llc_ui_wait_for_conn(sk, timeo)) 434 434 goto out; ··· 488 488 return rc; 489 489 } 490 490 491 - static int llc_ui_wait_for_disc(struct sock *sk, int timeout) 491 + static int llc_ui_wait_for_disc(struct sock *sk, long timeout) 492 492 { 493 493 DEFINE_WAIT(wait); 494 494 int rc = 0; 495 495 496 - prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 497 - while (sk->sk_state != TCP_CLOSE) { 498 - release_sock(sk); 499 - timeout = schedule_timeout(timeout); 500 - lock_sock(sk); 496 + while (1) { 497 + prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 498 + if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE)) 499 + break; 501 500 rc = -ERESTARTSYS; 502 501 if (signal_pending(current)) 503 502 break; ··· 504 505 if (!timeout) 505 506 break; 506 507 rc = 0; 507 - prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 508 508 } 509 509 finish_wait(sk->sk_sleep, &wait); 510 510 return rc; 511 511 } 512 512 513 - static int llc_ui_wait_for_conn(struct sock *sk, int timeout) 513 + static int llc_ui_wait_for_conn(struct sock *sk, long timeout) 514 514 { 515 515 DEFINE_WAIT(wait); 516 516 517 - prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 518 - 519 - while (sk->sk_state == TCP_SYN_SENT) { 520 - release_sock(sk); 521 - timeout = schedule_timeout(timeout); 522 - lock_sock(sk); 517 + while (1) { 518 + prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 519 + if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT)) 520 + break; 523 521 if (signal_pending(current) || !timeout) 524 522 break; 525 - prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 526 523 } 527 524 finish_wait(sk->sk_sleep, &wait); 528 525 return timeout; 529 526 } 530 527 531 - static int llc_ui_wait_for_data(struct sock *sk, int timeout) 528 + static int llc_ui_wait_for_data(struct sock *sk, long timeout) 532 529 { 533 530 DEFINE_WAIT(wait); 534 531 int rc = 0; 535 532 536 - for (;;) { 533 + while (1) { 537 534 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 538 - if (sk->sk_shutdown & RCV_SHUTDOWN) 535 + if (sk_wait_event(sk, &timeout, 536 + (sk->sk_shutdown & RCV_SHUTDOWN) || 537 + (!skb_queue_empty(&sk->sk_receive_queue)))) 539 538 break; 540 - if (!skb_queue_empty(&sk->sk_receive_queue)) 541 - break; 542 - release_sock(sk); 543 - timeout = schedule_timeout(timeout); 544 - lock_sock(sk); 545 539 rc = -ERESTARTSYS; 546 540 if (signal_pending(current)) 547 541 break; ··· 547 555 return rc; 548 556 } 549 557 550 - static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout) 558 + static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout) 551 559 { 552 560 DEFINE_WAIT(wait); 553 561 struct llc_sock *llc = llc_sk(sk); 554 562 int rc; 555 563 556 - for (;;) { 564 + while (1) { 557 565 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 558 - rc = -ENOTCONN; 559 - if (sk->sk_shutdown & RCV_SHUTDOWN) 560 - break; 561 566 rc = 0; 562 - if (!llc_data_accept_state(llc->state) && !llc->p_flag) 567 + if (sk_wait_event(sk, &timeout, 568 + (sk->sk_shutdown & RCV_SHUTDOWN) || 569 + (!llc_data_accept_state(llc->state) && 570 + !llc->p_flag))) 563 571 break; 564 - release_sock(sk); 565 - timeout = schedule_timeout(timeout); 566 - lock_sock(sk); 567 572 rc = -ERESTARTSYS; 568 573 if (signal_pending(current)) 569 574 break;