[asterisk-commits] file: trunk r49026 - in /trunk: ./ main/http.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 28 13:02:42 MST 2006


Author: file
Date: Thu Dec 28 14:02:41 2006
New Revision: 49026

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49026
Log:
Merged revisions 49024 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r49024 | qwell | 2006-12-28 14:52:46 -0500 (Thu, 28 Dec 2006) | 2 lines

make the uris_lock a rwlock instead of a mutex lock - needs to be forward ported to trunk

........

Modified:
    trunk/   (props changed)
    trunk/main/http.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=49026&r1=49025&r2=49026
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Thu Dec 28 14:02:41 2006
@@ -107,7 +107,7 @@
 	.worker_fn = httpd_helper_thread,
 };
 
-static AST_LIST_HEAD_STATIC(uris, ast_http_uri);	/*!< list of supported handlers */
+static AST_RWLIST_HEAD_STATIC(uris, ast_http_uri);	/*!< list of supported handlers */
 
 /* all valid URIs must be prepended by the string in prefix. */
 static char prefix[MAX_PREFIX];
@@ -309,35 +309,35 @@
 	struct ast_http_uri *uri;
 	int len = strlen(urih->uri);
 
-	AST_LIST_LOCK(&uris);
-
-	if ( AST_LIST_EMPTY(&uris) || strlen(AST_LIST_FIRST(&uris)->uri) <= len ) {
-		AST_LIST_INSERT_HEAD(&uris, urih, entry);
-		AST_LIST_UNLOCK(&uris);
+	AST_RWLIST_WRLOCK(&uris);
+
+	if ( AST_RWLIST_EMPTY(&uris) || strlen(AST_RWLIST_FIRST(&uris)->uri) <= len ) {
+		AST_RWLIST_INSERT_HEAD(&uris, urih, entry);
+		AST_RWLIST_UNLOCK(&uris);
 		return 0;
 	}
 
-	AST_LIST_TRAVERSE(&uris, uri, entry) {
-		if ( AST_LIST_NEXT(uri, entry) 
-			&& strlen(AST_LIST_NEXT(uri, entry)->uri) <= len ) {
-			AST_LIST_INSERT_AFTER(&uris, uri, urih, entry);
-			AST_LIST_UNLOCK(&uris); 
+	AST_RWLIST_TRAVERSE(&uris, uri, entry) {
+		if ( AST_RWLIST_NEXT(uri, entry) 
+			&& strlen(AST_RWLIST_NEXT(uri, entry)->uri) <= len ) {
+			AST_RWLIST_INSERT_AFTER(&uris, uri, urih, entry);
+			AST_RWLIST_UNLOCK(&uris); 
 			return 0;
 		}
 	}
 
-	AST_LIST_INSERT_TAIL(&uris, urih, entry);
-
-	AST_LIST_UNLOCK(&uris);
+	AST_RWLIST_INSERT_TAIL(&uris, urih, entry);
+
+	AST_RWLIST_UNLOCK(&uris);
 	
 	return 0;
 }	
 
 void ast_http_uri_unlink(struct ast_http_uri *urih)
 {
-	AST_LIST_LOCK(&uris);
-	AST_LIST_REMOVE(&uris, urih, entry);
-	AST_LIST_UNLOCK(&uris);
+	AST_RWLIST_WRLOCK(&uris);
+	AST_RWLIST_REMOVE(&uris, urih, entry);
+	AST_RWLIST_UNLOCK(&uris);
 }
 
 static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *status, char **title, int *contentlength, struct ast_variable **cookies)
@@ -404,8 +404,8 @@
 	if (l && !strncasecmp(uri, prefix, l) && uri[l] == '/') {
 		uri += l + 1;
 		/* scan registered uris to see if we match one. */
-		AST_LIST_LOCK(&uris);
-		AST_LIST_TRAVERSE(&uris, urih, entry) {
+		AST_RWLIST_RDLOCK(&uris);
+		AST_RWLIST_TRAVERSE(&uris, urih, entry) {
 			l = strlen(urih->uri);
 			c = uri + l;	/* candidate */
 			if (strncasecmp(urih->uri, uri, l) /* no match */
@@ -419,11 +419,11 @@
 			}
 		}
 		if (!urih)
-			AST_LIST_UNLOCK(&uris);
+			AST_RWLIST_UNLOCK(&uris);
 	}
 	if (urih) {
 		out = urih->callback(sin, uri, vars, status, title, contentlength);
-		AST_LIST_UNLOCK(&uris);
+		AST_RWLIST_UNLOCK(&uris);
 	} else {
 		out = ast_http_error(404, "Not Found", NULL,
 			"The requested URL was not found on this server.");
@@ -979,12 +979,14 @@
 	}
 
 	ast_cli(fd, "Enabled URI's:\n");
-	AST_LIST_LOCK(&uris);
-	AST_LIST_TRAVERSE(&uris, urih, entry)
-		ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
-	if (AST_LIST_EMPTY(&uris))
+	AST_RWLIST_RDLOCK(&uris);
+	if (AST_RWLIST_EMPTY(&uris)) {
 		ast_cli(fd, "None.\n");
-	AST_LIST_UNLOCK(&uris);
+	} else {
+		AST_RWLIST_TRAVERSE(&uris, urih, entry)
+			ast_cli(fd, "%s/%s%s => %s\n", prefix, urih->uri, (urih->has_subtree ? "/..." : "" ), urih->description);
+	}
+	AST_RWLIST_UNLOCK(&uris);
 
 	ast_cli(fd, "\nEnabled Redirects:\n");
 	AST_LIST_LOCK(&uri_redirects);



More information about the asterisk-commits mailing list