From patchwork Thu May 31 22:24:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Holljes X-Patchwork-Id: 9197 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp162650jad; Thu, 31 May 2018 15:26:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI/4WLlef8wZlOR3IibeAHeqfV9OaDTG1joUHWke6seEdOWE4KO4i+agFS5a+VVWvg7O+LH X-Received: by 2002:adf:88b2:: with SMTP id f47-v6mr6311939wrf.55.1527805602389; Thu, 31 May 2018 15:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527805602; cv=none; d=google.com; s=arc-20160816; b=OJJM5SX1X4uVADmulIPw+S8QosU7PlLxaQRoUGr5okt0AeLfIaOsKLDgq45/5gnWqc 05oHzioz/NPQ7DIk7wD0Gczx2LYnTE/zZzYDKoDnXv/OVYEFm6KQyGgVdwl4hFgfphLf uZzJXO4DQfHRwa6CwZZ3V16xzJCqw03KlmHhyRoqK1pvt1e2PrhLm62DznBAXoYn7ldC 4twGTfEjIjrPcv2ciTXAj27hCYNIFz034puxPc5lRC5RtfT4iQievfWMM2k+xSF4g1Qi HE5E8mAlShBngEB+mNbihpTuocKrTbYKc5t6PGuNXUn+B2ncfp+X1u7Nva8shBcKbXPR Q8Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=VwLA5EedjLDgKD5QIWzKO3mfx5UBWhJNFtXqJOSYQ60=; b=lmRTvHpdDl2EMccjPk3GamuQ/eA18UgTpbRk0i16mp8bFXtivuafjra3bJFB73ykuY 5MKZZfgqLXLAsOzVI6DRKStc0n+e5uMfyNhYumkoBZei8RFS4QGJlfZe/tQsC2gE7DJr eFqK6B5tMd6tvJKmWbATYG6lzV/LULDcTNLZntSi2Jk5HgYPm4aIUOxod6C5AIWmq8Gu ON7fZioXyrrSNC3dRHrMtJiqkT84CQcGY++uRekXEJHw6HaLMDv4Mw/eY6Y0sTkg/mkH aip77T6+eWB1DaQCz8vntXjcaLZTdU/R6zThdM1TTS/9LnUyqQ2GSiWE4ypfBMV0PUiB avgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@googlemail.com header.s=20161025 header.b=cftbUUYq; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n189-v6si323792wme.90.2018.05.31.15.26.41; Thu, 31 May 2018 15:26:42 -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; dkim=neutral (body hash did not verify) header.i=@googlemail.com header.s=20161025 header.b=cftbUUYq; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE62768A502; Fri, 1 Jun 2018 01:24:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27E2668A4F4 for ; Fri, 1 Jun 2018 01:24:01 +0300 (EEST) Received: by mail-wm0-f42.google.com with SMTP id 18-v6so51101443wml.2 for ; Thu, 31 May 2018 15:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JbdxMsibSvvyeUdT6dcQjRt25CvRgQfhFvJpgY5MatY=; b=cftbUUYqTHYcqVg8DGLdItA2GQAOfznjQnk6BIW5s8FIdYDjBN0XxV4C7yCbrXsguZ 1gGWPKCC25U66zNuiiTM5jojRop3UUY0SuA+QPbQn8x/Vd73rpf/DbF85ukP9OyrHafo 5Q7QcNzA0fi1tkG9uHaYWnC0Sfx54c0+CnW96gt08D5Bs1UuChp9RDn+t8/j1Rvuedm6 n2AtJzVHE3HPi5uMegI/K6rQ/l9BykKsVgk7CgDvq1EnQBUW73uzKnOA6zOljpLaZNOB 53XkEeY6G7xgXy6U7B9JLP61HHNv0wl4K4ccenOOmF+fZTSF2hN18JpsIK/kRBWaGdH7 Kt+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JbdxMsibSvvyeUdT6dcQjRt25CvRgQfhFvJpgY5MatY=; b=WhF0Cv/5JP2FLdVWfCKZjzy6z2TWAk6ZLnertZ0FBz2yRIzVk8Se0u3kGippZRXz40 whtUoeC64zZN8ZccZaWyPH0Sr0i+KRf01ivTZW6fcvWUeCHTA1fdRdB4K63SOrbY0eTr 4RGzuHP+wZH3Nog3VHfbviiohWjNznMoS2928LZCZf9L4Rqq69ovSAyLawV53boxvNqY yUW2/ys7hLf/QrbOmCYVmeNjOXJInybYVJxolOT1elxnyxqbOGQeiOXiR1HDGMtbYcIA 0jgL7o6QWCboxUJXmZB05UeGe0EHJeRGF6H3Coj4p1q9DmVkQ1koi+aRS9qBZQff1a5o WReQ== X-Gm-Message-State: APt69E1LV3lddns4p2l2IBDXun6e1N7CLluQaUwsMon0EBZE1ukhc89o QycJZ1cKW/0Pxa4dftXb0jRTjg== X-Received: by 2002:a1c:c10b:: with SMTP id r11-v6mr1032669wmf.120.1527805485566; Thu, 31 May 2018 15:24:45 -0700 (PDT) Received: from localhost.localdomain ([46.5.2.0]) by smtp.gmail.com with ESMTPSA id b72-v6sm705017wmf.11.2018.05.31.15.24.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 15:24:44 -0700 (PDT) From: Stephan Holljes To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Jun 2018 00:24:09 +0200 Message-Id: <20180531222415.24966-17-klaxa1337@googlemail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180531222415.24966-1-klaxa1337@googlemail.com> References: <20180528182711.3221-1-klaxa1337@googlemail.com> <20180531222415.24966-1-klaxa1337@googlemail.com> Subject: [FFmpeg-devel] [PATCH 16/22] lavfhttpd.c: Detect disconnected clients through amount of bytes written. 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: Stephan Holljes MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Stephan Holljes --- lavfhttpd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lavfhttpd.c b/lavfhttpd.c index b1e8819..9f56620 100644 --- a/lavfhttpd.c +++ b/lavfhttpd.c @@ -120,8 +120,14 @@ int lavfhttpd_accept(void *server, struct HTTPClient **client, int reply_code) int lavfhttpd_write(void *server, struct HTTPClient *client, const unsigned char *buf, int size) { AVIOContext *client_ctx = (AVIOContext*) client->httpd_data; + int64_t old_written = client_ctx->written; + int64_t actual_written; avio_write(client_ctx, buf, size); avio_flush(client_ctx); + actual_written = client_ctx->written - old_written; + if (actual_written < size) { + return AVERROR_EOF; + } return size; }