Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
5a8b70fc
Commit
5a8b70fc
authored
Mar 11, 2003
by
Andrew Morton
Committed by
Hideaki Yoshifuji
Mar 11, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Use fancy wakeups where applicable.
parent
cd9a1f5f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
65 deletions
+39
-65
net/core/datagram.c
net/core/datagram.c
+3
-6
net/core/sock.c
net/core/sock.c
+7
-10
net/ipv4/af_inet.c
net/ipv4/af_inet.c
+4
-6
net/ipv4/tcp.c
net/ipv4/tcp.c
+15
-27
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_ipv4.c
+4
-5
net/unix/af_unix.c
net/unix/af_unix.c
+6
-11
No files found.
net/core/datagram.c
View file @
5a8b70fc
...
...
@@ -68,11 +68,9 @@ static inline int connection_based(struct sock *sk)
static
int
wait_for_packet
(
struct
sock
*
sk
,
int
*
err
,
long
*
timeo_p
)
{
int
error
;
DEFINE_WAIT
(
wait
);
DECLARE_WAITQUEUE
(
wait
,
current
);
__set_current_state
(
TASK_INTERRUPTIBLE
);
add_wait_queue_exclusive
(
sk
->
sleep
,
&
wait
);
prepare_to_wait_exclusive
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
/* Socket errors? */
error
=
sock_error
(
sk
);
...
...
@@ -101,8 +99,7 @@ static int wait_for_packet(struct sock *sk, int *err, long *timeo_p)
error
=
0
;
*
timeo_p
=
schedule_timeout
(
*
timeo_p
);
out:
current
->
state
=
TASK_RUNNING
;
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
error
;
interrupted:
error
=
sock_intr_errno
(
*
timeo_p
);
...
...
net/core/sock.c
View file @
5a8b70fc
...
...
@@ -746,17 +746,16 @@ void sock_kfree_s(struct sock *sk, void *mem, int size)
*/
static
long
sock_wait_for_wmem
(
struct
sock
*
sk
,
long
timeo
)
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
clear_bit
(
SOCK_ASYNC_NOSPACE
,
&
sk
->
socket
->
flags
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
for
(;;)
{
if
(
!
timeo
)
break
;
if
(
signal_pending
(
current
))
break
;
set_bit
(
SOCK_NOSPACE
,
&
sk
->
socket
->
flags
);
set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
if
(
atomic_read
(
&
sk
->
wmem_alloc
)
<
sk
->
sndbuf
)
break
;
if
(
sk
->
shutdown
&
SEND_SHUTDOWN
)
...
...
@@ -765,8 +764,7 @@ static long sock_wait_for_wmem(struct sock * sk, long timeo)
break
;
timeo
=
schedule_timeout
(
timeo
);
}
__set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
timeo
;
}
...
...
@@ -860,19 +858,18 @@ struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
void
__lock_sock
(
struct
sock
*
sk
)
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
add_wait_queue_exclusive
(
&
sk
->
lock
.
wq
,
&
wait
);
for
(;;)
{
current
->
state
=
TASK_UNINTERRUPTIBLE
;
prepare_to_wait_exclusive
(
&
sk
->
lock
.
wq
,
&
wait
,
TASK_UNINTERRUPTIBLE
);
spin_unlock_bh
(
&
sk
->
lock
.
slock
);
schedule
();
spin_lock_bh
(
&
sk
->
lock
.
slock
);
if
(
!
sock_owned_by_user
(
sk
))
break
;
}
current
->
state
=
TASK_RUNNING
;
remove_wait_queue
(
&
sk
->
lock
.
wq
,
&
wait
);
finish_wait
(
&
sk
->
lock
.
wq
,
&
wait
);
}
void
__release_sock
(
struct
sock
*
sk
)
...
...
net/ipv4/af_inet.c
View file @
5a8b70fc
...
...
@@ -562,10 +562,9 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr * uaddr,
static
long
inet_wait_for_connect
(
struct
sock
*
sk
,
long
timeo
)
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
__set_current_state
(
TASK_INTERRUPTIBLE
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
/* Basic assumption: if someone sets sk->err, he _must_
* change state of the socket from TCP_SYN_*.
...
...
@@ -578,10 +577,9 @@ static long inet_wait_for_connect(struct sock *sk, long timeo)
lock_sock
(
sk
);
if
(
signal_pending
(
current
)
||
!
timeo
)
break
;
set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
}
__set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
timeo
;
}
...
...
net/ipv4/tcp.c
View file @
5a8b70fc
...
...
@@ -659,7 +659,7 @@ static int wait_for_tcp_connect(struct sock *sk, int flags, long *timeo_p)
{
struct
tcp_opt
*
tp
=
tcp_sk
(
sk
);
struct
task_struct
*
tsk
=
current
;
DE
CLARE_WAITQUEUE
(
wait
,
tsk
);
DE
FINE_WAIT
(
wait
);
while
((
1
<<
sk
->
state
)
&
~
(
TCPF_ESTABLISHED
|
TCPF_CLOSE_WAIT
))
{
if
(
sk
->
err
)
...
...
@@ -671,16 +671,14 @@ static int wait_for_tcp_connect(struct sock *sk, int flags, long *timeo_p)
if
(
signal_pending
(
tsk
))
return
sock_intr_errno
(
*
timeo_p
);
__set_task_state
(
tsk
,
TASK_INTERRUPTIBLE
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
tp
->
write_pending
++
;
release_sock
(
sk
);
*
timeo_p
=
schedule_timeout
(
*
timeo_p
);
lock_sock
(
sk
);
__set_task_state
(
tsk
,
TASK_RUNNING
);
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
tp
->
write_pending
--
;
}
return
0
;
...
...
@@ -700,16 +698,15 @@ static int wait_for_tcp_memory(struct sock *sk, long *timeo)
int
err
=
0
;
long
vm_wait
=
0
;
long
current_timeo
=
*
timeo
;
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
if
(
tcp_memory_free
(
sk
))
current_timeo
=
vm_wait
=
(
net_random
()
%
(
HZ
/
5
))
+
2
;
add_wait_queue
(
sk
->
sleep
,
&
wait
);
for
(;;)
{
set_bit
(
SOCK_ASYNC_NOSPACE
,
&
sk
->
socket
->
flags
);
set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
if
(
sk
->
err
||
(
sk
->
shutdown
&
SEND_SHUTDOWN
))
goto
do_error
;
...
...
@@ -740,8 +737,7 @@ static int wait_for_tcp_memory(struct sock *sk, long *timeo)
*
timeo
=
current_timeo
;
}
out:
current
->
state
=
TASK_RUNNING
;
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
err
;
do_error:
...
...
@@ -1374,11 +1370,9 @@ static void cleanup_rbuf(struct sock *sk, int copied)
static
long
tcp_data_wait
(
struct
sock
*
sk
,
long
timeo
)
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
__set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
set_bit
(
SOCK_ASYNC_WAITDATA
,
&
sk
->
socket
->
flags
);
release_sock
(
sk
);
...
...
@@ -1389,8 +1383,7 @@ static long tcp_data_wait(struct sock *sk, long timeo)
lock_sock
(
sk
);
clear_bit
(
SOCK_ASYNC_WAITDATA
,
&
sk
->
socket
->
flags
);
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
__set_current_state
(
TASK_RUNNING
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
timeo
;
}
...
...
@@ -2017,12 +2010,10 @@ void tcp_close(struct sock *sk, long timeout)
if
(
timeout
)
{
struct
task_struct
*
tsk
=
current
;
DECLARE_WAITQUEUE
(
wait
,
current
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
DEFINE_WAIT
(
wait
);
do
{
set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
if
(
!
closing
(
sk
))
break
;
release_sock
(
sk
);
...
...
@@ -2030,8 +2021,7 @@ void tcp_close(struct sock *sk, long timeout)
lock_sock
(
sk
);
}
while
(
!
signal_pending
(
tsk
)
&&
timeout
);
tsk
->
state
=
TASK_RUNNING
;
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
}
adjudge_to_death:
...
...
@@ -2191,7 +2181,7 @@ int tcp_disconnect(struct sock *sk, int flags)
static
int
wait_for_connect
(
struct
sock
*
sk
,
long
timeo
)
{
struct
tcp_opt
*
tp
=
tcp_sk
(
sk
);
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
int
err
;
/*
...
...
@@ -2208,9 +2198,8 @@ static int wait_for_connect(struct sock *sk, long timeo)
* our exclusiveness temporarily when we get woken up without
* having to remove and re-insert us on the wait queue.
*/
add_wait_queue_exclusive
(
sk
->
sleep
,
&
wait
);
for
(;;)
{
current
->
state
=
TASK_INTERRUPTIBLE
;
prepare_to_wait_exclusive
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
)
;
release_sock
(
sk
);
if
(
!
tp
->
accept_queue
)
timeo
=
schedule_timeout
(
timeo
);
...
...
@@ -2228,8 +2217,7 @@ static int wait_for_connect(struct sock *sk, long timeo)
if
(
!
timeo
)
break
;
}
current
->
state
=
TASK_RUNNING
;
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
return
err
;
}
...
...
net/ipv4/tcp_ipv4.c
View file @
5a8b70fc
...
...
@@ -334,11 +334,11 @@ void tcp_listen_wlock(void)
write_lock
(
&
tcp_lhash_lock
);
if
(
atomic_read
(
&
tcp_lhash_users
))
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
add_wait_queue_exclusive
(
&
tcp_lhash_wait
,
&
wait
);
for
(;;)
{
set_current_state
(
TASK_UNINTERRUPTIBLE
);
prepare_to_wait_exclusive
(
&
tcp_lhash_wait
,
&
wait
,
TASK_UNINTERRUPTIBLE
);
if
(
!
atomic_read
(
&
tcp_lhash_users
))
break
;
write_unlock_bh
(
&
tcp_lhash_lock
);
...
...
@@ -346,8 +346,7 @@ void tcp_listen_wlock(void)
write_lock_bh
(
&
tcp_lhash_lock
);
}
__set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
tcp_lhash_wait
,
&
wait
);
finish_wait
(
&
tcp_lhash_wait
,
&
wait
);
}
}
...
...
net/unix/af_unix.c
View file @
5a8b70fc
...
...
@@ -859,10 +859,9 @@ static long unix_wait_for_peer(unix_socket *other, long timeo)
{
struct
unix_sock
*
u
=
unix_sk
(
other
);
int
sched
;
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
__set_current_state
(
TASK_INTERRUPTIBLE
);
add_wait_queue_exclusive
(
&
u
->
peer_wait
,
&
wait
);
prepare_to_wait_exclusive
(
&
u
->
peer_wait
,
&
wait
,
TASK_INTERRUPTIBLE
);
sched
=
(
!
test_bit
(
SOCK_DEAD
,
&
other
->
flags
)
&&
!
(
other
->
shutdown
&
RCV_SHUTDOWN
)
&&
...
...
@@ -873,8 +872,7 @@ static long unix_wait_for_peer(unix_socket *other, long timeo)
if
(
sched
)
timeo
=
schedule_timeout
(
timeo
);
__set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
&
u
->
peer_wait
,
&
wait
);
finish_wait
(
&
u
->
peer_wait
,
&
wait
);
return
timeo
;
}
...
...
@@ -1542,14 +1540,12 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
static
long
unix_stream_data_wait
(
unix_socket
*
sk
,
long
timeo
)
{
DE
CLARE_WAITQUEUE
(
wait
,
curren
t
);
DE
FINE_WAIT
(
wai
t
);
unix_state_rlock
(
sk
);
add_wait_queue
(
sk
->
sleep
,
&
wait
);
for
(;;)
{
set_current_state
(
TASK_INTERRUPTIBLE
);
prepare_to_wait
(
sk
->
sleep
,
&
wait
,
TASK_INTERRUPTIBLE
);
if
(
skb_queue_len
(
&
sk
->
receive_queue
)
||
sk
->
err
||
...
...
@@ -1565,8 +1561,7 @@ static long unix_stream_data_wait(unix_socket * sk, long timeo)
clear_bit
(
SOCK_ASYNC_WAITDATA
,
&
sk
->
socket
->
flags
);
}
__set_current_state
(
TASK_RUNNING
);
remove_wait_queue
(
sk
->
sleep
,
&
wait
);
finish_wait
(
sk
->
sleep
,
&
wait
);
unix_state_runlock
(
sk
);
return
timeo
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment