Skip to content

Commit

Permalink
Fixed: Wrong number of bytes read
Browse files Browse the repository at this point in the history
  • Loading branch information
sshamov committed Jan 24, 2015
1 parent 2007dce commit 2815be7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions source/mysql/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ package class MySQLSocketPhobos : MySQLSocket
// querying the socket's opened/closed state directly.
scope(failure) socket.close();

auto bytesRead = socket.receive(dst);
enforceEx!MYX(bytesRead == dst.length, "Wrong number of bytes read");
enforceEx!MYX(bytesRead != socket.ERROR, "Received std.socket.Socket.ERROR");
for (size_t off, len; off < dst.length; off += len) {
len = socket.receive(dst[off..$]);
enforceEx!MYX(len != 0, "Server closed the connection");
enforceEx!MYX(len != socket.ERROR, "Received std.socket.Socket.ERROR");
}
}

void write(in ubyte[] bytes)
Expand Down

0 comments on commit 2815be7

Please sign in to comment.