Commit 0d9fe39d authored by Sergey Lyubka's avatar Sergey Lyubka

ns_read_from_socket(): calling recv() in a loop until failure

parent 708af6d9
...@@ -756,6 +756,7 @@ static void ns_read_from_socket(struct ns_connection *conn) { ...@@ -756,6 +756,7 @@ static void ns_read_from_socket(struct ns_connection *conn) {
// Therefore, read in a loop until we read everything. Without the loop, // Therefore, read in a loop until we read everything. Without the loop,
// we skip to the next select() cycle which can just timeout. // we skip to the next select() cycle which can just timeout.
while ((n = SSL_read(conn->ssl, buf, sizeof(buf))) > 0) { while ((n = SSL_read(conn->ssl, buf, sizeof(buf))) > 0) {
DBG(("%p %d <- %d bytes (SSL)", conn, conn->flags, n));
iobuf_append(&conn->recv_iobuf, buf, n); iobuf_append(&conn->recv_iobuf, buf, n);
ns_call(conn, NS_RECV, &n); ns_call(conn, NS_RECV, &n);
} }
...@@ -778,16 +779,15 @@ static void ns_read_from_socket(struct ns_connection *conn) { ...@@ -778,16 +779,15 @@ static void ns_read_from_socket(struct ns_connection *conn) {
} else } else
#endif #endif
{ {
n = recv(conn->sock, buf, sizeof(buf), 0); while ((n = recv(conn->sock, buf, sizeof(buf), 0)) > 0) {
DBG(("%p %d <- %d bytes (PLAIN)", conn, conn->flags, n));
iobuf_append(&conn->recv_iobuf, buf, n);
ns_call(conn, NS_RECV, &n);
}
} }
DBG(("%p %d <- %d bytes", conn, conn->flags, n));
if (ns_is_error(n)) { if (ns_is_error(n)) {
conn->flags |= NSF_CLOSE_IMMEDIATELY; conn->flags |= NSF_CLOSE_IMMEDIATELY;
} else if (n > 0) {
iobuf_append(&conn->recv_iobuf, buf, n);
ns_call(conn, NS_RECV, &n);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment