Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
cc227c72
Commit
cc227c72
authored
Jan 21, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set non-blocking mode on accepted sockets
parent
370f789f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
9 deletions
+25
-9
include/vlc_network.h
include/vlc_network.h
+3
-0
modules/control/telnet.c
modules/control/telnet.c
+1
-1
src/network/httpd.c
src/network/httpd.c
+4
-2
src/network/tcp.c
src/network/tcp.c
+17
-6
No files found.
include/vlc_network.h
View file @
cc227c72
...
@@ -86,6 +86,9 @@ static inline int __net_ConnectTCP (vlc_object_t *obj, const char *host, int por
...
@@ -86,6 +86,9 @@ static inline int __net_ConnectTCP (vlc_object_t *obj, const char *host, int por
return
__net_Connect
(
obj
,
host
,
port
,
SOCK_STREAM
,
IPPROTO_TCP
);
return
__net_Connect
(
obj
,
host
,
port
,
SOCK_STREAM
,
IPPROTO_TCP
);
}
}
VLC_EXPORT
(
int
,
net_AcceptSingle
,
(
vlc_object_t
*
obj
,
int
lfd
)
);
#define net_Accept(a, b, c) __net_Accept(VLC_OBJECT(a), b, c)
#define net_Accept(a, b, c) __net_Accept(VLC_OBJECT(a), b, c)
VLC_EXPORT
(
int
,
__net_Accept
,
(
vlc_object_t
*
,
int
*
,
mtime_t
)
);
VLC_EXPORT
(
int
,
__net_Accept
,
(
vlc_object_t
*
,
int
*
,
mtime_t
)
);
...
...
modules/control/telnet.c
View file @
cc227c72
...
@@ -490,7 +490,7 @@ static void Run( intf_thread_t *p_intf )
...
@@ -490,7 +490,7 @@ static void Run( intf_thread_t *p_intf )
if
(
ufd
[
ncli
+
i
].
revents
==
0
)
if
(
ufd
[
ncli
+
i
].
revents
==
0
)
continue
;
continue
;
fd
=
accept
(
ufd
[
ncli
+
i
].
fd
,
NULL
,
NULL
);
fd
=
net_AcceptSingle
(
VLC_OBJECT
(
p_intf
),
ufd
[
ncli
+
i
].
fd
);
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
continue
;
continue
;
...
...
src/network/httpd.c
View file @
cc227c72
...
@@ -2509,17 +2509,19 @@ static void httpd_HostThread( httpd_host_t *host )
...
@@ -2509,17 +2509,19 @@ static void httpd_HostThread( httpd_host_t *host )
{
{
httpd_client_t
*
cl
;
httpd_client_t
*
cl
;
int
i_state
=
-
1
;
int
i_state
=
-
1
;
int
fd
=
ufd
[
nfd
].
fd
;
assert
(
ufd
[
nfd
].
fd
==
host
->
fds
[
nfd
]);
assert
(
fd
==
host
->
fds
[
nfd
]);
if
(
ufd
[
nfd
].
revents
==
0
)
if
(
ufd
[
nfd
].
revents
==
0
)
continue
;
continue
;
/* */
/* */
int
fd
=
accept
(
ufd
[
nfd
].
fd
,
NULL
,
NULL
);
fd
=
accept
(
fd
,
NULL
,
NULL
);
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
continue
;
continue
;
net_SetupSocket
(
fd
);
if
(
p_tls
!=
NULL
)
if
(
p_tls
!=
NULL
)
{
{
switch
(
tls_ServerSessionHandshake
(
p_tls
,
fd
)
)
switch
(
tls_ServerSessionHandshake
(
p_tls
,
fd
)
)
...
...
src/network/tcp.c
View file @
cc227c72
...
@@ -258,6 +258,22 @@ next_ai: /* failure */
...
@@ -258,6 +258,22 @@ next_ai: /* failure */
}
}
int
net_AcceptSingle
(
vlc_object_t
*
obj
,
int
lfd
)
{
int
fd
=
accept
(
lfd
,
NULL
,
NULL
);
if
(
fd
==
-
1
)
{
if
(
net_errno
!=
EAGAIN
)
msg_Err
(
obj
,
"accept failed (from socket %d): %m"
,
lfd
);
return
-
1
;
}
msg_Dbg
(
obj
,
"accepted socket %d (from socket %d)"
,
fd
,
lfd
);
net_SetupSocket
(
fd
);
return
0
;
}
/*****************************************************************************
/*****************************************************************************
* __net_Accept:
* __net_Accept:
*****************************************************************************
*****************************************************************************
...
@@ -312,13 +328,9 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
...
@@ -312,13 +328,9 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
continue
;
continue
;
int
sfd
=
ufd
[
i
].
fd
;
int
sfd
=
ufd
[
i
].
fd
;
int
fd
=
accept
(
sfd
,
NULL
,
NULL
);
int
fd
=
net_AcceptSingle
(
p_this
,
sfd
);
if
(
fd
==
-
1
)
if
(
fd
==
-
1
)
{
msg_Err
(
p_this
,
"accept failed (%m)"
);
continue
;
continue
;
}
net_SetupSocket
(
fd
);
/*
/*
* Move listening socket to the end to let the others in the
* Move listening socket to the end to let the others in the
...
@@ -327,7 +339,6 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
...
@@ -327,7 +339,6 @@ int __net_Accept( vlc_object_t *p_this, int *pi_fd, mtime_t i_wait )
memmove
(
pi_fd
+
i
,
pi_fd
+
i
+
1
,
n
-
(
i
+
1
));
memmove
(
pi_fd
+
i
,
pi_fd
+
i
+
1
,
n
-
(
i
+
1
));
pi_fd
[
n
-
1
]
=
sfd
;
pi_fd
[
n
-
1
]
=
sfd
;
vlc_object_unlock
(
p_this
);
vlc_object_unlock
(
p_this
);
msg_Dbg
(
p_this
,
"accepted socket %d (from socket %d)"
,
fd
,
sfd
);
return
fd
;
return
fd
;
}
}
}
}
...
...
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