]> git.sesse.net Git - ffmpeg/blobdiff - ffserver.c
add multiple inclusion guards to headers
[ffmpeg] / ffserver.c
index 1c3a91e7e9288a47ef51e2b387af0810e86a325f..7886c202ae7809d9e4d1ce2bf8764c13105730b9 100644 (file)
@@ -18,7 +18,7 @@
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#define HAVE_AV_CONFIG_H
+
 #include "avformat.h"
 
 #include <stdarg.h>
 #include <sys/time.h>
 #undef time //needed because HAVE_AV_CONFIG_H is defined on top
 #include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/wait.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
 #include <signal.h>
 #ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
 
+#include "network.h"
 #include "version.h"
 #include "ffserver.h"
 #include "random.h"
@@ -444,7 +440,7 @@ static int socket_open_listen(struct sockaddr_in *my_addr)
         closesocket(server_fd);
         return -1;
     }
-    fcntl(server_fd, F_SETFL, O_NONBLOCK);
+    ff_socket_nonblock(server_fd, 1);
 
     return server_fd;
 }
@@ -592,7 +588,8 @@ static int http_server(void)
            second to handle timeouts */
         do {
             ret = poll(poll_table, poll_entry - poll_table, delay);
-            if (ret < 0 && errno != EAGAIN && errno != EINTR)
+            if (ret < 0 && ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR))
                 return -1;
         } while (ret < 0);
 
@@ -652,7 +649,7 @@ static void new_connection(int server_fd, int is_rtsp)
                 &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 */
@@ -795,7 +792,8 @@ static int handle_connection(HTTPContext *c)
     read_loop:
         len = recv(c->fd, c->buffer_ptr, 1, 0);
         if (len < 0) {
-            if (errno != EAGAIN && errno != EINTR)
+            if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR))
                 return -1;
         } else if (len == 0) {
             return -1;
@@ -830,7 +828,8 @@ static int handle_connection(HTTPContext *c)
             return 0;
         len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
         if (len < 0) {
-            if (errno != EAGAIN && errno != EINTR) {
+            if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR)) {
                 /* error : close connection */
                 av_freep(&c->pb_buffer);
                 return -1;
@@ -900,7 +899,8 @@ static int handle_connection(HTTPContext *c)
             return 0;
         len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
         if (len < 0) {
-            if (errno != EAGAIN && errno != EINTR) {
+            if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR)) {
                 /* error : close connection */
                 av_freep(&c->pb_buffer);
                 return -1;
@@ -926,7 +926,8 @@ static int handle_connection(HTTPContext *c)
         len = send(c->fd, c->packet_buffer_ptr,
                     c->packet_buffer_end - c->packet_buffer_ptr, 0);
         if (len < 0) {
-            if (errno != EAGAIN && errno != EINTR) {
+            if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR)) {
                 /* error : close connection */
                 av_freep(&c->packet_buffer);
                 return -1;
@@ -1298,7 +1299,7 @@ static int http_parse_request(HTTPContext *c)
         }
     }
 
-    /* If already streaming this feed, dont let start an another feeder */
+    /* If already streaming this feed, do not let start another feeder. */
     if (stream->feed_opened) {
         snprintf(msg, sizeof(msg), "This feed is already being received.");
         goto send_error;
@@ -2337,7 +2338,8 @@ static int http_send_data(HTTPContext *c)
                 /* TCP data output */
                 len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
                 if (len < 0) {
-                    if (errno != EAGAIN && errno != EINTR) {
+                    if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                        ff_neterrno() != FF_NETERROR(EINTR)) {
                         /* error : close connection */
                         return -1;
                     } else {
@@ -2394,7 +2396,8 @@ static int http_receive_data(HTTPContext *c)
 
         len = recv(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0);
         if (len < 0) {
-            if (errno != EAGAIN && errno != EINTR) {
+            if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
+                ff_neterrno() != FF_NETERROR(EINTR)) {
                 /* error : close connection */
                 goto fail;
             }
@@ -4281,7 +4284,7 @@ static int parse_ffconfig(const char *filename)
             }
 
             get_arg(arg, sizeof(arg), &p);
-           
+
             if (resolve_host(&acl.first, arg) != 0) {
                 fprintf(stderr, "%s:%d: ACL refers to invalid host or ip address '%s'\n",
                         filename, line_num, arg);