[MPlayer-cvslog] r32092 - trunk/udp_sync.c
reimar
subversion at mplayerhq.hu
Wed Sep 8 20:44:22 CEST 2010
Author: reimar
Date: Wed Sep 8 20:44:22 2010
New Revision: 32092
Log:
Use sockfd value to detect if we initialized already instead of a
separate variable.
Modified:
trunk/udp_sync.c
Modified: trunk/udp_sync.c
==============================================================================
--- trunk/udp_sync.c Wed Sep 8 20:42:27 2010 (r32091)
+++ trunk/udp_sync.c Wed Sep 8 20:44:22 2010 (r32092)
@@ -85,14 +85,11 @@ int get_udp(int blocking, float *master_
int chars_received = -1;
int n;
- static int done_init_yet = 0;
- static int sockfd;
- if (!done_init_yet) {
+ static int sockfd = -1;
+ if (sockfd == -1) {
struct timeval tv = { .tv_sec = 30 };
struct sockaddr_in servaddr = { 0 };
- done_init_yet = 1;
-
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd == -1)
return -1;
@@ -136,16 +133,13 @@ int get_udp(int blocking, float *master_
void send_udp(const char *send_to_ip, int port, char *mesg)
{
- static int done_init_yet = 0;
- static int sockfd;
+ static int sockfd = -1;
static struct sockaddr_in socketinfo;
- if (!done_init_yet) {
+ if (sockfd == -1) {
static const int one = 1;
int ip_valid = 0;
- done_init_yet = 1;
-
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd == -1)
exit_player(EXIT_ERROR);
More information about the MPlayer-cvslog
mailing list