Commit 400084ea authored by Sergey Lyubka's avatar Sergey Lyubka

read_from_client -> read_from_socket

parent 82ad9a07
...@@ -1923,7 +1923,7 @@ static void call_uri_handler(struct connection *conn) { ...@@ -1923,7 +1923,7 @@ static void call_uri_handler(struct connection *conn) {
} }
} }
static void write_to_client(struct connection *conn) { static void write_to_socket(struct connection *conn) {
struct iobuf *io = &conn->remote_iobuf; struct iobuf *io = &conn->remote_iobuf;
int n = conn->ssl == NULL ? send(conn->client_sock, io->buf, io->len, 0) : int n = conn->ssl == NULL ? send(conn->client_sock, io->buf, io->len, 0) :
#ifdef USE_SSL #ifdef USE_SSL
...@@ -3475,9 +3475,21 @@ static void process_request(struct connection *conn) { ...@@ -3475,9 +3475,21 @@ static void process_request(struct connection *conn) {
#endif #endif
} }
static void read_from_client(struct connection *conn) { static void read_from_socket(struct connection *conn) {
char buf[IOBUF_SIZE]; char buf[IOBUF_SIZE];
int n = 0; int ok, n = 0;
socklen_t len = sizeof(ok);
if (conn->endpoint_type == EP_CLIENT) {
conn->mg_conn.wsbits = 1;
if (!(conn->flags & CONN_CONNECTED) &&
getsockopt(conn->client_sock, SOL_SOCKET, SO_ERROR,
(char *) &ok, &len) < 0) {
conn->mg_conn.wsbits = 0;
}
conn->handler(&conn->mg_conn);
conn->flags |= CONN_CLOSE | CONN_CONNECTED;
} else {
if (conn->ssl != NULL) { if (conn->ssl != NULL) {
#ifdef USE_SSL #ifdef USE_SSL
if (conn->flags & CONN_SSL_HANDS_SHAKEN) { if (conn->flags & CONN_SSL_HANDS_SHAKEN) {
...@@ -3500,6 +3512,7 @@ static void read_from_client(struct connection *conn) { ...@@ -3500,6 +3512,7 @@ static void read_from_client(struct connection *conn) {
spool(&conn->local_iobuf, buf, n); spool(&conn->local_iobuf, buf, n);
process_request(conn); process_request(conn);
} }
}
} }
int mg_connect(struct mg_server *server, const char *host, int mg_connect(struct mg_server *server, const char *host,
...@@ -3541,19 +3554,6 @@ int mg_connect(struct mg_server *server, const char *host, ...@@ -3541,19 +3554,6 @@ int mg_connect(struct mg_server *server, const char *host,
return 1; return 1;
} }
static void read_from_server(struct connection *conn) {
sock_t ok, sock = conn->client_sock;
socklen_t len = sizeof(ok);
conn->mg_conn.wsbits = 1;
if (!(conn->flags & CONN_CONNECTED) &&
getsockopt(sock, SOL_SOCKET, SO_ERROR, (char *) &ok, &len) < 0) {
conn->mg_conn.wsbits = 0;
}
conn->handler(&conn->mg_conn);
conn->flags |= CONN_CLOSE | CONN_CONNECTED;
}
#ifndef NO_LOGGING #ifndef NO_LOGGING
static void log_header(const struct mg_connection *conn, const char *header, static void log_header(const struct mg_connection *conn, const char *header,
FILE *fp) { FILE *fp) {
...@@ -3722,11 +3722,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) { ...@@ -3722,11 +3722,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) {
conn = LINKED_LIST_ENTRY(lp, struct connection, link); conn = LINKED_LIST_ENTRY(lp, struct connection, link);
if (FD_ISSET(conn->client_sock, &read_set)) { if (FD_ISSET(conn->client_sock, &read_set)) {
conn->last_activity_time = current_time; conn->last_activity_time = current_time;
if (conn->endpoint_type == EP_CLIENT) { read_from_socket(conn);
read_from_server(conn);
} else {
read_from_client(conn);
}
} }
#ifndef NO_CGI #ifndef NO_CGI
if (conn->endpoint_type == EP_CGI && if (conn->endpoint_type == EP_CGI &&
...@@ -3737,7 +3733,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) { ...@@ -3737,7 +3733,7 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) {
if (FD_ISSET(conn->client_sock, &write_set) && if (FD_ISSET(conn->client_sock, &write_set) &&
!(conn->flags & CONN_BUFFER)) { !(conn->flags & CONN_BUFFER)) {
conn->last_activity_time = current_time; conn->last_activity_time = current_time;
write_to_client(conn); write_to_socket(conn);
} }
} }
} }
......
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