[Asterisk-cvs] asterisk manager.c,1.122,1.123

kpfleming kpfleming
Tue Oct 4 18:29:28 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv1322

Modified Files:
	manager.c 
Log Message:
allow write timeout to be set on a per-user basis in AMI (issue #5352)


Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- manager.c	4 Oct 2005 22:15:28 -0000	1.122
+++ manager.c	4 Oct 2005 22:25:15 -0000	1.123
@@ -495,7 +495,14 @@
 					} else if (!strcasecmp(v->name, "permit") ||
 						   !strcasecmp(v->name, "deny")) {
 						ha = ast_append_ha(v->name, v->value, ha);
-					}	
+					} else if (!strcasecmp(v->name, "writetimeout")) {
+						int val = atoi(v->value);
+
+						if (val < 100)
+							ast_log(LOG_WARNING, "Invalid writetimeout value '%s' at line %d\n", v->value, v->lineno);
+						else
+							s->writetimeout = val;
+					}
 				    		
 					v = v->next;
 				}
@@ -1286,7 +1293,7 @@
 		ast_mutex_lock(&s->__lock);
 		s->busy = 0;
 		while(s->eventq) {
-			if (ast_carefulwrite(s->fd, s->eventq->eventdata, strlen(s->eventq->eventdata), 100)) {
+			if (ast_carefulwrite(s->fd, s->eventq->eventdata, strlen(s->eventq->eventdata), s->writetimeout)) {
 				ret = -1;
 				break;
 			}
@@ -1427,6 +1434,7 @@
 		} 
 		memset(s, 0, sizeof(struct mansession));
 		memcpy(&s->sin, &sin, sizeof(sin));
+		s->writetimeout = 100;
 
 		if(! block_sockets) {
 			/* For safety, make sure socket is non-blocking */
@@ -1499,7 +1507,7 @@
 		ast_mutex_lock(&s->__lock);
 		if (s->busy) {
 			append_event(s, tmp);
-		} else if (ast_carefulwrite(s->fd, tmp, tmp_next - tmp, 100) < 0) {
+		} else if (ast_carefulwrite(s->fd, tmp, tmp_next - tmp, s->writetimeout) < 0) {
 			ast_log(LOG_WARNING, "Disconnecting slow (or gone) manager session!\n");
 			s->dead = 1;
 			pthread_kill(s->t, SIGURG);




More information about the svn-commits mailing list