[Mplayer-cvslog] CVS: main/libmpdemux asf_streaming.c,1.11,1.12 network.c,1.14,1.15 url.c,1.8,1.9

Bertrand Baudet bertrand at mplayer.dev.hu
Fri Dec 14 21:45:33 CET 2001


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv15460/libmpdemux

Modified Files:
	asf_streaming.c network.c url.c 
Log Message:
Applied the patch from Alban Bedel <albeu at free.fr>.
He added some errors checking on network code.
Added a check on the port number parsing in the url.


Index: asf_streaming.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/asf_streaming.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- asf_streaming.c	12 Dec 2001 22:35:51 -0000	1.11
+++ asf_streaming.c	14 Dec 2001 20:45:30 -0000	1.12
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "config.h"
 
@@ -468,13 +469,16 @@
 		//http_hdr = asf_http_request( url );
 		http_hdr = asf_http_request( stream->streaming_ctrl );
 printf("Request [%s]\n", http_hdr->buffer );
-		write( fd, http_hdr->buffer, http_hdr->buffer_size );
-printf("1\n");
+                                for(i=0; i <  http_hdr->buffer_size ; ) {
+			int r = write( fd, http_hdr->buffer+i, http_hdr->buffer_size-i );
+			if(r <0) {
+			  printf("Socket write error : %s\n",strerror(errno));
+			  return -1;
+			}
+			i += r;
+		}       
 	//	http_free( http_hdr );
-printf("2\n");
-
 		http_hdr = http_new_header();
-printf("3\n");
 		do {
 			i = read( fd, buffer, BUFFER_SIZE );
 printf("read: %d\n", i );

Index: network.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/network.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- network.c	11 Dec 2001 01:06:08 -0000	1.14
+++ network.c	14 Dec 2001 20:45:30 -0000	1.15
@@ -137,6 +137,17 @@
 
 	// Turn back the socket as blocking
 	fcntl( socket_server_fd, F_SETFL, fcntl(socket_server_fd, F_GETFL) & ~O_NONBLOCK );
+	// Check if there were any error
+	err_len = sizeof(int);
+	ret =  getsockopt(socket_server_fd,SOL_SOCKET,SO_ERROR,&err,&err_len);
+	if(ret < 0) {
+		printf("getsockopt failed : %s\n",strerror(errno));
+		return -1;
+	}
+	if(err > 0) {
+		printf("Connect error : %s\n",strerror(err));
+		return -1;
+	}
 	return socket_server_fd;
 }
 
@@ -356,8 +367,8 @@
 	if( len<size ) {
 		int ret;
 		ret = read( fd, buffer+len, size-len );
-		if( ret==0 ) {
-			printf("nop_streaming_read read 0 -ie- EOF\n");
+		if( ret<0 ) {
+			printf("nop_streaming_read error : %s\n",strerror(errno));
 		}
 		len += ret;
 //printf("read %d bytes from network\n", len );

Index: url.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/url.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- url.c	20 Nov 2001 22:15:32 -0000	1.8
+++ url.c	14 Dec 2001 20:45:30 -0000	1.9
@@ -17,7 +17,7 @@
 url_new(char* url) {
 	int pos1, pos2;
 	URL_t* Curl;
-	char *ptr1, *ptr2;
+	char *ptr1, *ptr2, *ptr3;
 
 	// Create the URL container
 	Curl = (URL_t*)malloc(sizeof(URL_t));
@@ -49,6 +49,9 @@
 
 	// look if the port is given
 	ptr2 = strstr(ptr1+3, ":");
+	// If the : is after the first / it isn't the port
+	ptr3 = strstr(ptr1+3, "/");
+	if(ptr3 && ptr3 - ptr2 < 0) ptr2 = NULL;
 	if( ptr2==NULL ) {
 		// No port is given
 		// Look if a path is given




More information about the MPlayer-cvslog mailing list