There is a possibility that errno may be changed during write log
Modified to save the errno value
Change-Id: I210bc4678e83ee00bb1c1b788f5c99c23f745b6a
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
while (left) {
ssize_t recv_byte = recv(fd_, buffer, left, 0);
if (recv_byte == 0) {
+ int err = errno;
LOG(WARNING) << "Socket was disconnected. fd: " << fd_
- << ", errno: " << errno;
- return -errno;
+ << ", errno: " << err;
+ return -err;
} else if (recv_byte < 0) {
if (errno == EINTR) {
LOG(WARNING) << "Interrupt occuered, try to receive data continue";
continue;
} else if (errno == EAGAIN) {
if (is_blocking) {
- LOG(ERROR) << "Timed out. fd: " << fd_ << ", errno: " << errno;
- return -errno;
+ LOG(ERROR) << "Timed out. fd: " << fd_ << ", errno: " << EAGAIN;
+ return -EAGAIN;
}
if (retry_count > 0) {