summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorEmmanuel Vasilakis <mrzammler@mm.st>2023-02-28 17:34:34 +0200
committerGitHub <noreply@github.com>2023-02-28 17:34:34 +0200
commitdd3b914ed5dfb12fa816c7ae086c57b7702f2821 (patch)
tree6be48f24cf0a4ae7ea827f170c5bc0ed11754897 /web
parent76ca052b9d2fb5324946b9d229059892e8e9debd (diff)
Misc SSL improvements 3 (#14602)
* go to normal only if its in stream mode * use ssl specific flags for wait receive and send * remove brackets
Diffstat (limited to 'web')
-rw-r--r--web/server/static/static-threaded.c7
-rw-r--r--web/server/web_client.c14
-rw-r--r--web/server/web_client.h11
3 files changed, 20 insertions, 12 deletions
diff --git a/web/server/static/static-threaded.c b/web/server/static/static-threaded.c
index 7076648c92..d0d55ebc30 100644
--- a/web/server/static/static-threaded.c
+++ b/web/server/static/static-threaded.c
@@ -293,9 +293,6 @@ static int web_server_rcv_callback(POLLINFO *pi, short int *events) {
struct web_client *w = (struct web_client *)pi->data;
int fd = pi->fd;
- web_client_disable_wait_receive(w);
- web_client_disable_wait_send(w);
-
ssize_t bytes;
bytes = web_client_receive(w);
@@ -354,10 +351,10 @@ static int web_server_rcv_callback(POLLINFO *pi, short int *events) {
ret = -1;
goto cleanup;
} else if (unlikely(bytes == 0)) {
- if(unlikely(w->ifd == fd && web_client_has_wait_receive(w)))
+ if(unlikely(w->ifd == fd && web_client_has_ssl_wait_receive(w)))
*events |= POLLIN;
- if(unlikely(w->ofd == fd && web_client_has_wait_send(w)))
+ if(unlikely(w->ofd == fd && web_client_has_ssl_wait_send(w)))
*events |= POLLOUT;
}
diff --git a/web/server/web_client.c b/web/server/web_client.c
index e31ecd7933..e0a2aca165 100644
--- a/web/server/web_client.c
+++ b/web/server/web_client.c
@@ -41,12 +41,12 @@ static inline int web_client_crock_socket(struct web_client *w) {
static inline void web_client_enable_wait_from_ssl(struct web_client *w, int bytes) {
int ssl_err = SSL_get_error(w->ssl.conn, bytes);
if (ssl_err == SSL_ERROR_WANT_READ)
- web_client_enable_wait_receive(w);
+ web_client_enable_ssl_wait_receive(w);
else if (ssl_err == SSL_ERROR_WANT_WRITE)
- web_client_enable_wait_send(w);
- else if (ssl_err) {
- web_client_disable_wait_receive(w);
- web_client_disable_wait_send(w);
+ web_client_enable_ssl_wait_send(w);
+ else {
+ web_client_disable_ssl_wait_receive(w);
+ web_client_disable_ssl_wait_send(w);
}
}
@@ -955,7 +955,6 @@ static inline HTTP_VALIDATION http_request_validate(struct web_client *w) {
return HTTP_VALIDATION_NOT_SUPPORTED;
}
}
-
web_client_enable_wait_receive(w);
return HTTP_VALIDATION_INCOMPLETE;
}
@@ -1528,7 +1527,8 @@ void web_client_process_request(struct web_client *w) {
// wait for more data
// set to normal to prevent web_server_rcv_callback
// from going into stream mode
- w->mode = WEB_CLIENT_MODE_NORMAL;
+ if (w->mode == WEB_CLIENT_MODE_STREAM)
+ w->mode = WEB_CLIENT_MODE_NORMAL;
return;
}
break;
diff --git a/web/server/web_client.h b/web/server/web_client.h
index 801f88d7b4..61c5221541 100644
--- a/web/server/web_client.h
+++ b/web/server/web_client.h
@@ -71,6 +71,9 @@ typedef enum web_client_flags {
WEB_CLIENT_FLAG_DONT_CLOSE_SOCKET = 1 << 9, // don't close the socket when cleaning up (static-threaded web server)
WEB_CLIENT_CHUNKED_TRANSFER = 1 << 10, // chunked transfer (used with zlib compression)
+
+ WEB_CLIENT_FLAG_SSL_WAIT_RECEIVE = 1 << 11, // if set, we are waiting more input data from an ssl conn
+ WEB_CLIENT_FLAG_SSL_WAIT_SEND = 1 << 12, // if set, we have data to send to the client from an ssl conn
} WEB_CLIENT_FLAGS;
#define web_client_flag_check(w, flag) ((w)->flags & (flag))
@@ -100,6 +103,14 @@ typedef enum web_client_flags {
#define web_client_enable_wait_send(w) web_client_flag_set(w, WEB_CLIENT_FLAG_WAIT_SEND)
#define web_client_disable_wait_send(w) web_client_flag_clear(w, WEB_CLIENT_FLAG_WAIT_SEND)
+#define web_client_has_ssl_wait_receive(w) web_client_flag_check(w, WEB_CLIENT_FLAG_SSL_WAIT_RECEIVE)
+#define web_client_enable_ssl_wait_receive(w) web_client_flag_set(w, WEB_CLIENT_FLAG_SSL_WAIT_RECEIVE)
+#define web_client_disable_ssl_wait_receive(w) web_client_flag_clear(w, WEB_CLIENT_FLAG_SSL_WAIT_RECEIVE)
+
+#define web_client_has_ssl_wait_send(w) web_client_flag_check(w, WEB_CLIENT_FLAG_SSL_WAIT_SEND)
+#define web_client_enable_ssl_wait_send(w) web_client_flag_set(w, WEB_CLIENT_FLAG_SSL_WAIT_SEND)
+#define web_client_disable_ssl_wait_send(w) web_client_flag_clear(w, WEB_CLIENT_FLAG_SSL_WAIT_SEND)
+
#define web_client_set_tcp(w) web_client_flag_set(w, WEB_CLIENT_FLAG_TCP_CLIENT)
#define web_client_set_unix(w) web_client_flag_set(w, WEB_CLIENT_FLAG_UNIX_CLIENT)
#define web_client_check_unix(w) web_client_flag_check(w, WEB_CLIENT_FLAG_UNIX_CLIENT)