mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Config fixes for when parsing fails
Don't needlessly call getsockopt() all the time (it's a system call, hence expensive) svn path=/trunk/icecast/; revision=3735
This commit is contained in:
parent
59e523a023
commit
3e60ee06f6
@ -89,7 +89,7 @@ int config_parse_file(const char *filename)
|
||||
|
||||
doc = xmlParseFile(_config_filename);
|
||||
if (doc == NULL) {
|
||||
return -1;
|
||||
return CONFIG_EPARSE;
|
||||
}
|
||||
|
||||
node = xmlDocGetRootElement(doc);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#define CONFIG_EINSANE -1
|
||||
#define CONFIG_ENOROOT -2
|
||||
#define CONFIG_EBADROOT -3
|
||||
#define CONFIG_EPARSE -4
|
||||
|
||||
typedef struct ice_config_dir_tag
|
||||
{
|
||||
|
@ -277,6 +277,8 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "parse error\n");
|
||||
break;
|
||||
}
|
||||
_shutdown_subsystems();
|
||||
return 1;
|
||||
}
|
||||
} else if (res == -1) {
|
||||
_print_usage();
|
||||
|
@ -214,9 +214,9 @@ int sock_write_bytes(sock_t sock, const char *buff, const int len)
|
||||
return SOCK_ERROR;
|
||||
} else if (len <= 0) {
|
||||
return SOCK_ERROR;
|
||||
} else if (!sock_valid_socket(sock)) {
|
||||
} /*else if (!sock_valid_socket(sock)) {
|
||||
return SOCK_ERROR;
|
||||
}
|
||||
} */
|
||||
|
||||
return send(sock, buff, len, 0);
|
||||
}
|
||||
@ -251,9 +251,8 @@ int sock_write(sock_t sock, const char *fmt, ...)
|
||||
|
||||
int sock_read_bytes(sock_t sock, char *buff, const int len)
|
||||
{
|
||||
// int ret;
|
||||
|
||||
if (!sock_valid_socket(sock)) return 0;
|
||||
/*if (!sock_valid_socket(sock)) return 0; */
|
||||
if (!buff) return 0;
|
||||
if (len <= 0) return 0;
|
||||
|
||||
@ -273,9 +272,9 @@ int sock_read_line(sock_t sock, char *buff, const int len)
|
||||
char c = '\0';
|
||||
int read_bytes, pos;
|
||||
|
||||
if (!sock_valid_socket(sock)) {
|
||||
/*if (!sock_valid_socket(sock)) {
|
||||
return 0;
|
||||
} else if (!buff) {
|
||||
} else*/ if (!buff) {
|
||||
return 0;
|
||||
} else if (len <= 0) {
|
||||
return 0;
|
||||
@ -490,6 +489,7 @@ int sock_accept(sock_t serversock, char *ip, int len)
|
||||
ret = accept(serversock, (struct sockaddr *)&sin, &slen);
|
||||
|
||||
if (ret >= 0 && ip != NULL) {
|
||||
// inet_ntoa is not reentrant, we should protect this
|
||||
strncpy(ip, inet_ntoa(sin.sin_addr), len);
|
||||
sock_set_nolinger(ret);
|
||||
sock_set_keepalive(ret);
|
||||
|
Loading…
Reference in New Issue
Block a user