From patchwork Thu Aug 29 23:14:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 14803 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 828584492A9 for ; Fri, 30 Aug 2019 02:14:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5C6A0687F35; Fri, 30 Aug 2019 02:14:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9575D687F34 for ; Fri, 30 Aug 2019 02:14:39 +0300 (EEST) X-QQ-mid: bizesmtp18t1567120471tdmk9xu7 Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Fri, 30 Aug 2019 07:14:30 +0800 (CST) X-QQ-SSF: 01100000008000K0ZQF1B00A0000000 X-QQ-FEAT: 0abLp1D7a8L+fLsoxn7GH6NPL0cZ3WyUItjZO5xoERzp66x/Fd6syrIcbiSUv PSLxn9w7eHFNrYgl2h1jUfvwoupRJxNQFcM3xuP0qx2lfQnDmKdlVdLVGbeNgMXyj1JWs7B NGvo9PSo5cWwVSB7HefpRIXS3KtmhUeqHUlLJucKZlTwZy2ofXsF3T9WsrZsyw4xcSE9RSG QYj/GnjKOt3qRZBYFnCNbbZUA7E8Wtun3OHdb2j7TEVtxrsI0VqIWpRe86jmNoH++aGOcFT 4rdD5DSTlbWfLifjYQFyFqTq/4I1M1225orH3V5YQfnX/da10TgxLGspI= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Aug 2019 07:14:27 +0800 Message-Id: <20190829231428.27877-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/http: add ff_http_get_shutdown_status api for check the status of shutdown X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" this function is used to get the previous shutdown status when reusing the old connection in block mode. Signed-off-by: Steven Liu --- libavformat/http.c | 16 ++++++++++++++++ libavformat/http.h | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 579debcd35..71dd6c2b1f 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -304,6 +304,22 @@ fail: return location_changed; return ff_http_averror(s->http_code, AVERROR(EIO)); } +int ff_http_get_shutdown_status(URLContext *h) +{ + int ret = 0; + HTTPContext *s = h->priv_data; + + /* flush the receive buffer when it is write only mode */ + char buf[1024]; + int read_ret; + read_ret = ffurl_read(s->hd, buf, sizeof(buf)); + if (read_ret < 0) { + ret = read_ret; + } + + return ret; +} + int ff_http_do_new_request(URLContext *h, const char *uri) { diff --git a/libavformat/http.h b/libavformat/http.h index 7d02713e31..662bd2cab6 100644 --- a/libavformat/http.h +++ b/libavformat/http.h @@ -37,6 +37,15 @@ */ void ff_http_init_auth_state(URLContext *dest, const URLContext *src); +/** + * Get the HTTP shutdown response status, be used after http_shutdown. + * + * @param h pointer to the resource + * @return a negative value if an error condition occurred, 0 + * otherwise + */ +int ff_http_get_shutdown_status(URLContext *h); + /** * Send a new HTTP request, reusing the old connection. *