summaryrefslogtreecommitdiff
path: root/ext/librethinkdbxx/src/connection.cc
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-11-03 22:40:26 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-11-03 22:40:26 -0400
commit7fc9094d8ea1c2d28d003c499016f0755b73063d (patch)
tree9f5b5fd51aad00bc964e06e188486d026b0e27e3 /ext/librethinkdbxx/src/connection.cc
parent92c7070aa85425041f856d7e4203bdd1ae713c33 (diff)
downloadinfinitytier-7fc9094d8ea1c2d28d003c499016f0755b73063d.tar.gz
infinitytier-7fc9094d8ea1c2d28d003c499016f0755b73063d.zip
More fixes to RethinkDB.
Diffstat (limited to 'ext/librethinkdbxx/src/connection.cc')
-rw-r--r--ext/librethinkdbxx/src/connection.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/librethinkdbxx/src/connection.cc b/ext/librethinkdbxx/src/connection.cc
index 62f6efee..53d106ec 100644
--- a/ext/librethinkdbxx/src/connection.cc
+++ b/ext/librethinkdbxx/src/connection.cc
@@ -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) {