[xiph-cvs] cvs commit: icecast/src connection.c source.c source.h

Karl Heyes karl at xiph.org
Wed Feb 25 08:24:31 PST 2004



karl        04/02/25 11:24:31

  Modified:    src      connection.c source.c source.h
  Log:
  move the source client '200 OK' response to the source client specific part
  of the source thread, and rearrange stats around that

Revision  Changes    Path
1.90      +0 -4      icecast/src/connection.c

Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- connection.c	20 Feb 2004 17:42:57 -0000	1.89
+++ connection.c	25 Feb 2004 16:24:30 -0000	1.90
@@ -479,8 +479,6 @@
 
         global.sources++;
         global_unlock();
-        stats_event_inc(NULL, "sources");
-        stats_event_inc(NULL, "source_total_connections");
 
         /* for relays, we don't yet have a client, however we do require one
          * to retrieve the stream from.  This is created here, quite late,
@@ -490,8 +488,6 @@
         if (source->client == NULL)
             source->client = client_create (source->con, source->parser);
 
-        sock_set_blocking (source->con->sock, SOCK_NONBLOCK);
-
         while (mountproxy)
         {
             if (strcmp (mountproxy->mountname, source->mount) == 0)

<p><p>1.76      +21 -13    icecast/src/source.c

Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- source.c	20 Feb 2004 17:42:57 -0000	1.75
+++ source.c	25 Feb 2004 16:24:30 -0000	1.76
@@ -398,18 +398,10 @@
     /* grab a read lock, to make sure we get a chance to cleanup */
     thread_rwlock_rlock(source->shutdown_rwlock);
 
-    /* If we connected successfully, we can send the message (if requested)
-     * back
-     */
-    if(source->send_return) {
-        source->client->respcode = 200;
-        bytes = sock_write(source->client->con->sock, 
-                "HTTP/1.0 200 OK\r\n\r\n");
-        if(bytes > 0) source->client->con->sent_bytes = bytes;
-    }
-
     /* start off the statistics */
     source->listeners = 0;
+    stats_event_inc(NULL, "sources");
+    stats_event_inc(NULL, "source_total_connections");
     stats_event(source->mount, "listeners", "0");
     stats_event(source->mount, "type", source->format->format_description);
 #ifdef USE_YP
@@ -520,6 +512,7 @@
         }
     }
 
+    sock_set_blocking (source->con->sock, SOCK_NONBLOCK);
 
     DEBUG0("Source creation complete");
     source->running = 1;
@@ -913,10 +906,25 @@
 void *source_client_thread (void *arg)
 {
     source_t *source = arg;
+    const char ok_msg[] = "HTTP/1.0 200 OK\r\n\r\n";
+    int bytes;
+
+    source->client->respcode = 200;
+    bytes = sock_write_bytes (source->client->con->sock, ok_msg, sizeof (ok_msg)-1);
+    if (bytes < sizeof (ok_msg)-1)
+    {
+        global_lock();
+        global.sources--;
+        global_unlock();
+        WARN0 ("Error writing 200 OK message to source client");
+    }
+    else
+    {
+        source->client->con->sent_bytes += bytes;
 
-    source->send_return = 1;
-    stats_event_inc(NULL, "source_client_connections");
-    source_main (source);
+        stats_event_inc(NULL, "source_client_connections");
+        source_main (source);
+    }
     source_free_source (source);
     return NULL;
 }

<p><p>1.21      +0 -1      icecast/src/source.h

Index: source.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- source.h	19 Feb 2004 21:16:59 -0000	1.20
+++ source.h	25 Feb 2004 16:24:30 -0000	1.21
@@ -53,7 +53,6 @@
     long listeners;
     long max_listeners;
     int yp_public;
-    int send_return;
     struct auth_tag *authenticator;
     int fallback_override;
     int no_mount;

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list