[xiph-cvs] cvs commit: icecast/src source.h source.c connection.c
Michael Smith
msmith at xiph.org
Mon Feb 17 05:01:37 PST 2003
msmith 03/02/17 08:01:37
Modified: src source.h source.c connection.c
Log:
Fix previous changes to source creation - misunderstood requirements for
unlocking rwlocks. Move more checks and some other logic into source.c
Revision Changes Path
1.8 +1 -0 icecast/src/source.h
Index: source.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- source.h 11 Feb 2003 14:23:34 -0000 1.7
+++ source.h 17 Feb 2003 13:01:37 -0000 1.8
@@ -30,6 +30,7 @@
int num_yp_directories;
long listeners;
long max_listeners;
+ int send_return;
} source_t;
source_t *source_create(client_t *client, connection_t *con, http_parser_t *parser, const char *mount, format_type_t type);
<p><p>1.34 +22 -2 icecast/src/source.c
Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- source.c 17 Feb 2003 11:56:12 -0000 1.33
+++ source.c 17 Feb 2003 13:01:37 -0000 1.34
@@ -56,6 +56,7 @@
src->running = 1;
src->num_yp_directories = 0;
src->listeners = 0;
+ src->send_return = 0;
for (i=0;i<config_get_config()->num_yp_directories;i++) {
if (config_get_config()->yp_url[i]) {
src->ypdata[src->num_yp_directories] = yp_create_ypdata();
@@ -157,13 +158,32 @@
/* grab a read lock, to make sure we get a chance to cleanup */
thread_rwlock_rlock(source->shutdown_rwlock);
- /* The caller has ensured we have a write lock on the tree... */
-
+ avl_tree_wlock(global.source_tree);
+ /* Now, we must do a final check with write lock taken out that the
+ * mountpoint is available..
+ */
+ if (source_find_mount(source->mount) != NULL) {
+ avl_tree_unlock(global.source_tree);
+ if(source->send_return) {
+ client_send_404(source->client, "Mountpoint in use");
+ }
+ thread_exit(0);
+ return NULL;
+ }
/* insert source onto source tree */
avl_insert(global.source_tree, (void *)source);
/* release write lock on global source tree */
avl_tree_unlock(global.source_tree);
+ /* 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 */
stats_event(source->mount, "listeners", "0");
<p><p>1.52 +1 -20 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- connection.c 17 Feb 2003 11:56:12 -0000 1.51
+++ connection.c 17 Feb 2003 13:01:37 -0000 1.52
@@ -296,7 +296,6 @@
int connection_create_source(client_t *client, connection_t *con, http_parser_t *parser, char *mount) {
source_t *source;
char *contenttype;
- int bytes;
/* check to make sure this source wouldn't
** be over the limit
@@ -328,25 +327,7 @@
source = source_create(client, con, parser, mount, format);
}
- /* We did a preliminary check earlier, to catch the common case before
- * we do any unneccesary processing. Now, we do a check that must be
- * correct - so we have to take a write lock out, since we need to
- * add this source if it doesn't already exist.
- */
- avl_tree_wlock(global.source_tree);
- if (source_find_mount(mount) != NULL) {
- INFO1("Source tried to log in as %s, but mountpoint is already used",
- mount);
- avl_tree_unlock(global.source_tree);
- goto fail;
- }
- /* Keep the tree locked - it gets unlocked in source_main */
-
- client->respcode = 200;
- bytes = sock_write(client->con->sock,
- "HTTP/1.0 200 OK\r\n\r\n");
- if(bytes > 0) client->con->sent_bytes = bytes;
-
+ source->send_return = 1;
source->shutdown_rwlock = &_source_shutdown_rwlock;
sock_set_blocking(con->sock, SOCK_NONBLOCK);
thread_create("Source Thread", source_main, (void *)source, THREAD_DETACHED);
<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