Probably going to merge accept and network threads
This commit is contained in:
@@ -47,19 +47,25 @@ void Connection::appendMessage(std::string_view s, bool copyToArena) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view Connection::readBytes(char *buf, size_t buffer_size) {
|
||||
int r = read(fd_, buf, buffer_size);
|
||||
if (r == -1) {
|
||||
if (errno == EINTR || errno == EAGAIN) {
|
||||
return {}; // Empty string_view indicates no data or would block
|
||||
int Connection::readBytes(char *buf, size_t buffer_size) {
|
||||
int r;
|
||||
for (;;) {
|
||||
r = read(fd_, buf, buffer_size);
|
||||
if (r == -1) {
|
||||
if (errno == EINTR) {
|
||||
continue;
|
||||
}
|
||||
if (errno == EAGAIN) {
|
||||
return 0;
|
||||
}
|
||||
perror("read");
|
||||
return -1;
|
||||
}
|
||||
perror("read");
|
||||
return {}; // Error - let server handle connection cleanup
|
||||
if (r == 0) {
|
||||
return -1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
if (r == 0) {
|
||||
return {}; // EOF - let server handle connection cleanup
|
||||
}
|
||||
return {buf, size_t(r)};
|
||||
}
|
||||
|
||||
bool Connection::writeBytes() {
|
||||
|
||||
Reference in New Issue
Block a user