[svn-commits] jpeeler: branch jpeeler/externalivr-tcp r108403 - /team/jpeeler/externalivr-t...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 13 13:33:48 CDT 2008


Author: jpeeler
Date: Thu Mar 13 13:33:47 2008
New Revision: 108403

URL: http://svn.digium.com/view/asterisk?view=rev&rev=108403
Log:
changed socket connection to use file descriptors again

Modified:
    team/jpeeler/externalivr-tcp/apps/app_externalivr.c

Modified: team/jpeeler/externalivr-tcp/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/externalivr-tcp/apps/app_externalivr.c?view=diff&rev=108403&r1=108402&r2=108403
==============================================================================
--- team/jpeeler/externalivr-tcp/apps/app_externalivr.c (original)
+++ team/jpeeler/externalivr-tcp/apps/app_externalivr.c Thu Mar 13 13:33:47 2008
@@ -88,7 +88,7 @@
 
 static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, 
               int eivr_events_fd, int eivr_commands_fd, int eivr_errors_fd, 
-              FILE *stream, const char *args);
+              const char *args);
 
 int eivr_connect_socket(struct ast_channel *chan, const char *host, int port);
 
@@ -380,7 +380,7 @@
 		if (!ser) {
 			goto exit;
 		} 
-		res = eivr_comm(chan, u, 0, 0, 0, ser->f, pipe_delim_argbuf);
+		res = eivr_comm(chan, u, ser->fd, ser->fd, 0, pipe_delim_argbuf);
 	} else {
 	
 		if (pipe(child_stdin)) {
@@ -438,7 +438,7 @@
 			child_stdout[1] = 0;
 			close(child_stderr[1]);
 			child_stderr[1] = 0;
-			res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], NULL, pipe_delim_argbuf);
+			res = eivr_comm(chan, u, child_stdin[1], child_stdout[0], child_stderr[0], pipe_delim_argbuf);
 		}
 	}
 
@@ -477,7 +477,7 @@
 
 static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u, 
  				int eivr_events_fd, int eivr_commands_fd, int eivr_errors_fd, 
- 				FILE *stream, const char *args)
+ 				const char *args)
 {
 	struct playlist_entry *entry;
 	struct ast_frame *f;
@@ -493,23 +493,19 @@
  	FILE *eivr_errors = NULL;
  	FILE *eivr_events = NULL;
 
-	if (!stream) {
- 		if (!(eivr_events = fdopen(eivr_events_fd, "w"))) {
- 			ast_chan_log(LOG_WARNING, chan, "Could not open stream to send events\n");
- 			goto exit;
- 		}
- 		if (!(eivr_commands = fdopen(eivr_commands_fd, "r"))) {
- 			ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive commands\n");
- 			goto exit;
- 		}
+	if (!(eivr_events = fdopen(eivr_events_fd, "w"))) {
+		ast_chan_log(LOG_WARNING, chan, "Could not open stream to send events\n");
+		goto exit;
+	}
+	if (!(eivr_commands = fdopen(eivr_commands_fd, "r"))) {
+		ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive commands\n");
+		goto exit;
+	}
+	if(eivr_errors_fd) {  /* if opening a socket connection, error stream will not be used */
  		if (!(eivr_errors = fdopen(eivr_errors_fd, "r"))) {
  			ast_chan_log(LOG_WARNING, chan, "Could not open stream to receive errors\n");
  			goto exit;
  		}
-	} else {
-		/* if opening a socket connection, error stream will not be used */
-		eivr_events = stream;
-		eivr_commands = stream;
 	}
  
  	setvbuf(eivr_events, NULL, _IONBF, 0);
@@ -693,16 +689,14 @@
  
 exit:
  
-	if (!stream) {
- 		if (eivr_events)
- 			fclose(eivr_events);
- 
- 		if (eivr_commands)
-			fclose(eivr_commands);
-
- 		if (eivr_errors)
- 			fclose(eivr_errors);
-	}
+	if (eivr_events)
+ 		fclose(eivr_events);
+ 
+	if (eivr_commands)
+		fclose(eivr_commands);
+
+	if (eivr_errors)
+		fclose(eivr_errors);
   
   	return res;
  




More information about the svn-commits mailing list