Check the return value of I/O operations for failure

This commit is contained in:
Nathan Binkert
2008-09-19 09:11:42 -07:00
parent f066db7fcd
commit ea83cedcf6
3 changed files with 13 additions and 5 deletions

View File

@@ -182,8 +182,12 @@ EtherTap::recvPacket(EthPacketPtr packet)
DPRINTF(Ethernet, "EtherTap output len=%d\n", packet->length);
DDUMP(EthernetData, packet->data, packet->length);
uint32_t len = htonl(packet->length);
write(socket, &len, sizeof(len));
write(socket, packet->data, packet->length);
ssize_t ret = write(socket, &len, sizeof(len));
if (ret != sizeof(len))
return false;
ret = write(socket, packet->data, packet->length);
if (ret != packet->length)
return false;
interface->recvDone();