Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
1a0ad6c1
Commit
1a0ad6c1
authored
Nov 24, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32: fix poll() with more than 64 sockets
parent
899a6313
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
27 deletions
+46
-27
src/network/poll.c
src/network/poll.c
+46
-27
No files found.
src/network/poll.c
View file @
1a0ad6c1
...
@@ -70,23 +70,37 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
...
@@ -70,23 +70,37 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
(
void
)
fds
;
(
void
)
nfds
;
(
void
)
timeout
;
(
void
)
fds
;
(
void
)
nfds
;
(
void
)
timeout
;
abort
();
abort
();
}
}
#else
/* !HAVE_POLL */
#elif defined (WIN32)
#include <string.h>
#include <string.h>
#include <errno.h>
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
int
vlc_poll
(
struct
pollfd
*
fds
,
unsigned
nfds
,
int
timeout
)
{
{
fd_set
rdset
,
wrset
,
exset
;
size_t
setsize
=
sizeof
(
fd_set
)
+
(
nfds
-
FD_SETSIZE
)
*
sizeof
(
SOCKET
);
fd_set
*
rdset
=
malloc
(
setsize
);
fd_set
*
wrset
=
malloc
(
setsize
);
fd_set
*
exset
=
malloc
(
setsize
);
struct
timeval
tv
=
{
0
,
0
};
struct
timeval
tv
=
{
0
,
0
};
int
val
;
int
val
;
if
(
unlikely
(
rdset
==
NULL
||
wrset
==
NULL
||
exset
==
NULL
))
{
free
(
rdset
);
free
(
wrset
);
free
(
exset
);
errno
=
ENOMEM
;
return
-
1
;
}
resume:
resume:
val
=
-
1
;
val
=
-
1
;
vlc_testcancel
();
vlc_testcancel
();
FD_ZERO
(
&
rdset
);
FD_ZERO
(
rdset
);
FD_ZERO
(
&
wrset
);
FD_ZERO
(
wrset
);
FD_ZERO
(
&
exset
);
FD_ZERO
(
exset
);
for
(
unsigned
i
=
0
;
i
<
nfds
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
nfds
;
i
++
)
{
{
int
fd
=
fds
[
i
].
fd
;
int
fd
=
fds
[
i
].
fd
;
...
@@ -100,16 +114,15 @@ resume:
...
@@ -100,16 +114,15 @@ resume:
* on systems (such as BSD) that have no process open files limit by
* on systems (such as BSD) that have no process open files limit by
* default, such that it is quite feasible to get fd >= FD_SETSIZE.
* default, such that it is quite feasible to get fd >= FD_SETSIZE.
* The next instructions will result in a buffer overflow if run on
* The next instructions will result in a buffer overflow if run on
* a POSIX system, and the later FD_ISSET will do undefined memory
* a POSIX system, and the later FD_ISSET would perform an undefined
* access
.
* memory read
.
*
*
* With Winsock, fd_set is a table of integers. This is awfully slow.
* With Winsock, fd_set is a table of integers. This is awfully slow.
* However, FD_SET and FD_ISSET silently and safely discard
* However, FD_SET and FD_ISSET silently and safely discard excess
* overflows. If it happens we will loose socket events. Note that
* entries. Here, overflow cannot happen anyway: fd_set of adequate
* most (if not all) Winsock SOCKET handles are actually bigger than
* size are allocated.
* FD_SETSIZE in terms of absolute value - they are not POSIX file
* Note that Vista has a much nicer WSAPoll(), but Mingw does not
* descriptors. From Vista, there is a much nicer WSAPoll(), but Mingw
* support it yet.
* is yet to support it.
*/
*/
if
(
fds
[
i
].
events
&
POLLIN
)
if
(
fds
[
i
].
events
&
POLLIN
)
FD_SET
((
SOCKET
)
fd
,
rdset
);
FD_SET
((
SOCKET
)
fd
,
rdset
);
...
@@ -135,7 +148,7 @@ resume:
...
@@ -135,7 +148,7 @@ resume:
tv
.
tv_usec
=
d
.
rem
*
1000
;
tv
.
tv_usec
=
d
.
rem
*
1000
;
}
}
val
=
select
(
val
+
1
,
&
rdset
,
&
wrset
,
&
exset
,
val
=
select
(
val
+
1
,
rdset
,
wrset
,
exset
,
/*(timeout >= 0) ?*/
&
tv
/*: NULL*/
);
/*(timeout >= 0) ?*/
&
tv
/*: NULL*/
);
#ifndef HAVE_ALERTABLE_SELECT
#ifndef HAVE_ALERTABLE_SELECT
...
@@ -154,10 +167,16 @@ resume:
...
@@ -154,10 +167,16 @@ resume:
for
(
unsigned
i
=
0
;
i
<
nfds
;
i
++
)
for
(
unsigned
i
=
0
;
i
<
nfds
;
i
++
)
{
{
int
fd
=
fds
[
i
].
fd
;
int
fd
=
fds
[
i
].
fd
;
fds
[
i
].
revents
=
(
FD_ISSET
(
fd
,
&
rdset
)
?
POLLIN
:
0
)
fds
[
i
].
revents
=
(
FD_ISSET
(
fd
,
rdset
)
?
POLLIN
:
0
)
|
(
FD_ISSET
(
fd
,
&
wrset
)
?
POLLOUT
:
0
)
|
(
FD_ISSET
(
fd
,
wrset
)
?
POLLOUT
:
0
)
|
(
FD_ISSET
(
fd
,
&
exset
)
?
POLLPRI
:
0
);
|
(
FD_ISSET
(
fd
,
exset
)
?
POLLPRI
:
0
);
}
}
free
(
exset
);
free
(
wrset
);
free
(
rdset
);
return
val
;
return
val
;
}
}
#endif
/* !HAVE_POLL */
#else
# error poll() not implemented!
#endif
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