MCPcopy Create free account
hub / github.com/apache/trafficserver / readFromFD

Method readFromFD

src/tscore/TextBuffer.cc:204–231  ·  view source on GitHub ↗

int TextBuffer::readFromFD(int fd) Issues a single read command on the file descriptor passed in. Attempts to read a minimum of 512 bytes from file descriptor passed.

Source from the content-addressed store, hash-verified

202// descriptor passed in. Attempts to read a minimum of
203// 512 bytes from file descriptor passed.
204int
205TextBuffer::readFromFD(int fd)
206{
207 int readSize;
208
209 // Check to see if we have got a reasonable amount of space left in our
210 // buffer, if not try to get some more
211 if (spaceLeft < 512) {
212 if (enlargeBuffer(512) == -1) {
213 return -1;
214 }
215 }
216
217 readSize = read(fd, nextAdd, spaceLeft - 1);
218
219 if (readSize == 0) {
220 // Socket is empty so we are done
221 return 0;
222 } else if (readSize < 0) {
223 // Error on read
224 return readSize;
225 } else {
226 nextAdd = nextAdd + readSize;
227 nextAdd[0] = '\0';
228 spaceLeft -= readSize + 1;
229 return readSize;
230 }
231}
232
233void
234TextBuffer::vformat(const char *fmt, va_list ap)

Callers 1

ServerBacktraceFunction · 0.80

Calls 1

readFunction · 0.50

Tested by

no test coverage detected