mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-09-29 04:25:55 -04:00
resync with trunk
svn path=/icecast/branches/kh/icecast/; revision=8119
This commit is contained in:
parent
c71366088e
commit
b5cb8e5d94
@ -820,8 +820,8 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node,
|
||||
_add_server(doc, node->xmlChildrenNode, configuration);
|
||||
} else if (strcmp(node->name, "touch-interval") == 0) {
|
||||
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
|
||||
configuration->yp_touch_interval[configuration->num_yp_directories]
|
||||
= atoi(tmp);
|
||||
configuration->yp_touch_interval[configuration->num_yp_directories] =
|
||||
atoi(tmp);
|
||||
if (tmp) xmlFree(tmp);
|
||||
}
|
||||
} while ((node = node->next));
|
||||
@ -994,3 +994,4 @@ static void _add_server(xmlDocPtr doc, xmlNodePtr node,
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -245,9 +245,7 @@ static connection_t *_accept_connection(void)
|
||||
}
|
||||
|
||||
if (!sock_recoverable(sock_error()))
|
||||
{
|
||||
WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error()));
|
||||
}
|
||||
|
||||
free(ip);
|
||||
|
||||
@ -749,9 +747,6 @@ static void _handle_get_request(connection_t *con,
|
||||
}
|
||||
alias = config->aliases;
|
||||
client_limit = config->client_limit;
|
||||
|
||||
|
||||
stats_event_inc(NULL, "client_connections");
|
||||
|
||||
/* there are several types of HTTP GET clients
|
||||
** media clients, which are looking for a source (eg, URI = /stream.ogg)
|
||||
@ -776,6 +771,7 @@ static void _handle_get_request(connection_t *con,
|
||||
|
||||
/* make a client */
|
||||
client = client_create(con, parser);
|
||||
stats_event_inc(NULL, "client_connections");
|
||||
|
||||
/* Dispatch all admin requests */
|
||||
if (strncmp(uri, "/admin/", 7) == 0) {
|
||||
|
@ -38,6 +38,60 @@
|
||||
int errorlog = 0;
|
||||
int accesslog = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Since strftime's %z option on win32 is different, we need
|
||||
to go through a few loops to get the same info as %z */
|
||||
int get_clf_time (char *buffer, unsigned len, struct tm *t)
|
||||
{
|
||||
char sign;
|
||||
char *timezone_string;
|
||||
struct tm gmt;
|
||||
time_t time1 = time(NULL);
|
||||
int time_days, time_hours, time_tz;
|
||||
int tempnum1, tempnum2;
|
||||
struct tm *thetime;
|
||||
time_t now;
|
||||
|
||||
gmtime_r(&time1, &gmt);
|
||||
|
||||
time_days = t->tm_yday - gmt.tm_yday;
|
||||
|
||||
if (time_days < -1) {
|
||||
tempnum1 = 24;
|
||||
}
|
||||
else {
|
||||
tempnum1 = 1;
|
||||
}
|
||||
if (tempnum1 < time_days) {
|
||||
tempnum2 = -24;
|
||||
}
|
||||
else {
|
||||
tempnum2 = time_days*24;
|
||||
}
|
||||
|
||||
time_hours = (tempnum2 + t->tm_hour - gmt.tm_hour);
|
||||
time_tz = time_hours * 60 + t->tm_min - gmt.tm_min;
|
||||
|
||||
if (time_tz < 0) {
|
||||
sign = '-';
|
||||
time_tz = -time_tz;
|
||||
}
|
||||
else {
|
||||
sign = '+';
|
||||
}
|
||||
|
||||
timezone_string = calloc(1, 7);
|
||||
snprintf(timezone_string, 7, " %c%.2d%.2d", sign, time_tz / 60, time_tz % 60);
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
thetime = localtime(&now);
|
||||
strftime (buffer, len-7, "%d/%b/%Y:%H:%M:%S", thetime);
|
||||
strcat(buffer, timezone_string);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME]
|
||||
**
|
||||
@ -64,10 +118,14 @@ void logging_access(client_t *client)
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
/* build the data */
|
||||
localtime_r (&now, &thetime);
|
||||
/* build the data */
|
||||
#ifdef _WIN32
|
||||
memset(datebuf, '\000', sizeof(datebuf));
|
||||
get_clf_time(datebuf, sizeof(datebuf)-1, &thetime);
|
||||
#else
|
||||
strftime (datebuf, sizeof(datebuf), LOGGING_FORMAT_CLF, &thetime);
|
||||
|
||||
#endif
|
||||
/* build the request */
|
||||
snprintf (reqbuf, sizeof(reqbuf), "%s %s %s/%s",
|
||||
httpp_getvar (client->parser, HTTPP_VAR_REQ_TYPE),
|
||||
|
29
src/main.c
29
src/main.c
@ -181,32 +181,43 @@ static int _start_logging(void)
|
||||
char fn_error[FILENAME_MAX];
|
||||
char fn_access[FILENAME_MAX];
|
||||
char buf[1024];
|
||||
int log_to_stderr;
|
||||
|
||||
ice_config_t *config = config_get_config_unlocked();
|
||||
|
||||
if(strcmp(config->error_log, "-")) {
|
||||
snprintf(fn_error, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->error_log);
|
||||
errorlog = log_open(fn_error);
|
||||
log_to_stderr = 0;
|
||||
} else {
|
||||
errorlog = log_open_file(stderr);
|
||||
log_to_stderr = 1;
|
||||
}
|
||||
|
||||
if (errorlog < 0)
|
||||
{
|
||||
snprintf (buf, sizeof(buf), "FATAL: could not open error logging: %s", strerror(errno));
|
||||
_fatal_error (buf);
|
||||
if (errorlog < 0) {
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"FATAL: could not open error logging (%s): %s",
|
||||
log_to_stderr?"standard error":fn_error,
|
||||
strerror(errno));
|
||||
_fatal_error(buf);
|
||||
}
|
||||
log_set_level(errorlog, config->loglevel);
|
||||
|
||||
if(strcmp(config->access_log, "-")) {
|
||||
snprintf(fn_access, FILENAME_MAX, "%s%s%s", config->log_dir, PATH_SEPARATOR, config->access_log);
|
||||
accesslog = log_open(fn_access);
|
||||
log_to_stderr = 0;
|
||||
} else {
|
||||
accesslog = log_open_file(stderr);
|
||||
log_to_stderr = 1;
|
||||
}
|
||||
|
||||
if (accesslog < 0)
|
||||
{
|
||||
snprintf (buf, sizeof(buf), "FATAL: could not open access logging: %s",
|
||||
if (accesslog < 0) {
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
snprintf(buf, sizeof(buf)-1,
|
||||
"FATAL: could not open access logging (%s): %s",
|
||||
log_to_stderr?"standard error":fn_access,
|
||||
strerror(errno));
|
||||
_fatal_error(buf);
|
||||
}
|
||||
@ -397,7 +408,7 @@ int main(int argc, char **argv)
|
||||
_fatal_error(pbuf);
|
||||
switch (ret) {
|
||||
case CONFIG_EINSANE:
|
||||
_fatal_error("filename was null of blank");
|
||||
_fatal_error("filename was null or blank");
|
||||
break;
|
||||
case CONFIG_ENOROOT:
|
||||
_fatal_error("no root element found");
|
||||
@ -437,7 +448,7 @@ int main(int argc, char **argv)
|
||||
* assume */
|
||||
if(!getuid()) /* Running as root! Don't allow this */
|
||||
{
|
||||
fprintf(stderr, "WARNING: You should not run icecast2 as root\n");
|
||||
fprintf(stderr, "ERROR: You should not run icecast2 as root\n");
|
||||
fprintf(stderr, "Use the changeowner directive in the config file\n");
|
||||
_shutdown_subsystems();
|
||||
return 1;
|
||||
|
@ -80,7 +80,7 @@ relay_server *relay_free (relay_server *relay)
|
||||
xmlFree (relay->localmount);
|
||||
xmlFree (relay->username);
|
||||
xmlFree (relay->password);
|
||||
xmlFree (relay);
|
||||
free (relay);
|
||||
return next;
|
||||
}
|
||||
|
||||
@ -344,7 +344,7 @@ static void check_relay_stream (relay_server *relay)
|
||||
{
|
||||
if (relay->localmount[0] != '/')
|
||||
{
|
||||
WARN1 ("relay mountpoint \"%s\" does not start with /",
|
||||
WARN1 ("relay mountpoint \"%s\" does not start with /, skipping",
|
||||
relay->localmount);
|
||||
return;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#define vsnprintf _vsnprintf
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define STATS_EVENT_SET 0
|
||||
@ -115,8 +116,8 @@ static void queue_global_event (stats_event_t *event)
|
||||
node = node->next;
|
||||
node->next = event;
|
||||
}
|
||||
// DEBUG3("event added (%s, %s, %s)", event->source,
|
||||
// event->name, event->value);
|
||||
/* DEBUG3("event added (%s, %s, %s)", event->source,
|
||||
event->name, event->value); */
|
||||
thread_mutex_unlock(&_global_event_mutex);
|
||||
}
|
||||
|
||||
@ -420,7 +421,7 @@ static void modify_node_event (stats_node_t *node, stats_event_t *event)
|
||||
str = (char *)strdup (event->value);
|
||||
free (node->value);
|
||||
node->value = str;
|
||||
// DEBUG3 ("update node %s \"%s\" (%d)", node->name, node->value, event->action);
|
||||
/* DEBUG3 ("update node %s \"%s\" (%d)", node->name, node->value, event->action); */
|
||||
}
|
||||
|
||||
|
||||
|
6
src/yp.c
6
src/yp.c
@ -84,7 +84,7 @@ typedef struct ypdata_tag
|
||||
static rwlock_t yp_lock;
|
||||
static mutex_t yp_pending_lock;
|
||||
|
||||
static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
|
||||
volatile static struct yp_server *active_yps = NULL, *pending_yps = NULL;
|
||||
static volatile int yp_update = 0;
|
||||
static int yp_running;
|
||||
static time_t now;
|
||||
@ -546,8 +546,8 @@ static ypdata_t *create_yp_entry (source_t *source)
|
||||
/* Check for changes in the YP servers configured */
|
||||
static void check_servers ()
|
||||
{
|
||||
struct yp_server *server = (struct yp_server *)active_yps,
|
||||
**server_p = (struct yp_server **)&active_yps;
|
||||
struct yp_server *server = (struct yp_server *)active_yps,
|
||||
**server_p = (struct yp_server **)&active_yps;
|
||||
|
||||
while (server)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user