[svn-commits] eliel: branch eliel/cli-permissions r151902 - /team/eliel/cli-permissions/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Oct 25 00:35:30 CDT 2008


Author: eliel
Date: Sat Oct 25 00:35:29 2008
New Revision: 151902

URL: http://svn.digium.com/view/asterisk?view=rev&rev=151902
Log:
Move code to avoid unnecesary indentation.

Modified:
    team/eliel/cli-permissions/main/asterisk.c

Modified: team/eliel/cli-permissions/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/eliel/cli-permissions/main/asterisk.c?view=diff&rev=151902&r1=151901&r2=151902
==============================================================================
--- team/eliel/cli-permissions/main/asterisk.c (original)
+++ team/eliel/cli-permissions/main/asterisk.c Sat Oct 25 00:35:29 2008
@@ -1136,32 +1136,33 @@
 				ast_log(LOG_WARNING, "Unable to turn on socket credentials passing\n");
 			} else {
 				for (x = 0; x < AST_MAX_CONNECTS; x++) {
-					if (consoles[x].fd < 0) {
-						if (socketpair(AF_LOCAL, SOCK_STREAM, 0, consoles[x].p)) {
-							ast_log(LOG_ERROR, "Unable to create pipe: %s\n", strerror(errno));
-							consoles[x].fd = -1;
-							fdprint(s, "Server failed to create pipe\n");
-							close(s);
-							break;
-						}
-						flags = fcntl(consoles[x].p[1], F_GETFL);
-						fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
-						consoles[x].fd = s;
-						consoles[x].mute = 1; /* Default is muted, we will un-mute if necessary */
-						/* Default uid and gid to -2, so then in cli.c/cli_has_permissions() we will be able
-						   to know if the user didn't send the credentials. */
-						consoles[x].uid = -2;
-						consoles[x].gid = -2;
-						if (ast_pthread_create_detached_background(&consoles[x].t, NULL, netconsole, &consoles[x])) {
-							ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
-							close(consoles[x].p[0]);
-							close(consoles[x].p[1]);
-							consoles[x].fd = -1;
-							fdprint(s, "Server failed to spawn thread\n");
-							close(s);
-						}
+					if (consoles[x].fd >= 0) {
+						continue;
+					}
+					if (socketpair(AF_LOCAL, SOCK_STREAM, 0, consoles[x].p)) {
+						ast_log(LOG_ERROR, "Unable to create pipe: %s\n", strerror(errno));
+						consoles[x].fd = -1;
+						fdprint(s, "Server failed to create pipe\n");
+						close(s);
 						break;
 					}
+					flags = fcntl(consoles[x].p[1], F_GETFL);
+					fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
+					consoles[x].fd = s;
+					consoles[x].mute = 1; /* Default is muted, we will un-mute if necessary */
+					/* Default uid and gid to -2, so then in cli.c/cli_has_permissions() we will be able
+					   to know if the user didn't send the credentials. */
+					consoles[x].uid = -2;
+					consoles[x].gid = -2;
+					if (ast_pthread_create_detached_background(&consoles[x].t, NULL, netconsole, &consoles[x])) {
+						ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
+						close(consoles[x].p[0]);
+						close(consoles[x].p[1]);
+						consoles[x].fd = -1;
+						fdprint(s, "Server failed to spawn thread\n");
+						close(s);
+					}
+					break;
 				}
 				if (x >= AST_MAX_CONNECTS) {
 					fdprint(s, "No more connections allowed\n");




More information about the svn-commits mailing list