Commit af1c8da6 authored by Karl Heyes's avatar Karl Heyes

more sock_t cleanups, win32 should have less warnings now

svn path=/icecast/trunk/icecast/; revision=14043
parent 089dd4c2
...@@ -438,7 +438,7 @@ void connection_uses_ssl (connection_t *con) ...@@ -438,7 +438,7 @@ void connection_uses_ssl (connection_t *con)
#endif #endif
} }
static int wait_for_serversock(int timeout) static sock_t wait_for_serversock(int timeout)
{ {
#ifdef HAVE_POLL #ifdef HAVE_POLL
struct pollfd ufds [global.server_sockets]; struct pollfd ufds [global.server_sockets];
...@@ -452,10 +452,10 @@ static int wait_for_serversock(int timeout) ...@@ -452,10 +452,10 @@ static int wait_for_serversock(int timeout)
ret = poll(ufds, global.server_sockets, timeout); ret = poll(ufds, global.server_sockets, timeout);
if(ret < 0) { if(ret < 0) {
return -2; return SOCK_ERROR;
} }
else if(ret == 0) { else if(ret == 0) {
return -1; return SOCK_ERROR;
} }
else { else {
int dst; int dst;
...@@ -466,35 +466,35 @@ static int wait_for_serversock(int timeout) ...@@ -466,35 +466,35 @@ static int wait_for_serversock(int timeout)
{ {
if (ufds[i].revents & (POLLHUP|POLLERR)) if (ufds[i].revents & (POLLHUP|POLLERR))
{ {
close (global.serversock[i]); sock_close (global.serversock[i]);
WARN0("Had to close a listening socket"); WARN0("Had to close a listening socket");
} }
global.serversock[i] = -1; global.serversock[i] = SOCK_ERROR;
} }
} }
/* remove any closed sockets */ /* remove any closed sockets */
for(i=0, dst=0; i < global.server_sockets; i++) for(i=0, dst=0; i < global.server_sockets; i++)
{ {
if (global.serversock[i] == -1) if (global.serversock[i] == SOCK_ERROR)
continue; continue;
if (i!=dst) if (i!=dst)
global.serversock[dst] = global.serversock[i]; global.serversock[dst] = global.serversock[i];
dst++; dst++;
} }
global.server_sockets = dst; global.server_sockets = dst;
return -1; return SOCK_ERROR;
} }
#else #else
fd_set rfds; fd_set rfds;
struct timeval tv, *p=NULL; struct timeval tv, *p=NULL;
int i, ret; int i, ret;
int max = -1; sock_t max = SOCK_ERROR;
FD_ZERO(&rfds); FD_ZERO(&rfds);
for(i=0; i < global.server_sockets; i++) { for(i=0; i < global.server_sockets; i++) {
FD_SET(global.serversock[i], &rfds); FD_SET(global.serversock[i], &rfds);
if(global.serversock[i] > max) if (max == SOCK_ERROR || global.serversock[i] > max)
max = global.serversock[i]; max = global.serversock[i];
} }
...@@ -506,36 +506,35 @@ static int wait_for_serversock(int timeout) ...@@ -506,36 +506,35 @@ static int wait_for_serversock(int timeout)
ret = select(max+1, &rfds, NULL, NULL, p); ret = select(max+1, &rfds, NULL, NULL, p);
if(ret < 0) { if(ret < 0) {
return -2; return SOCK_ERROR;
} }
else if(ret == 0) { else if(ret == 0) {
return -1; return SOCK_ERROR;
} }
else { else {
for(i=0; i < global.server_sockets; i++) { for(i=0; i < global.server_sockets; i++) {
if(FD_ISSET(global.serversock[i], &rfds)) if(FD_ISSET(global.serversock[i], &rfds))
return global.serversock[i]; return global.serversock[i];
} }
return -1; /* Should be impossible, stop compiler warnings */ return SOCK_ERROR; /* Should be impossible, stop compiler warnings */
} }
#endif #endif
} }
static connection_t *_accept_connection(void) static connection_t *_accept_connection(void)
{ {
int sock; sock_t sock, serversock;
char *ip; char *ip;
int serversock;
serversock = wait_for_serversock(100); serversock = wait_for_serversock(100);
if(serversock < 0) if (serversock == SOCK_ERROR)
return NULL; return NULL;
/* malloc enough room for a full IP address (including ipv6) */ /* malloc enough room for a full IP address (including ipv6) */
ip = (char *)malloc(MAX_ADDR_LEN); ip = (char *)malloc(MAX_ADDR_LEN);
sock = sock_accept(serversock, ip, MAX_ADDR_LEN); sock = sock_accept(serversock, ip, MAX_ADDR_LEN);
if (sock >= 0) if (sock != SOCK_ERROR)
{ {
connection_t *con = NULL; connection_t *con = NULL;
/* Make any IPv4 mapped IPv6 address look like a normal IPv4 address */ /* Make any IPv4 mapped IPv6 address look like a normal IPv4 address */
......
...@@ -37,8 +37,8 @@ typedef struct connection_tag ...@@ -37,8 +37,8 @@ typedef struct connection_tag
time_t discon_time; time_t discon_time;
uint64_t sent_bytes; uint64_t sent_bytes;
int sock; sock_t sock;
int serversock; sock_t serversock;
int error; int error;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
......
...@@ -20,14 +20,13 @@ ...@@ -20,14 +20,13 @@
#define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION #define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION
#define MAX_LISTEN_SOCKETS 20
#include "thread/thread.h" #include "thread/thread.h"
#include "slave.h" #include "slave.h"
#include "net/sock.h"
typedef struct ice_global_tag typedef struct ice_global_tag
{ {
int *serversock; sock_t *serversock;
int server_sockets; int server_sockets;
int running; int running;
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
* 0 if no activity occurs * 0 if no activity occurs
* < 0 for error. * < 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 #ifdef HAVE_POLL
struct pollfd ufds; struct pollfd ufds;
...@@ -84,7 +84,7 @@ int util_timed_wait_for_fd(int fd, int timeout) ...@@ -84,7 +84,7 @@ int util_timed_wait_for_fd(int fd, int timeout)
#endif #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; int read_bytes, ret;
unsigned long pos; unsigned long pos;
......
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#define MAX_LINE_LEN 512 #define MAX_LINE_LEN 512
int util_timed_wait_for_fd(int fd, int timeout); int util_timed_wait_for_fd(sock_t fd, int timeout);
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 util_check_valid_extension(const char *uri); int util_check_valid_extension(const char *uri);
char *util_get_extension(const char *path); char *util_get_extension(const char *path);
char *util_get_path_from_uri(char *uri); char *util_get_path_from_uri(char *uri);
......
...@@ -41,7 +41,7 @@ RSC=rc.exe ...@@ -41,7 +41,7 @@ RSC=rc.exe
# PROP Intermediate_Dir "Releaseicecast" # PROP Intermediate_Dir "Releaseicecast"
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # 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 BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment