summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Osterried <thomas@osterried.de>2009-01-24 18:03:48 +0000
committerThomas Osterried <thomas@osterried.de>2009-01-24 18:03:48 +0000
commit2ede1a405f5bf472ba03fe4285fb0b43f5d3c137 (patch)
tree11f073d3c266ff2d1b1d518f80e9e6c47b154888
parente534aedb6fea927c7dc8df07d3ef5d2e27862f31 (diff)
Hope this is the last fix for the slightly corrupted output
issue whenever a packet ended with "\r ".
-rw-r--r--call/call.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/call/call.c b/call/call.c
index 8016722..a098562 100644
--- a/call/call.c
+++ b/call/call.c
@@ -1586,10 +1586,10 @@ int cmd_call(char *call[], int mode)
static int last_line_was_cr = 1;
int this_line_has_cr = 0;
char buf2[MAX_BUFLEN];
- unsigned long buf2_len = 0L;
+ int buf2_len = 0L;
int i;
/* bytes = read(fd, buf, 511); */
- bytes = read(fd, buf, paclen);
+ bytes = read(fd, buf, sizeof(buf));
if (bytes == 0) {
/* read EOF on stdin */
/* cause program to terminate */
@@ -1633,7 +1633,7 @@ next_read_line_from_fd:
* then searche_key_words misinterprets " go_7+. "
* as start of a line.
*/
- if (last_line_was_cr) {
+ if (last_line_was_cr && this_line_has_cr) {
com_num = searche_key_words(buf, &bytes, parms, &parmsbytes, restbuf, &restbytes);
} else {
com_num = -1;
@@ -2079,6 +2079,7 @@ next_read_line_from_fd:
if (bytes > 0) {
unsigned long offset = 0L;
sevenplus = FALSE;
+ int err = 0;
if (uploadfile != -1) {
statline(mode,
"Ignored. Type ~s to stop upload");
@@ -2087,15 +2088,20 @@ next_read_line_from_fd:
convert_lf_cr(buf, bytes);
while (offset != bytes) {
- int ret = write(fd, buf+offset, bytes-offset);
+ int len = (bytes-offset > paclen) ? paclen : bytes-offset;
+ int ret = write(fd, buf+offset, len);
if (ret == -1) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ usleep(100000);
+ continue;
+ }
perror("write");
- offset=-1;
+ err = 1;
break;
}
offset += ret;
}
- if (offset == -1)
+ if (err)
break;
}
}