equal
deleted
inserted
replaced
38 ** $QT_END_LICENSE$ |
38 ** $QT_END_LICENSE$ |
39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include "qwindowspipewriter_p.h" |
42 #include "qwindowspipewriter_p.h" |
|
43 #include <string.h> |
43 |
44 |
44 QT_BEGIN_NAMESPACE |
45 QT_BEGIN_NAMESPACE |
45 |
46 |
46 #ifndef QT_NO_THREAD |
47 #ifndef QT_NO_THREAD |
47 |
48 |
98 return maxlen; |
99 return maxlen; |
99 } |
100 } |
100 |
101 |
101 void QWindowsPipeWriter::run() |
102 void QWindowsPipeWriter::run() |
102 { |
103 { |
103 OVERLAPPED overl = {0, 0, 0, 0, NULL}; |
104 OVERLAPPED overl; |
|
105 memset(&overl, 0, sizeof overl); |
104 overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
106 overl.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); |
105 forever { |
107 forever { |
106 lock.lock(); |
108 lock.lock(); |
107 while(data.isEmpty() && (!quitNow)) { |
109 while(data.isEmpty() && (!quitNow)) { |
108 waitCondition.wakeOne(); |
110 waitCondition.wakeOne(); |
124 qint64 totalWritten = 0; |
126 qint64 totalWritten = 0; |
125 overl.Offset = 0; |
127 overl.Offset = 0; |
126 overl.OffsetHigh = 0; |
128 overl.OffsetHigh = 0; |
127 while ((!quitNow) && totalWritten < maxlen) { |
129 while ((!quitNow) && totalWritten < maxlen) { |
128 DWORD written = 0; |
130 DWORD written = 0; |
129 // Write 2k at a time to prevent flooding the pipe. If you |
|
130 // write too much (4k-8k), the pipe can close |
|
131 // unexpectedly. |
|
132 if (!WriteFile(writePipe, ptrData + totalWritten, |
131 if (!WriteFile(writePipe, ptrData + totalWritten, |
133 qMin<int>(2048, maxlen - totalWritten), &written, &overl)) { |
132 maxlen - totalWritten, &written, &overl)) { |
|
133 |
134 if (GetLastError() == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) { |
134 if (GetLastError() == 0xE8/*NT_STATUS_INVALID_USER_BUFFER*/) { |
135 // give the os a rest |
135 // give the os a rest |
136 msleep(100); |
136 msleep(100); |
137 continue; |
137 continue; |
138 } |
138 } |