[xiph-commits] r8119 - icecast/branches/kh/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Wed Oct 27 05:57:14 PDT 2004


Author: karl
Date: 2004-10-27 05:57:13 -0700 (Wed, 27 Oct 2004)
New Revision: 8119

Modified:
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/main.c
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/stats.c
   icecast/branches/kh/icecast/src/yp.c
Log:
resync with trunk


Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -820,8 +820,8 @@
             _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 @@
     
 }
 
+

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/connection.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -245,9 +245,7 @@
     }
 
     if (!sock_recoverable(sock_error()))
-    {
         WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error()));
-    }
     
     free(ip);
 
@@ -749,9 +747,6 @@
     }
     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 @@
 
     /* make a client */
     client = client_create(con, parser);
+    stats_event_inc(NULL, "client_connections");
 
     /* Dispatch all admin requests */
     if (strncmp(uri, "/admin/", 7) == 0) {

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/logging.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -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 @@
 
     now = time(NULL);
 
+    localtime_r (&now, &thetime);
     /* build the data */
-    localtime_r (&now, &thetime);
+#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),

Modified: icecast/branches/kh/icecast/src/main.c
===================================================================
--- icecast/branches/kh/icecast/src/main.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/main.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -181,32 +181,43 @@
     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 @@
             _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 @@
      * 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;

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/slave.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -80,7 +80,7 @@
     xmlFree (relay->localmount);
     xmlFree (relay->username);
     xmlFree (relay->password);
-    xmlFree (relay);
+    free (relay);
     return next;
 }
 
@@ -344,7 +344,7 @@
     {
         if (relay->localmount[0] != '/')
         {
-            WARN1 ("relay mountpoint \"%s\" does not start with /",
+            WARN1 ("relay mountpoint \"%s\" does not start with /, skipping",
                     relay->localmount);
             return;
         }

Modified: icecast/branches/kh/icecast/src/stats.c
===================================================================
--- icecast/branches/kh/icecast/src/stats.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/stats.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -40,6 +40,7 @@
 
 #ifdef _WIN32
 #define vsnprintf _vsnprintf
+#define snprintf _snprintf
 #endif
 
 #define STATS_EVENT_SET     0
@@ -115,8 +116,8 @@
             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 @@
         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); */
 }
 
 

Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2004-10-27 12:49:28 UTC (rev 8118)
+++ icecast/branches/kh/icecast/src/yp.c	2004-10-27 12:57:13 UTC (rev 8119)
@@ -84,7 +84,7 @@
 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 @@
 /* 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)
     {



More information about the commits mailing list