mirror of
https://github.com/golang/go
synced 2024-11-18 20:24:41 -07:00
cmd/ld: retry short writes, to get error detail
Fixes #3802. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7228066
This commit is contained in:
parent
956cd0059c
commit
592b480746
@ -1447,6 +1447,23 @@ Yconv(Fmt *fp)
|
|||||||
|
|
||||||
vlong coutpos;
|
vlong coutpos;
|
||||||
|
|
||||||
|
static void
|
||||||
|
dowrite(int fd, char *p, int n)
|
||||||
|
{
|
||||||
|
int m;
|
||||||
|
|
||||||
|
while(n > 0) {
|
||||||
|
m = write(fd, p, n);
|
||||||
|
if(m <= 0) {
|
||||||
|
cursym = S;
|
||||||
|
diag("write error: %r");
|
||||||
|
errorexit();
|
||||||
|
}
|
||||||
|
n -= m;
|
||||||
|
p += m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cflush(void)
|
cflush(void)
|
||||||
{
|
{
|
||||||
@ -1455,13 +1472,8 @@ cflush(void)
|
|||||||
if(cbpmax < cbp)
|
if(cbpmax < cbp)
|
||||||
cbpmax = cbp;
|
cbpmax = cbp;
|
||||||
n = cbpmax - buf.cbuf;
|
n = cbpmax - buf.cbuf;
|
||||||
if(n) {
|
dowrite(cout, buf.cbuf, n);
|
||||||
if(write(cout, buf.cbuf, n) != n) {
|
|
||||||
diag("write error: %r");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
coutpos += n;
|
coutpos += n;
|
||||||
}
|
|
||||||
cbp = buf.cbuf;
|
cbp = buf.cbuf;
|
||||||
cbc = sizeof(buf.cbuf);
|
cbc = sizeof(buf.cbuf);
|
||||||
cbpmax = cbp;
|
cbpmax = cbp;
|
||||||
@ -1502,10 +1514,7 @@ cwrite(void *buf, int n)
|
|||||||
cflush();
|
cflush();
|
||||||
if(n <= 0)
|
if(n <= 0)
|
||||||
return;
|
return;
|
||||||
if(write(cout, buf, n) != n) {
|
dowrite(cout, buf, n);
|
||||||
diag("write error: %r");
|
|
||||||
errorexit();
|
|
||||||
}
|
|
||||||
coutpos += n;
|
coutpos += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user