comparison lib-src/i.c @ 2426:bb3f73fbbda8

[xemacs-hg @ 2004-12-07 00:20:51 by ben] fix data loss from i.c i.c: Undo change of 2003-03-06. It causes truncation of output at the end.
author ben
date Tue, 07 Dec 2004 00:20:51 +0000
parents 01c57eb70ae9
children 49316578f12d
comparison
equal deleted inserted replaced
2425:b3315b0c8558 2426:bb3f73fbbda8
65 { 65 {
66 I_connector* pi = (I_connector*) pv_i; 66 I_connector* pi = (I_connector*) pv_i;
67 BYTE buffer [256]; 67 BYTE buffer [256];
68 DWORD really_read, unused; 68 DWORD really_read, unused;
69 69
70 /* The docs for ReadFile claim: 70 /* I said:
71
72 [[ The docs for ReadFile claim:
71 73
72 The ReadFile function returns when one of the following is true: a write 74 The ReadFile function returns when one of the following is true: a write
73 operation completes on the write end of the pipe, the number of bytes 75 operation completes on the write end of the pipe, the number of bytes
74 requested has been read, or an error occurs. 76 requested has been read, or an error occurs.
75 77
76 But this is just not true. ReadFile never seems to block, and unless we 78 But this is just not true. ReadFile never seems to block, and unless we
77 Sleep(), we will chew up all the CPU time. --ben 79 Sleep(), we will chew up all the CPU time. --ben ]]
78 */ 80
81 But in fact
82
83 [a] this does not appear to be the case any more [maybe a temporary
84 bug in some versions of Win2000?]
85 [b] it causes data lossage. [#### Why should this be? Seems extremely
86 fishy. I tried commenting out the calls to close the standard
87 handles at the bottom of the program, but it made no difference.
88 Would we need some kind of additional handshaking? If we get
89 data loss with the sleep, then we are a race condition waiting
90 to happen. */
79 while (ReadFile (pi->source, buffer, sizeof (buffer), &really_read, NULL) && 91 while (ReadFile (pi->source, buffer, sizeof (buffer), &really_read, NULL) &&
80 WriteFile (pi->drain, buffer, really_read, &unused, NULL)) 92 WriteFile (pi->drain, buffer, really_read, &unused, NULL))
81 Sleep (100); 93 /* Sleep (100) */ ;
82 94
83 return 0; 95 return 0;
84 } 96 }
85 97
86 /* 98 /*