Browse Source

AP_HAL: fixed socket destructor

master
Andrew Tridgell 10 years ago
parent
commit
5067359ed7
  1. 5
      libraries/AP_HAL/utility/Socket.cpp
  2. 2
      libraries/AP_HAL/utility/Socket.h

5
libraries/AP_HAL/utility/Socket.cpp

@ -35,8 +35,9 @@ datagram(_datagram) @@ -35,8 +35,9 @@ datagram(_datagram)
SocketAPM::~SocketAPM()
{
if (::close(fd) < 0) {
perror("close");
if (fd != -1) {
::close(fd);
fd = -1;
}
}

2
libraries/AP_HAL/utility/Socket.h

@ -47,7 +47,7 @@ public: @@ -47,7 +47,7 @@ public:
private:
bool datagram;
int fd;
int fd = -1;
void make_sockaddr(const char *address, uint16_t port, struct sockaddr_in &sockaddr);
};

Loading…
Cancel
Save