From patchwork Tue Mar 14 02:12:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gareth McMullin X-Patchwork-Id: 19557 Received: (qmail 23164 invoked by alias); 14 Mar 2017 02:13:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 23067 invoked by uid 89); 14 Mar 2017 02:13:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*f:mfLAOusr, H*i:sk:c50f945, H*f:sk:c50f945, H*f:0CyBC X-HELO: mail-vk0-f43.google.com Received: from mail-vk0-f43.google.com (HELO mail-vk0-f43.google.com) (209.85.213.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Mar 2017 02:13:07 +0000 Received: by mail-vk0-f43.google.com with SMTP id t8so45144755vke.3 for ; Mon, 13 Mar 2017 19:13:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oqbRO2dZaP8z+Gs/8KT0I5qZjqSggF9IxN9jb92pcU0=; b=aFWaToWrM6ZlTyMHat9w2PuUUyM0jm+LpkbDjQhCC7e2U70pcNWpLFs1Q5t+5Qnkws tKeziEXJmQlpEFVTbo8zhljqmL1k3YfN+8Yb7xKvnkOOSjAa9OlxQTIfMgLJ8w4Mc/N2 IX3jVwZBjkgJhLmKLZPWU3JxjxEQjaiP52X69PXuR60cOWRANTclTU0UFbOzfNeU7brG t2JMlxYH0RKxUQYfIkSp1vVfe0UsD/v2bF6+jdx087BHotCCGYWI3JmmGVLxawNSwYzY Wp1QsI8mAHb0xuhd1j5NxsDsSrJiV13mpkp6qZEMjTge+5/hhifGRkhO4tnjEoEyFb6v I9XA== X-Gm-Message-State: AMke39mZM0LH9R3PA891XePy/J0kKSsIuRC9eq5zgUdqSvHrjnlwnMQlOAx1WGhaCPCJM78gIii73xI3r75QLg== X-Received: by 10.31.59.197 with SMTP id i188mr13042485vka.45.1489457586525; Mon, 13 Mar 2017 19:13:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.102.68 with HTTP; Mon, 13 Mar 2017 19:12:46 -0700 (PDT) In-Reply-To: References: <630aafbb-8684-5aea-0fa1-f0f538b4eb02@ericsson.com> From: Gareth McMullin Date: Tue, 14 Mar 2017 15:12:46 +1300 Message-ID: Subject: Re: [PATCH] PR remote/21188: Fix remote serial timeout To: Simon Marchi Cc: Simon Marchi , gdb-patches@sourceware.org X-IsSubscribed: yes On Tue, Mar 14, 2017 at 2:40 PM, Simon Marchi wrote: > Thanks for the updated patch. I just gave it a quick look, and it looks > good functionally. Just a little formatting issue. The four lines: > > else if (timeout_remaining < 0) > continue; > else > return SERIAL_TIMEOUT; > > should have one less indent (shift them two spaces to the left). Thank you. Corrected. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 608501b..111cf4d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-03-14 Gareth McMullin + + PR remote/21188 + * ser-unix.c (do_hardwire_readchar): Wait for full timeout to elapse. + * serial.h (serial_t): Remove fields current_timeout and timeout_remaining. + 2017-03-14 Pedro Alves * cp-name-parser.y (cp_demangled_name_to_comp): Update comment. diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index b9e55f0..7f73af8 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -441,8 +441,6 @@ hardwire_raw (struct serial *scb) state.sgttyb.sg_flags &= ~(CBREAK | ECHO); #endif - scb->current_timeout = 0; - if (set_tty_state (scb, &state)) fprintf_unfiltered (gdb_stderr, "set_tty_state failed: %s\n", safe_strerror (errno)); @@ -546,9 +544,21 @@ do_hardwire_readchar (struct serial *scb, int timeout) if (detach) return SERIAL_TIMEOUT; - scb->timeout_remaining = (timeout < 0 ? timeout : timeout - delta); + int timeout_remaining = (timeout < 0 ? timeout : timeout - delta); status = wait_for (scb, delta); + if (status == SERIAL_TIMEOUT) { + if (timeout_remaining > 0) + { + timeout = timeout_remaining; + continue; + } + else if (timeout_remaining < 0) + continue; + else + return SERIAL_TIMEOUT; + } + if (status < 0) return status; @@ -556,21 +566,7 @@ do_hardwire_readchar (struct serial *scb, int timeout) if (status <= 0) { - if (status == 0) - { - /* Zero characters means timeout (it could also be EOF, but - we don't (yet at least) distinguish). */ - if (scb->timeout_remaining > 0) - { - timeout = scb->timeout_remaining; - continue; - } - else if (scb->timeout_remaining < 0) - continue; - else - return SERIAL_TIMEOUT; - } - else if (errno == EINTR) + if (errno == EINTR) continue; else return SERIAL_ERROR; /* Got an error from read. */ diff --git a/gdb/serial.h b/gdb/serial.h index cf4e659..2900507 100644 --- a/gdb/serial.h +++ b/gdb/serial.h @@ -250,11 +250,6 @@ struct serial buffer. -ve for sticky errors. */ unsigned char *bufp; /* Current byte */ unsigned char buf[BUFSIZ]; /* Da buffer itself */ - int current_timeout; /* (ser-unix.c termio{,s} only), last - value of VTIME */ - int timeout_remaining; /* (ser-unix.c termio{,s} only), we - still need to wait for this many - more seconds. */ struct serial *next; /* Pointer to the next `struct serial *' */ int debug_p; /* Trace this serial devices operation. */ int async_state; /* Async internal state. */