aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-03-28 08:24:28 +0000
committerAndrew Cagney <cagney@redhat.com>2000-03-28 08:24:28 +0000
commit2171aa415b4c6687292ea72e7f612cc7a24fbdcc (patch)
treefc453e9073341c0c886497768876c1aa2f57efee /gdb
parent5d161b24198e362be0f768e76e6f76bd110d8acb (diff)
downloadgdb-2171aa415b4c6687292ea72e7f612cc7a24fbdcc.zip
gdb-2171aa415b4c6687292ea72e7f612cc7a24fbdcc.tar.gz
gdb-2171aa415b4c6687292ea72e7f612cc7a24fbdcc.tar.bz2
From Jonathan L. Fix ser-unix.c timing out when there was no timeout.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ser-unix.c65
2 files changed, 33 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc83460..24b1811 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+Tue Mar 28 18:19:50 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ From 2000-03-20 Jonathan Larmour <jlarmour@redhat.co.uk>:
+ * ser-unix.c (do_unix_readchar): Reorganise to be more robust,
+ particularly ensuring it can't return SERIAL_TIMEOUT when told
+ not to time out.
+
2000-03-24 Daniel Berlin <dan@cgsoftware.com>
* gdbtypes.c (_initialize_gdbtypes): Add "set debug overload",
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index 919c9fd..47b6647 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -910,9 +910,9 @@ do_unix_readchar (serial_t scb, int timeout)
each time through the loop.
Also, timeout = 0 means to poll, so we just set the delta to 0, so we
- will only go through the loop once. */
+ will only go through the loop once. timeout < 0 means to wait forever. */
- delta = (timeout == 0 ? 0 : 1);
+ delta = (timeout <= 0 ? 0 : 1);
while (1)
{
@@ -928,51 +928,38 @@ do_unix_readchar (serial_t scb, int timeout)
return SERIAL_TIMEOUT;
}
- status = ser_unix_wait_for (scb, delta);
+ status = ser_unix_wait_for (scb, timeout < 0 ? timeout : delta);
timeout -= delta;
- /* If we got a character or an error back from wait_for, then we can
- break from the loop before the timeout is completed. */
+ /* If we got an error back from wait_for, then we can return */
- if (status != SERIAL_TIMEOUT)
- {
- break;
- }
+ if (status == SERIAL_ERROR)
+ return status;
- /* If we have exhausted the original timeout, then generate
- a SERIAL_TIMEOUT, and pass it out of the loop. */
+ status = read (scb->fd, scb->buf, BUFSIZ);
- else if (timeout == 0)
- {
- status = SERIAL_TIMEOUT;
- break;
+ if (status <= 0)
+ {
+ if (status == 0)
+ {
+ if (timeout != 0)
+ continue;
+ else
+ return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
+ distinguish between EOF & timeouts
+ someday] */
+ }
+ else if (errno == EINTR)
+ continue;
+ else
+ return SERIAL_ERROR; /* Got an error from read */
}
- }
-
- if (status < 0)
- return status;
- while (1)
- {
- status = read (scb->fd, scb->buf, BUFSIZ);
- if (status != -1 || errno != EINTR)
- break;
- }
-
- if (status <= 0)
- {
- if (status == 0)
- return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
- distinguish between EOF & timeouts
- someday] */
- else
- return SERIAL_ERROR; /* Got an error from read */
+ scb->bufcnt = status;
+ scb->bufcnt--;
+ scb->bufp = scb->buf;
+ return *scb->bufp++;
}
-
- scb->bufcnt = status;
- scb->bufcnt--;
- scb->bufp = scb->buf;
- return *scb->bufp++;
}
/* Perform operations common to both old and new readchar. */