Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
f3743d45
Commit
f3743d45
authored
Feb 21, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Use poll in net_Accept
- Fix som bugs
parent
52b0f7ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
39 deletions
+34
-39
src/network/tcp.c
src/network/tcp.c
+34
-39
No files found.
src/network/tcp.c
View file @
f3743d45
...
@@ -40,6 +40,9 @@
...
@@ -40,6 +40,9 @@
#ifdef HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
# include <unistd.h>
#endif
#endif
#ifdef HAVE_POLL
# include <poll.h>
#endif
#include <vlc_network.h>
#include <vlc_network.h>
#if defined (WIN32) || defined (UNDER_CE)
#if defined (WIN32) || defined (UNDER_CE)
...
@@ -272,50 +275,43 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
...
@@ -272,50 +275,43 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
while
(
!
p_this
->
b_die
)
while
(
!
p_this
->
b_die
)
{
{
int
maxfd
=
-
1
;
unsigned
n
=
0
;
fd_set
readset
;
while
(
pi_fd
[
n
]
!=
-
1
)
n
++
;
struct
pollfd
ufd
[
n
];
/* Initialize file descriptor set */
/* Initialize file descriptor set */
FD_ZERO
(
&
readset
);
for
(
unsigned
i
=
0
;
i
<
n
;
i
++
)
int
*
pi_end
=
pi_fd
;
for
(
const
int
*
pi
=
pi_fd
;
*
pi
!=
-
1
;
pi
++
)
{
{
int
fd
=
*
pi
;
ufd
[
i
].
fd
=
pi_fd
[
i
];
ufd
[
i
].
events
=
POLLIN
;
if
(
fd
>
maxfd
)
ufd
[
i
].
revents
=
0
;
maxfd
=
fd
;
FD_SET
(
fd
,
&
readset
);
pi_end
++
;
}
}
s
truct
timeval
tv
=
{
0
,
b_block
?
500000
:
i_wait
};
s
witch
(
poll
(
ufd
,
n
,
b_block
?
500
:
i_wait
))
{
int
val
=
select
(
maxfd
+
1
,
&
readset
,
NULL
,
NULL
,
&
tv
);
case
-
1
:
if
(
val
==
0
)
if
(
net_errno
!=
EINTR
)
{
{
msg_Err
(
p_this
,
"poll error: %s"
,
net_strerror
(
net_errno
));
}
return
-
1
;
case
0
:
if
(
b_block
)
if
(
b_block
)
continue
;
continue
;
return
-
1
;
return
-
1
;
}
}
if
(
val
<
0
)
{
if
(
net_errno
!=
EINTR
)
msg_Err
(
p_this
,
"network select error (%s)"
,
net_strerror
(
net_errno
)
);
return
-
1
;
}
for
(
const
int
*
pi
=
pi_fd
;
*
pi
!=
-
1
;
p
i
++
)
for
(
unsigned
i
=
0
;
i
<
n
;
i
++
)
{
{
int
fd
=
*
pi
;
if
(
ufd
[
i
].
revents
==
0
)
if
(
!
FD_ISSET
(
fd
,
&
readset
))
continue
;
continue
;
fd
=
accept
(
fd
,
NULL
,
0
);
int
sfd
=
ufd
[
i
].
fd
;
if
(
fd
<
0
)
int
fd
=
accept
(
sfd
,
NULL
,
NULL
);
if
(
fd
==
-
1
)
{
{
msg_Err
(
p_this
,
"accept failed (%s)"
,
msg_Err
(
p_this
,
"accept failed (%s)"
,
net_strerror
(
net_errno
));
net_strerror
(
net_errno
));
...
@@ -324,13 +320,12 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
...
@@ -324,13 +320,12 @@ int __net_Accept( vlc_object_t *p_this, int pi_fd[], mtime_t i_wait )
net_SetupSocket
(
fd
);
net_SetupSocket
(
fd
);
/*
/*
*
This round-robin trick ensures that the first sockets in
*
Move listening socket to the end to let the others in the
*
pi_fd won't prevent the last ones from getting accept'ed
.
*
set a chance next time
.
*/
*/
--
pi_end
;
memmove
(
pi_fd
+
i
,
pi_fd
+
i
+
1
,
n
-
(
i
+
1
));
memmove
(
pi_fd
,
pi_fd
+
1
,
pi_end
-
pi_fd
);
pi_fd
[
n
-
1
]
=
sfd
;
*
pi_end
=
*
pi
;
msg_Dbg
(
p_this
,
"accepted socket %d (from socket %d)"
,
fd
,
sfd
);
msg_Dbg
(
p_this
,
"accepted socket %d (from socket %d)"
,
fd
,
*
pi
);
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