From patchwork Sat Sep 11 09:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 30148 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2284743iov; Sat, 11 Sep 2021 02:47:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwsUMs7EcmxzXLJuyKt7cQ5FMw6FgRG+8uEzVP/p9kLeSg0m2tVRH9XMeWfaoGzgHEsY0R X-Received: by 2002:a17:906:a3d2:: with SMTP id ca18mr2090651ejb.274.1631353651408; Sat, 11 Sep 2021 02:47:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631353651; cv=none; d=google.com; s=arc-20160816; b=dt2vZ9W4rPzmQ8lWQvQmQXlnZelyKoqN6OXO/r88yaZoRoyc//RcQXVIp+y9THUNBN D9k9Vf8gBA7iZ790VcAGC62KGk7h+91e27kbuZAgUzQtvKK3B0AwnSwD/UOSkijiyBB+ 6Bhz9kVrXLDBagK52aUgfDgATjNodq7AS7ipWm8ChE4hZOpiqVmpbSpShQq6Lsuc/XMt oIOj/T8Cux12ogvFRNjBxo+1VkvUQUxTTZyk0UgtrLRW/znrEugOjtMxKvW4+nJItIO2 GNbf+ql0oZzVRkoZwja7vDx/Rs/zvwWIiZQBpAbL1l/65fFI959sc0CSz2QuuYyu7jmG wJfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:feedback-id:to:date:message-id :mime-version:from:delivered-to; bh=qq4tj9HIsGFiNu/eFnLD5zKF6YQYqXCxHhXAbTvHNZQ=; b=oErU8Kxy2zzy1tT9ES3MFe9cujVO7qVlj8vZO2cN5Ln1kIM0uwnWtotsNoKpwgUoVu CvlNQBHpZ2CUNArmq8SOk3qWyeLVJk0VczI0ZhCZ/LSO0h8z8Dh6fWTk9vRJOomXSGi1 3CCPn9lftoeUOEacA/E/6b9WfOleb/o2E5gaxQLq/xsT9NXNtkxl78eqBHoDe6WZp02T cHfLMxkeZDHPs3xITbHRocKQ3mPI8X0bA9mNkiGYATZaF9NZu+HhklWC844J2+mLyVtW fdgZJZVoZYxpaEVIrDIN3Km0xdswpPCFr6TFKugchGpwGKmEhvgeZ60ZLSmPFSD7po+R L2EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u1si1754132edc.285.2021.09.11.02.47.30; Sat, 11 Sep 2021 02:47:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FF3368A4D5; Sat, 11 Sep 2021 12:47:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg587.qq.com (smtpbg126.qq.com [106.55.201.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F77D687EBB for ; Sat, 11 Sep 2021 12:47:19 +0300 (EEST) X-QQ-mid: bizesmtp40t1631353566tig6fy5v Received: from [192.168.3.15] (unknown [114.245.24.111]) by esmtp6.qq.com (ESMTP) with id ; Sat, 11 Sep 2021 17:46:05 +0800 (CST) X-QQ-SSF: 00100000004000Z0Z000000A0000000 X-QQ-FEAT: 90EFqYDyPxCVFn0Dbv4Z0ElxpVz1GVWn+XSdfruxDhwCbMu/t68ZUEI7x9/ci LYZzAy2rPOVs/SY0Tuc9EglZvMb3t1Io5ztvtuMa7aa0z7/+jbd1uGtGaeR3Wgjq9CM3ZhZ oJmdDZBA08TEj/5qwoFYV0uc6TV+g6KvzfAlKSwBHWlVIDo+f8k5uHVmu3wtcPQzEH+5RlZ IKRw+HRsTCTqhlw2MWZtHR4ccKaLamYU4IfajH3c2cCJS95UGrC6aEb6pmf1XeasnRlD6V9 8WNevPu5cjlY9npT71wIHzfBzSlagInjRXTuS9W6ihyjsmAMhsx0BdpZQ4yxR/imTy68Z6O p/ftXw8 X-QQ-GoodBg: 0 From: Steven Liu Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Message-Id: Date: Sat, 11 Sep 2021 17:45:06 +0800 To: FFmpeg development discussions and patches X-Mailer: Apple Mail (2.3445.9.7) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgspam:qybgspam2 Subject: [FFmpeg-devel] [RFC] Reconnect and PUT file continue by ffmpeg base https on windows X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7EyxplmYPSgh Hello everyone, There have two tickets about Reconnect and PUT file continue by hlsenc. The first one is https://trac.ffmpeg.org/ticket/7975. It be fixed use the way ff_http_get_shutdown_status after furl_shutdown, But it get second problem. The ff_http_get_shutdown_status will block in Schannel on windows operating system in http_persistent mode. It’s ok by other operating system or non http_persistent mode. I think three ways to fix the new problem https://trac.ffmpeg.org/ticket/9010 but i cannot sure which way should better. First way: set socket flags of tcp NONBLOCK ----------------------------------------- $ git diff ----------------------------------------- I think this is not pretty. :( There maybe have some other ways, Do you have some suggestions. Thanks Steven diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c index d4959f75fa..f5d048f9e5 100644 --- a/libavformat/tls_schannel.c +++ b/libavformat/tls_schannel.c @@ -414,14 +414,15 @@ static int tls_read(URLContext *h, uint8_t *buf, int len) return ret; } } - + c->tls_shared.tcp->flags &= ~AVIO_FLAG_NONBLOCK; + c->tls_shared.tcp->flags |= h->flags & AVIO_FLAG_NONBLOCK; ret = ffurl_read(s->tcp, c->enc_buf + c->enc_buf_offset, c->enc_buf_size - c->enc_buf_offset); if (ret == AVERROR_EOF) { c->connection_closed = 1; ret = 0; } else if (ret < 0) { - av_log(h, AV_LOG_ERROR, "Unable to read from socket\n"); + av_log(h, AV_LOG_ERROR, "Unable to read from socket ret = [%s]\n", av_err2str(ret)); return ret; } ----------------------------------------- This way will get error code when ret < 0, but all the hls PUT will success process, there maybe have some risk for other module if merge this modify, ----------------------------------------- Second way: $ git diff diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 7c37bc50b9..86cdb897a4 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -314,9 +314,11 @@ static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) #if CONFIG_HTTP_PROTOCOL } else { URLContext *http_url_context = ffio_geturlcontext(*pb); + const char *proto = avio_find_protocol_name(filename); av_assert0(http_url_context); avio_flush(*pb); ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE); + if (av_strcasecmp(proto, "https")) ret = ff_http_get_shutdown_status(http_url_context); #endif } ----------------------------------------- This way can fix the problem too, But this will ignore all the http status which return from server base on all operating systems. Third way: diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 7c37bc50b9..0ede8856a4 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -317,7 +317,9 @@ static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) av_assert0(http_url_context); avio_flush(*pb); ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE); +#if !CONFIG_SCHANNEL ret = ff_http_get_shutdown_status(http_url_context); +#endif #endif } return ret;