From owner-svn-ports-head@freebsd.org Wed Apr 18 11:27:00 2018 Return-Path: Delivered-To: svn-ports-head@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 7EFCAF814FE; Wed, 18 Apr 2018 11:27:00 +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 296F0741D7; Wed, 18 Apr 2018 11:27:00 +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 1BF431A57D; Wed, 18 Apr 2018 11:27:00 +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 w3IBQxOa004801; Wed, 18 Apr 2018 11:26:59 GMT (envelope-from decke@FreeBSD.org) Received: (from decke@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3IBQxb7004799; Wed, 18 Apr 2018 11:26:59 GMT (envelope-from decke@FreeBSD.org) Message-Id: <201804181126.w3IBQxb7004799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: decke set sender to decke@FreeBSD.org using -f From: Bernhard Froehlich Date: Wed, 18 Apr 2018 11:26:59 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r467705 - 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: 467705 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Apr 2018 11:27:00 -0000 Author: decke Date: Wed Apr 18 11:26:59 2018 New Revision: 467705 URL: https://svnweb.freebsd.org/changeset/ports/467705 Log: Fix tcp_socket_dead() for FreeBSD The FreeBSD port of tvheadend couldn't stream Live TV, and debug log shows webui judged the peer socket closed immediately after starting streaming: 2018-04-15 06:30:04.996 [ DEBUG]:webui: Start streaming /stream/mux/c4bc67bdaa13457e33740ca883cc4d75?ticket=7D1B56AD0E434C5F7EBFA4677A7FBE4C94097974 2018-04-15 06:30:04.996 [ DEBUG]:webui: Stop streaming /stream/mux/c4bc67bdaa13457e33740ca883cc4d75?ticket=7D1B56AD0E434C5F7EBFA4677A7FBE4C94097974, client hung up It looks tcp_socket_dead() misunderstood the zero-return from recv(). For the FreeBSD, recv() might return zero for alive sockets which have nothing to read. Submitted by: Jongsung Kim Obtained from: https://github.com/tvheadend/tvheadend/pull/1112 Added: head/multimedia/tvheadend/files/patch-src_tcp.c (contents, props changed) Modified: head/multimedia/tvheadend/Makefile Modified: head/multimedia/tvheadend/Makefile ============================================================================== --- head/multimedia/tvheadend/Makefile Wed Apr 18 11:20:04 2018 (r467704) +++ head/multimedia/tvheadend/Makefile Wed Apr 18 11:26:59 2018 (r467705) @@ -4,6 +4,7 @@ PORTNAME= tvheadend PORTVERSION= 4.2.6 DISTVERSIONPREFIX= v +PORTREVISION= 1 CATEGORIES= multimedia MAINTAINER= decke@FreeBSD.org Added: head/multimedia/tvheadend/files/patch-src_tcp.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/multimedia/tvheadend/files/patch-src_tcp.c Wed Apr 18 11:26:59 2018 (r467705) @@ -0,0 +1,39 @@ +From dc7804e1410971dabbe087193ca2b47f02131524 Mon Sep 17 00:00:00 2001 +From: Jongsung Kim +Date: Mon, 16 Apr 2018 13:01:41 +0900 +Subject: [PATCH] tcp: fix tcp_socket_dead() for FreeBSD + +The FreeBSD port of tvheadend couldn't stream Live TV, and debug +log shows webui judged the peer socket closed immediately after +starting streaming: + +2018-04-15 06:30:04.996 [ DEBUG]:webui: Start streaming /stream/mux/c4bc67bdaa13457e33740ca883cc4d75?ticket=7D1B56AD0E434C5F7EBFA4677A7FBE4C94097974 +2018-04-15 06:30:04.996 [ DEBUG]:webui: Stop streaming /stream/mux/c4bc67bdaa13457e33740ca883cc4d75?ticket=7D1B56AD0E434C5F7EBFA4677A7FBE4C94097974, client hung up + +It looks because tcp_socket_dead() misunderstood the zero-return +from recv(). For the FreeBSD, recv() might return zero for alive +sockets which have nothing to read. + +Patch tested with the latest FreeBSD port of tvheadend-4.2.6. +--- + src/tcp.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/tcp.c b/src/tcp.c +index 40f6c1c0cc..9b865eb292 100644 +--- src/tcp.c ++++ src/tcp.c +@@ -453,8 +453,13 @@ tcp_socket_dead(int fd) + return -errno; + if (err) + return -err; ++#ifdef PLATFORM_FREEBSD ++ if (recv(fd, NULL, 0, MSG_PEEK | MSG_DONTWAIT) < 0) ++ return -errno; ++#else + if (recv(fd, NULL, 0, MSG_PEEK | MSG_DONTWAIT) == 0) + return -EIO; ++#endif + return 0; + } +