Report the actual error when read() or write() a network device failed.

This enable to actually detect and handle device removal (USB...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37897 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin
2010-08-04 11:11:56 +00:00
parent 2b4154458a
commit cc8eceb0af
2 changed files with 4 additions and 2 deletions
@@ -278,7 +278,7 @@ ethernet_send_data(net_device *_device, net_buffer *buffer)
device->stats.send.errors++;
if (allocated)
gBufferModule->free(allocated);
return bytesWritten;
return errno;
}
device->stats.send.packets++;
@@ -323,7 +323,7 @@ ethernet_receive_data(net_device *_device, net_buffer **_buffer)
bytesRead = read(device->fd, data, device->frame_size);
if (bytesRead < 0) {
device->stats.receive.errors++;
status = bytesRead;
status = errno;
goto err;
}
//dump_block((const char *)data, bytesRead, "rcv: ");
@@ -66,6 +66,8 @@ device_reader_thread(void* _interface)
}
fifo_enqueue_buffer(&interface->receive_queue, buffer);
} else if (status == B_DEVICE_NOT_FOUND) {
device_removed(device);
} else {
// In case of error, give the other threads some
// time to run since this is a high priority time thread.