From patchwork Wed May 15 09:29:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wamelink X-Patchwork-Id: 1099907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::c3a; helo=mail-yw1-xc3a.google.com; envelope-from=swupdate+bncbd6oxp525akbb7nx57takgqe6z6tjqq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="hCXUNVgI"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eRPBAe9f"; dkim-atps=neutral Received: from mail-yw1-xc3a.google.com (mail-yw1-xc3a.google.com [IPv6:2607:f8b0:4864:20::c3a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 453q5D6BCRz9sD4 for ; Wed, 15 May 2019 19:29:36 +1000 (AEST) Received: by mail-yw1-xc3a.google.com with SMTP id b81sf1720782ywc.8 for ; Wed, 15 May 2019 02:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:subject:mime-version :x-original-sender:precedence:mailing-list:list-id:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=JXb4NvKfy9Xxroh20Fn6DoI5vJgWpowsRbcgirxcHiw=; b=hCXUNVgIp7TdxsJqu2LiI2sAVOcxk3N/uZEdgWGzOwnq5zyXJPubFLY1Z71CADzYa9 si+AGX+hvLfJe1r+9b9yMOfCcYrcmq3dId+Tf3qOOTfZdTPb/UX+fuAdBpvuYJ+S3uO+ fxaTk2pN9gCzgF3Msr9I3S66KL0n+aEBoJ1WSLrWzgYUsU+Fcc3C3tUYeoPNjpqHnbR1 ltKCSoH9WaYYQeFh9s1mmNmPeCOJbz8EjeThdLywO2NXoRrDIXC0dZHpGZPMbEY59EMy JHiiEKTJR6MBGCskWYc2fWgU9p4qCMn7xacZMRJzfiAAir1ungbGhher/W13Mjip3mZP rluw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:subject:mime-version:x-original-sender :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=JXb4NvKfy9Xxroh20Fn6DoI5vJgWpowsRbcgirxcHiw=; b=eRPBAe9fheRF0ypJfNxPtNxVEw59adQJ0S2msW3hn75QGCNITW4XPB8c5Y7/7B2g+R dIR0xuwPUItZZKRPID23pUEO0QvoSsz5xetBKmvwzlG8qX02Q3mWUOhQmsu3Ij1Q27jK 9yDRXRJ1bFxj0geBDRuHfywDmTlrr1wN1WpfeX21n/T9K44Sfw6AznleNSMRz8mW2Ijc iAJjHx25UDJa+pR/xS+MAW6uN3tzyBTI4ClM2lk+3vmqsYauXKnHD/BgthgL56pDeqMV kpbbRIuUHIAeqRY0U41cVsDBZ4RVQ5rF4Hkl26DAWjOiOd/qEX7t5YVrgBJ45e/AixDR IjBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:subject :mime-version:x-original-sender:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=JXb4NvKfy9Xxroh20Fn6DoI5vJgWpowsRbcgirxcHiw=; b=LNqycEgXXqzgouVWkkV068ucmfFUlwABEDmqJRDbMX5+IKhnUEF1sTU6cXQ4En8axH uFZ1RwKoD+tq4Ktid5cfy6wwIrZGUnujjHGBPx1h8jDSZCdk+YLdOzYG/4oLqlGdNwds mY9nv1tg+DA1K0SSMUnltIJmgD8erOvj2EYFsRusU3fK9u+G73RP7hMtWUcRUMwq92PJ qeHVNOY6ZTGQDybDp+EmY8aozblOQ6gvdgJSV5YU7ftbx02QyN1AQwEEv8gt8GIwsbrD iVDSB5fJROaNsvwxWz8TN9Cpx21qnxCSGHGMXHmrV9+Qc1sCQlNQ9CUk4LGUBwdHaciF 342Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAVP25V2D+YYf6A/k41thVlyl5qg9qzfXGPk2Cn0QKJiqnzd5mAg 1VTMKfJoAIDBaMk1Ms+yhQ8= X-Google-Smtp-Source: APXvYqzPgH4pNB5FolaqMRseguq+jaV1Pyroy8OuE9sKTw7Oxoh+bJdnl6Y9u0h9/EL5hyn9ISArRg== X-Received: by 2002:a25:ba44:: with SMTP id z4mr19391016ybj.304.1557912573419; Wed, 15 May 2019 02:29:33 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a25:244b:: with SMTP id k72ls192274ybk.11.gmail; Wed, 15 May 2019 02:29:33 -0700 (PDT) X-Received: by 2002:a25:a325:: with SMTP id d34mr12512387ybi.58.1557912572862; Wed, 15 May 2019 02:29:32 -0700 (PDT) Date: Wed, 15 May 2019 02:29:32 -0700 (PDT) From: Simon Wamelink To: swupdate Message-Id: Subject: [swupdate] Interrupted image upload causes mongoose interface to always return "500 Failed to queue command" MIME-Version: 1.0 X-Original-Sender: SimonWamelink@gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Hi, If a file upload is interrupted before completing the mongoose interface will always send 500 errors on subsequent requests. I've traced this issue back to fus->fd not being closed when the connection is interrupted. Any calls to ipc_inst_start_ext() after that will fail since the previous file descriptor is not closed. I've made an workaround for this issue but think this could be done better. Kind regards, Simon Wamelink break; diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c index 68ff675..503fcb1 100644 --- a/mongoose/mongoose_interface.c +++ b/mongoose/mongoose_interface.c @@ -57,6 +57,7 @@ struct file_upload_state { static struct mg_serve_http_opts s_http_server_opts; static void upload_handler(struct mg_connection *nc, int ev, void *p); +static int fus_fd = -1; /* * These functions are for V2 of the protocol @@ -389,9 +390,16 @@ static void upload_handler(struct mg_connection *nc, int ev, void *p) if (fus->fd < 0) { mg_http_send_error(nc, 500, "Failed to queue command"); free(fus); + + if (fus_fd > 0) { + ipc_end(fus_fd); + fus_fd = -1; + } break; } + fus_fd = fus->fd; + mp->user_data = fus;