freebsd-ports/net/minidlna/files/patch-upnphttp
2011-09-21 05:06:12 +00:00

60 lines
1.2 KiB
Text

--- upnphttp.c 2010-12-13 01:41:52.000000000 -0500
+++ upnphttp.c 2010-12-13 17:28:08.000000000 -0500
@@ -66,5 +66,4 @@
#include <fcntl.h>
#include <errno.h>
-#include <sys/sendfile.h>
#include <arpa/inet.h>
@@ -80,10 +79,16 @@
#include "tivo_commands.h"
#endif
+#ifdef __linux__
//#define MAX_BUFFER_SIZE 4194304 // 4MB -- Too much?
#define MAX_BUFFER_SIZE 2147483647 // 2GB -- Too much?
#define MIN_BUFFER_SIZE 65536
+#endif
#include "icons.c"
+#ifndef MSG_MORE /* A Linux-only flag for send(2) */
+# define MSG_MORE 0
+#endif
+
struct upnphttp *
New_upnphttp(int s)
@@ -1115,6 +1120,7 @@
}
-void
+static void
send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset)
+#if defined(__linux__)
{
off_t send_size;
@@ -1166,4 +1172,25 @@
free(buf);
}
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || \
+ defined(__OpenBSD__) || defined(__DragonFlyBSD__)
+{
+
+ off_t sent;
+
+ while (offset < end_offset)
+ {
+ if (sendfile(sendfd, h->socket, offset,
+ end_offset - offset + 1, NULL, &sent, SF_MNOWAIT) == -1) {
+ DPRINTF(E_ERROR, L_HTTP,
+ "sendfile error :: error no. %d [%s]\n",
+ errno, strerror(errno));
+ if (errno != EAGAIN)
+ break;
+ }
+ offset += sent;
+
+ }
+}
+#endif
void