[MPlayer-cvslog] CVS: main/libmpdemux rtp.c,1.9,1.10
Reimar Döffinger CVS
syncmail at mplayerhq.hu
Sun Jun 19 14:42:38 CEST 2005
CVS change done by Reimar Döffinger CVS
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv32761
Modified Files:
rtp.c
Log Message:
fix wrong usage of select() (based on patch by Selwyn Tang selwyn hectrix com),
add missing closesocket calls.
Index: rtp.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/rtp.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- rtp.c 29 May 2005 12:53:59 -0000 1.9
+++ rtp.c 19 Jun 2005 12:42:36 -0000 1.10
@@ -76,7 +76,7 @@
hp =(struct hostent*)gethostbyname( url->hostname );
if( hp==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_ERR,"Counldn't resolve name: %s\n", url->hostname);
- return -1;
+ goto err_out;
}
memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length );
#else
@@ -103,8 +103,7 @@
if( WSAGetLastError() != WSAEINPROGRESS ) {
#endif
mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to connect to server\n");
- closesocket(socket_server_fd);
- return -1;
+ goto err_out;
}
}
@@ -113,7 +112,7 @@
hp =(struct hostent*)gethostbyname( url->hostname );
if( hp==NULL ) {
mp_msg(MSGT_NETWORK,MSGL_ERR,"Counldn't resolve name: %s\n", url->hostname);
- return -1;
+ goto err_out;
}
memcpy( (void*)&server_address.sin_addr.s_addr, (void*)hp->h_addr, hp->h_length );
} else {
@@ -134,7 +133,7 @@
mcast.imr_interface.s_addr = 0;
if( setsockopt( socket_server_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcast, sizeof(mcast))) {
mp_msg(MSGT_NETWORK,MSGL_ERR,"IP_ADD_MEMBERSHIP failed (do you have multicasting enabled in your kernel?)\n");
- return -1;
+ goto err_out;
}
}
@@ -142,18 +141,26 @@
tv.tv_usec = (1 * 1000000); // 1 second timeout
FD_ZERO( &set );
FD_SET( socket_server_fd, &set );
- if( select(socket_server_fd+1, &set, NULL, NULL, &tv)>0 ) {
- //if( select(socket_server_fd+1, &set, NULL, NULL, NULL)>0 ) {
+ err = select(socket_server_fd+1, &set, NULL, NULL, &tv);
+ if (err < 0) {
+ mp_msg(MSGT_NETWORK, MSGL_FATAL, "Select failed: %s\n", strerror(errno));
+ goto err_out;
+ }
+ if (err == 0) {
+ mp_msg(MSGT_NETWORK,MSGL_ERR,"Timeout! No data from host %s\n", url->hostname );
+ goto err_out;
+ }
err_len = sizeof( err );
getsockopt( socket_server_fd, SOL_SOCKET, SO_ERROR, &err, &err_len );
if( err ) {
- mp_msg(MSGT_NETWORK,MSGL_ERR,"Timeout! No data from host %s\n", url->hostname );
mp_msg(MSGT_NETWORK,MSGL_DBG2,"Socket error: %d\n", err );
- closesocket(socket_server_fd);
- return -1;
+ goto err_out;
}
- }
return socket_server_fd;
+
+err_out:
+ closesocket(socket_server_fd);
+ return -1;
}
static int rtp_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *streaming_ctrl ) {
More information about the MPlayer-cvslog
mailing list