From owner-svn-ports-all@freebsd.org Wed Jun 13 13:13:37 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BD5311009C64; Wed, 13 Jun 2018 13:13:37 +0000 (UTC) (envelope-from decke@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C5428216E; Wed, 13 Jun 2018 13:13:37 +0000 (UTC) (envelope-from decke@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4CBB319EA0; Wed, 13 Jun 2018 13:13:37 +0000 (UTC) (envelope-from decke@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5DDDbxN029467; Wed, 13 Jun 2018 13:13:37 GMT (envelope-from decke@FreeBSD.org) Received: (from decke@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5DDDa3A029465; Wed, 13 Jun 2018 13:13:36 GMT (envelope-from decke@FreeBSD.org) Message-Id: <201806131313.w5DDDa3A029465@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: decke set sender to decke@FreeBSD.org using -f From: Bernhard Froehlich Date: Wed, 13 Jun 2018 13:13:36 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r472317 - in head/multimedia/tvheadend: . files X-SVN-Group: ports-head X-SVN-Commit-Author: decke X-SVN-Commit-Paths: in head/multimedia/tvheadend: . files X-SVN-Commit-Revision: 472317 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 13:13:38 -0000 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 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 +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);