mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 13:54:15 -07:00
More fixes to RethinkDB.
This commit is contained in:
parent
92c7070aa8
commit
7fc9094d8e
4 changed files with 93 additions and 76 deletions
|
@ -101,6 +101,8 @@ std::unique_ptr<Connection> connect(std::string host, int port, std::string auth
|
|||
Connection::Connection(ConnectionPrivate *dd) : d(dd) { }
|
||||
Connection::~Connection() {
|
||||
// close();
|
||||
if (d->guarded_sockfd >= 0)
|
||||
::close(d->guarded_sockfd);
|
||||
}
|
||||
|
||||
size_t ReadLock::recv_some(char* buf, size_t size, double wait) {
|
||||
|
@ -128,7 +130,7 @@ size_t ReadLock::recv_some(char* buf, size_t size, double wait) {
|
|||
}
|
||||
|
||||
ssize_t numbytes = ::recv(conn->guarded_sockfd, buf, size, 0);
|
||||
if (numbytes == -1) throw Error::from_errno("recv");
|
||||
if (numbytes <= 0) throw Error::from_errno("recv");
|
||||
if (debug_net > 1) {
|
||||
fprintf(stderr, "<< %s\n", write_datum(std::string(buf, numbytes)).c_str());
|
||||
}
|
||||
|
@ -190,6 +192,7 @@ void Connection::close() {
|
|||
if (ret == -1) {
|
||||
throw Error::from_errno("close");
|
||||
}
|
||||
d->guarded_sockfd = -1;
|
||||
}
|
||||
|
||||
Response ConnectionPrivate::wait_for_response(uint64_t token_want, double wait) {
|
||||
|
|
|
@ -21,9 +21,11 @@ CursorPrivate::CursorPrivate(uint64_t token_, Connection *conn_, Datum&& datum)
|
|||
Cursor::Cursor(CursorPrivate *dd) : d(dd) {}
|
||||
|
||||
Cursor::~Cursor() {
|
||||
if (d && d->conn) {
|
||||
close();
|
||||
}
|
||||
try {
|
||||
if (d && d->conn) {
|
||||
close();
|
||||
}
|
||||
} catch ( ... ) {}
|
||||
}
|
||||
|
||||
Datum& Cursor::next(double wait) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue