Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
spr0cketeer
Icecast-common
Commits
81ca1569
Commit
81ca1569
authored
Feb 05, 2008
by
Karl Heyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use poll if available, select can cause stack corruption if descriptor value is over 1024
svn path=/icecast/trunk/net/; revision=14457
parent
e5be87d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
net/sock.c
net/sock.c
+24
-0
No files found.
net/sock.c
View file @
81ca1569
...
...
@@ -30,6 +30,9 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#ifdef HAVE_POLL
#include <poll.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
...
...
@@ -508,6 +511,26 @@ int sock_read_line(sock_t sock, char *buff, const int len)
* return 0 for try again, interrupted
* return 1 for ok
*/
#ifdef HAVE_POLL
int
sock_connected
(
sock_t
sock
,
int
timeout
)
{
struct
pollfd
check
;
check
.
fd
=
sock
;
check
.
events
=
POLLOUT
;
switch
(
poll
(
&
check
,
1
,
timeout
*
1000
))
{
case
0
:
return
SOCK_TIMEOUT
;
case
-
1
:
if
(
sock_recoverable
(
sock_error
()))
return
0
;
return
SOCK_ERROR
;
default:
return
1
;
}
}
#else
int
sock_connected
(
sock_t
sock
,
int
timeout
)
{
fd_set
wfds
;
...
...
@@ -545,6 +568,7 @@ int sock_connected (sock_t sock, int timeout)
return
SOCK_ERROR
;
}
}
#endif
#ifdef HAVE_GETADDRINFO
...
...
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