1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

more sock_t cleanups, win32 should have less warnings now

svn path=/icecast/trunk/icecast/; revision=14043
This commit is contained in:
Karl Heyes 2007-10-24 22:42:49 +00:00
parent 089dd4c273
commit af1c8da6b6
6 changed files with 24 additions and 26 deletions

View File

@ -438,7 +438,7 @@ void connection_uses_ssl (connection_t *con)
#endif
}
static int wait_for_serversock(int timeout)
static sock_t wait_for_serversock(int timeout)
{
#ifdef HAVE_POLL
struct pollfd ufds [global.server_sockets];
@ -452,10 +452,10 @@ static int wait_for_serversock(int timeout)
ret = poll(ufds, global.server_sockets, timeout);
if(ret < 0) {
return -2;
return SOCK_ERROR;
}
else if(ret == 0) {
return -1;
return SOCK_ERROR;
}
else {
int dst;
@ -466,35 +466,35 @@ static int wait_for_serversock(int timeout)
{
if (ufds[i].revents & (POLLHUP|POLLERR))
{
close (global.serversock[i]);
sock_close (global.serversock[i]);
WARN0("Had to close a listening socket");
}
global.serversock[i] = -1;
global.serversock[i] = SOCK_ERROR;
}
}
/* remove any closed sockets */
for(i=0, dst=0; i < global.server_sockets; i++)
{
if (global.serversock[i] == -1)
if (global.serversock[i] == SOCK_ERROR)
continue;
if (i!=dst)
global.serversock[dst] = global.serversock[i];
dst++;
}
global.server_sockets = dst;
return -1;
return SOCK_ERROR;
}
#else
fd_set rfds;
struct timeval tv, *p=NULL;
int i, ret;
int max = -1;
sock_t max = SOCK_ERROR;
FD_ZERO(&rfds);
for(i=0; i < global.server_sockets; i++) {
FD_SET(global.serversock[i], &rfds);
if(global.serversock[i] > max)
if (max == SOCK_ERROR || global.serversock[i] > max)
max = global.serversock[i];
}
@ -506,36 +506,35 @@ static int wait_for_serversock(int timeout)
ret = select(max+1, &rfds, NULL, NULL, p);
if(ret < 0) {
return -2;
return SOCK_ERROR;
}
else if(ret == 0) {
return -1;
return SOCK_ERROR;
}
else {
for(i=0; i < global.server_sockets; i++) {
if(FD_ISSET(global.serversock[i], &rfds))
return global.serversock[i];
}
return -1; /* Should be impossible, stop compiler warnings */
return SOCK_ERROR; /* Should be impossible, stop compiler warnings */
}
#endif
}
static connection_t *_accept_connection(void)
{
int sock;
sock_t sock, serversock;
char *ip;
int serversock;
serversock = wait_for_serversock(100);
if(serversock < 0)
if (serversock == SOCK_ERROR)
return NULL;
/* malloc enough room for a full IP address (including ipv6) */
ip = (char *)malloc(MAX_ADDR_LEN);
sock = sock_accept(serversock, ip, MAX_ADDR_LEN);
if (sock >= 0)
if (sock != SOCK_ERROR)
{
connection_t *con = NULL;
/* Make any IPv4 mapped IPv6 address look like a normal IPv4 address */

View File

@ -37,8 +37,8 @@ typedef struct connection_tag
time_t discon_time;
uint64_t sent_bytes;
int sock;
int serversock;
sock_t sock;
sock_t serversock;
int error;
#ifdef HAVE_OPENSSL

View File

@ -20,14 +20,13 @@
#define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION
#define MAX_LISTEN_SOCKETS 20
#include "thread/thread.h"
#include "slave.h"
#include "net/sock.h"
typedef struct ice_global_tag
{
int *serversock;
sock_t *serversock;
int server_sockets;
int running;

View File

@ -58,7 +58,7 @@
* 0 if no activity occurs
* < 0 for error.
*/
int util_timed_wait_for_fd(int fd, int timeout)
int util_timed_wait_for_fd(sock_t fd, int timeout)
{
#ifdef HAVE_POLL
struct pollfd ufds;
@ -84,7 +84,7 @@ int util_timed_wait_for_fd(int fd, int timeout)
#endif
}
int util_read_header(int sock, char *buff, unsigned long len, int entire)
int util_read_header(sock_t sock, char *buff, unsigned long len, int entire)
{
int read_bytes, ret;
unsigned long pos;

View File

@ -21,8 +21,8 @@
#define MAX_LINE_LEN 512
int util_timed_wait_for_fd(int fd, int timeout);
int util_read_header(int sock, char *buff, unsigned long len, int entire);
int util_timed_wait_for_fd(sock_t fd, int timeout);
int util_read_header(sock_t sock, char *buff, unsigned long len, int entire);
int util_check_valid_extension(const char *uri);
char *util_get_extension(const char *path);
char *util_get_path_from_uri(char *uri);

View File

@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Releaseicecast"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../curl/include" /I "..\src" /I "..\src/httpp" /I "..\src/thread" /I "..\src/log" /I "..\src/avl" /I "..\src/net" /I "..\src/timings" /I "../" /I "../../libxslt/include" /I "../../iconv/include" /I "../../libxml2/include" /I "../../pthreads" /I "../../oggvorbis-win32sdk-1.0.1/include" /I "../../theora/include" /I "../../speex/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_CURL" /D "USE_YP" /D "HAVE_SYS_STAT_H" /D PACKAGE_VERSION=\"2.3.1\" /D "HAVE_LOCALTIME_R" /D "HAVE_OLD_VSNPRINTF" /D "HAVE_THEORA" /D "HAVE_SPEEX" /D "HAVE_AUTH_URL" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../curl/include" /I "..\src" /I "..\src/httpp" /I "..\src/thread" /I "..\src/log" /I "..\src/avl" /I "..\src/net" /I "..\src/timings" /I "../" /I "../../libxslt/include" /I "../../iconv/include" /I "../../libxml2/include" /I "../../pthreads" /I "../../oggvorbis-win32sdk-1.0.1/include" /I "../../theora/include" /I "../../speex/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_CURL" /D "USE_YP" /D "HAVE_SYS_STAT_H" /D PACKAGE_VERSION=\"2.3.2pre\" /D "HAVE_LOCALTIME_R" /D "HAVE_OLD_VSNPRINTF" /D "HAVE_THEORA" /D "HAVE_SPEEX" /D "HAVE_AUTH_URL" /D sock_t=SOCKET /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe