[MPlayer-cvslog] r32091 - trunk/udp_sync.c

reimar subversion at mplayerhq.hu
Wed Sep 8 20:42:27 CEST 2010


Author: reimar
Date: Wed Sep  8 20:42:27 2010
New Revision: 32091

Log:
Handle failures to create a socket.

Modified:
   trunk/udp_sync.c

Modified: trunk/udp_sync.c
==============================================================================
--- trunk/udp_sync.c	Wed Sep  8 20:37:55 2010	(r32090)
+++ trunk/udp_sync.c	Wed Sep  8 20:42:27 2010	(r32091)
@@ -74,6 +74,7 @@ static void set_blocking(int fd, int blo
 
 // gets a datagram from the master with or without blocking.  updates
 // master_position if successful.  if the master has exited, returns 1.
+// returns -1 on error.
 // otherwise, returns 0.
 int get_udp(int blocking, float *master_position)
 {
@@ -93,6 +94,8 @@ int get_udp(int blocking, float *master_
         done_init_yet = 1;
 
         sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+        if (sockfd == -1)
+            return -1;
 
         servaddr.sin_family      = AF_INET;
         servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -144,6 +147,8 @@ void send_udp(const char *send_to_ip, in
         done_init_yet = 1;
 
         sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+        if (sockfd == -1)
+            exit_player(EXIT_ERROR);
 
         // Enable broadcast
         setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one));


More information about the MPlayer-cvslog mailing list