Date: Wed, 13 Jun 2018 13:13:36 +0000 (UTC) From: Bernhard Froehlich <decke@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r472317 - in head/multimedia/tvheadend: . files Message-ID: <201806131313.w5DDDa3A029465@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: decke Date: Wed Jun 13 13:13:36 2018 New Revision: 472317 URL: https://svnweb.freebsd.org/changeset/ports/472317 Log: multimedia/tvheadend: fix two major problems of webui on FreeBSD 1. very high CPU usage while streaming a recored program 2. unable to stream the recorded program beyond 128MB. Unlike Linux sendfile(), FreeBSD sendfile() requires an explicit file offset, and return value must be checked to catch any error occurred. (i.e., closed connection) Obtained from: https://github.com/tvheadend/tvheadend/pull/1125 Submitted by: Jongsung Kim <jongsung.kim@gmail.com> Added: head/multimedia/tvheadend/files/patch-src_webui_webui.c (contents, props changed) Modified: head/multimedia/tvheadend/Makefile Modified: head/multimedia/tvheadend/Makefile ============================================================================== --- head/multimedia/tvheadend/Makefile Wed Jun 13 13:12:44 2018 (r472316) +++ head/multimedia/tvheadend/Makefile Wed Jun 13 13:13:36 2018 (r472317) @@ -4,7 +4,7 @@ PORTNAME= tvheadend PORTVERSION= 4.2.6 DISTVERSIONPREFIX= v -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= multimedia PATCH_SITES= https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/ Added: head/multimedia/tvheadend/files/patch-src_webui_webui.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/multimedia/tvheadend/files/patch-src_webui_webui.c Wed Jun 13 13:13:36 2018 (r472317) @@ -0,0 +1,74 @@ +From d19ee83aba20e5a64a6cef6dd528191a71f9aa31 Mon Sep 17 00:00:00 2001 +From: Jongsung Kim <jongsung.kim@gmail.com> +Date: Tue, 29 May 2018 03:42:04 +0900 +Subject: [PATCH] webui: fix http_serve_file() for FreeBSD + +This patch fixes two major problems of FreeBSD port of tvheadend: + +1. very high CPU usage while streaming a recored program +2. unable to stream the recorded program beyond 128MB. + +Unlike Linux sendfile(), FreeBSD sendfile() requires an explicit +file offset, and return value must be checked to catch any error +occurred. (i.e., closed connection) + +Patch tested with the latest FreeBSD port of tvheadend-4.2.6. + +--- src/webui/webui.c.orig 2018-03-26 10:19:37.000000000 +0200 ++++ src/webui/webui.c 2018-06-13 14:47:58.627430000 +0200 +@@ -1570,7 +1570,7 @@ + #if defined(PLATFORM_LINUX) + ssize_t r; + #elif defined(PLATFORM_FREEBSD) || defined(PLATFORM_DARWIN) +- off_t r; ++ off_t o, r; + #endif + + if (fconv) { +@@ -1631,6 +1631,7 @@ + sprintf(range_buf, "bytes %jd-%jd/%jd", + file_start, file_end, (intmax_t)st.st_size); + ++#if defined(PLATFORM_LINUX) + if(file_start > 0) + if (lseek(fd, file_start, SEEK_SET) != file_start) { + close(fd); +@@ -1644,6 +1645,9 @@ + return ret; + } + } ++#elif defined(PLATFORM_FREEBSD) || defined(PLATFORM_DARWIN) ++ o = file_start; ++#endif + + http_send_begin(hc); + http_send_header(hc, range ? HTTP_STATUS_PARTIAL_CONTENT : HTTP_STATUS_OK, +@@ -1656,16 +1660,22 @@ + chunk = MIN(1024 * ((stats ? 128 : 1024) * 1024), content_len); + #if defined(PLATFORM_LINUX) + r = sendfile(hc->hc_fd, fd, NULL, chunk); ++ if (r < 0) { ++ ret = -1; ++ break; ++ } + #elif defined(PLATFORM_FREEBSD) +- sendfile(fd, hc->hc_fd, 0, chunk, NULL, &r, 0); ++ ret = sendfile(fd, hc->hc_fd, o, chunk, NULL, &r, 0); ++ if (ret < 0) ++ break; ++ o += r; + #elif defined(PLATFORM_DARWIN) + r = chunk; +- sendfile(fd, hc->hc_fd, 0, &r, NULL, 0); +-#endif +- if(r < 0) { +- ret = -1; ++ ret = sendfile(fd, hc->hc_fd, o, &r, NULL, 0); ++ if (ret < 0) + break; +- } ++ o += r; ++#endif + content_len -= r; + if (stats) + stats(hc, r, opaque);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806131313.w5DDDa3A029465>