[Ffmpeg-cvslog] r8846 - in trunk: ffserver.c libavformat/network.h libavformat/os_support.c libavformat/tcp.c
alex
subversion
Fri Apr 27 02:41:50 CEST 2007
Author: alex
Date: Fri Apr 27 02:41:50 2007
New Revision: 8846
Log:
implement ff_socket_nonblock and use it in networking code
Modified:
trunk/ffserver.c
trunk/libavformat/network.h
trunk/libavformat/os_support.c
trunk/libavformat/tcp.c
Modified: trunk/ffserver.c
==============================================================================
--- trunk/ffserver.c (original)
+++ trunk/ffserver.c Fri Apr 27 02:41:50 2007
@@ -440,7 +440,7 @@ static int socket_open_listen(struct soc
closesocket(server_fd);
return -1;
}
- fcntl(server_fd, F_SETFL, O_NONBLOCK);
+ ff_socket_nonblock(server_fd, 1);
return server_fd;
}
@@ -649,7 +649,7 @@ static void new_connection(int server_fd
&len);
if (fd < 0)
return;
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ ff_socket_nonblock(fd, 1);
/* XXX: should output a warning page when coming
close to the connection limit */
Modified: trunk/libavformat/network.h
==============================================================================
--- trunk/libavformat/network.h (original)
+++ trunk/libavformat/network.h Fri Apr 27 02:41:50 2007
@@ -32,6 +32,8 @@
#define ff_neterrno() errno
#define FF_NETERROR(err) err
+int ff_socket_nonblock(int socket, int enable);
+
#if !defined(HAVE_INET_ATON)
/* in os_support.c */
int inet_aton (const char * str, struct in_addr * add);
Modified: trunk/libavformat/os_support.c
==============================================================================
--- trunk/libavformat/os_support.c (original)
+++ trunk/libavformat/os_support.c Fri Apr 27 02:41:50 2007
@@ -114,6 +114,14 @@ int resolve_host(struct in_addr *sin_add
}
return 0;
}
+
+int ff_socket_nonblock(int socket, int enable)
+{
+ if (enable)
+ return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
+ else
+ return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
+}
#endif /* CONFIG_NETWORK */
#ifdef CONFIG_FFSERVER
Modified: trunk/libavformat/tcp.c
==============================================================================
--- trunk/libavformat/tcp.c (original)
+++ trunk/libavformat/tcp.c Fri Apr 27 02:41:50 2007
@@ -22,7 +22,6 @@
#include <unistd.h>
#include "network.h"
#include <sys/time.h>
-#include <fcntl.h>
typedef struct TCPContext {
int fd;
@@ -62,7 +61,7 @@ static int tcp_open(URLContext *h, const
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
goto fail;
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ ff_socket_nonblock(fd, 1);
redo:
ret = connect(fd, (struct sockaddr *)&dest_addr,
More information about the ffmpeg-cvslog
mailing list