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

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Wed May 25 07:27:38 PDT 2005


Author: karl
Date: 2005-05-25 07:27:33 -0700 (Wed, 25 May 2005)
New Revision: 9311

Modified:
   icecast/branches/kh/icecast/src/admin.c
   icecast/branches/kh/icecast/src/logging.c
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/source.h
Log:
don't duplicate the setting for the [dis]connect scripts, lookup the mount
details when needed. Fix formating bug for win32 access.log


Modified: icecast/branches/kh/icecast/src/admin.c
===================================================================
--- icecast/branches/kh/icecast/src/admin.c	2005-05-25 05:45:35 UTC (rev 9310)
+++ icecast/branches/kh/icecast/src/admin.c	2005-05-25 14:27:33 UTC (rev 9311)
@@ -249,7 +249,7 @@
             xmlNewChild (srcnode, NULL, "fallback", 
                     (source->fallback_mount != NULL)?
                     source->fallback_mount:"");
-            snprintf (buf, sizeof(buf), "%u", source->listeners);
+            snprintf (buf, sizeof(buf), "%lu", source->listeners);
             xmlNewChild (srcnode, NULL, "listeners", buf);
 
             config = config_get_config();
@@ -714,7 +714,7 @@
     xmlDocSetRootElement(doc, node);
 
     memset(buf, '\000', sizeof(buf));
-    snprintf(buf, sizeof(buf)-1, "%u", source->listeners);
+    snprintf(buf, sizeof(buf), "%lu", source->listeners);
     xmlNewChild(srcnode, NULL, "Listeners", buf);
 
     current = source->active_clients;

Modified: icecast/branches/kh/icecast/src/logging.c
===================================================================
--- icecast/branches/kh/icecast/src/logging.c	2005-05-25 05:45:35 UTC (rev 9310)
+++ icecast/branches/kh/icecast/src/logging.c	2005-05-25 14:27:33 UTC (rev 9311)
@@ -145,14 +145,16 @@
         user_agent = "-";
 
 #ifdef HAVE_LOGGING_IP
-    log_write_direct (accesslog, "%s - - [%s] \"%s\" %d %lld \"%s\" \"%s\" %d",
-             client->con->ip,
-             datebuf, reqbuf, client->respcode, client->con->sent_bytes,
-             referrer, user_agent, (int)stayed);
+    log_write_direct (accesslog,
+            "%s - - [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
+            client->con->ip,
+            datebuf, reqbuf, client->respcode, client->con->sent_bytes,
+            referrer, user_agent, (unsigned long)stayed);
 #else
-    log_write_direct (accesslog, "- - - [%s] \"%s\" %d %lld \"%s\" \"%s\" %d",
-             datebuf, reqbuf, client->respcode, client->con->sent_bytes,
-             referrer, user_agent, (int)stayed);
+    log_write_direct (accesslog,
+            "- - - [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
+            datebuf, reqbuf, client->respcode, client->con->sent_bytes,
+            referrer, user_agent, (unsigned long)stayed);
 #endif
 }
 

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-05-25 05:45:35 UTC (rev 9310)
+++ icecast/branches/kh/icecast/src/source.c	2005-05-25 14:27:33 UTC (rev 9311)
@@ -261,12 +261,6 @@
         source->intro_file = NULL;
     }
 
-    free (source->on_connect);
-    source->on_connect = NULL;
-
-    free (source->on_disconnect);
-    source->on_disconnect = NULL;
-
     source->on_demand_req = 0;
 }
 
@@ -731,6 +725,7 @@
     char *str = "0";
     char buffer [100];
     struct tm local;
+    mount_proxy *mountinfo;
 
     thread_mutex_lock (&source->lock);
 
@@ -778,8 +773,10 @@
     strftime (buffer, sizeof (buffer), "%a, %d %b %Y %H:%M:%S %z", &local);
     stats_event (source->mount, "stream_start", buffer);
 
-    if (source->on_connect)
-        source_run_script (source->on_connect, source->mount);
+    mountinfo = config_find_mount (config_get_config(), source->mount);
+    if (mountinfo && mountinfo->on_connect)
+        source_run_script (mountinfo->on_connect, source->mount);
+    config_release_config();
 
     /*
     ** Now, if we have a fallback source and override is on, we want
@@ -860,12 +857,16 @@
 
 static void source_shutdown (source_t *source)
 {
+    mount_proxy *mountinfo;
+
     INFO1("Source \"%s\" exiting", source->mount);
     source->running = 0;
 
     auth_stream_end (source->mount);
-    if (source->on_disconnect)
-        source_run_script (source->on_disconnect, source->mount);
+    mountinfo = config_find_mount (config_get_config(), source->mount);
+    if (mountinfo && mountinfo->on_disconnect)
+        source_run_script (mountinfo->on_disconnect, source->mount);
+    config_release_config();
 
     /* we have de-activated the source now, so no more clients will be
      * added, now move the listeners we have to the fallback (if any)
@@ -1183,16 +1184,6 @@
     if (mountinfo && mountinfo->fallback_when_full)
         source->fallback_when_full = mountinfo->fallback_when_full;
 
-    free (source->on_connect);
-    source->on_connect = NULL;
-    if (mountinfo && mountinfo->on_connect)
-        source->on_connect = strdup (mountinfo->on_connect);
-
-    free (source->on_disconnect);
-    source->on_disconnect = NULL;
-    if (mountinfo && mountinfo->on_disconnect)
-        source->on_disconnect = strdup (mountinfo->on_disconnect);
-
     if (source->format && source->format->apply_settings)
         source->format->apply_settings (source->client, source->format, mountinfo);
 }
@@ -1217,10 +1208,10 @@
         DEBUG1 ("intro file is %s", source->intro_filename);
     if (source->dumpfilename)
         DEBUG1 ("Dumping stream to %s", source->dumpfilename);
-    if (source->on_connect)
-        DEBUG1 ("connect script \"%s\"", source->on_connect);
-    if (source->on_disconnect)
-        DEBUG1 ("disconnect script \"%s\"", source->on_disconnect);
+    if (mountinfo && mountinfo->on_connect)
+        DEBUG1 ("connect script \"%s\"", mountinfo->on_connect);
+    if (mountinfo && mountinfo->on_disconnect)
+        DEBUG1 ("disconnect script \"%s\"", mountinfo->on_disconnect);
     if (source->on_demand)
         DEBUG0 ("on_demand set");
     if (source->hidden)

Modified: icecast/branches/kh/icecast/src/source.h
===================================================================
--- icecast/branches/kh/icecast/src/source.h	2005-05-25 05:45:35 UTC (rev 9310)
+++ icecast/branches/kh/icecast/src/source.h	2005-05-25 14:27:33 UTC (rev 9311)
@@ -48,11 +48,12 @@
 
     /* name of a file, whose contents are sent at listener connection */
     char *intro_filename;
+    FILE *intro_file;
 
     char *dumpfilename; /* Name of a file to dump incoming stream to */
     FILE *dumpfile;
 
-    unsigned int listeners;
+    unsigned long listeners;
     long max_listeners;
     int yp_public;
     int fallback_override;
@@ -74,16 +75,12 @@
     int hidden;
 
     time_t last_read;
-    char *on_connect;
-    char *on_disconnect;
 
     mutex_t lock;
 
     refbuf_t *stream_data;
     refbuf_t *stream_data_tail;
 
-    FILE *intro_file;
-
 } source_t;
 
 source_t *source_reserve (const char *mount);



More information about the commits mailing list