summaryrefslogtreecommitdiff
path: root/proxy_network.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-11-24 18:28:18 -0800
committerdormando <dormando@rydia.net>2022-11-24 18:28:18 -0800
commit46487041a498dcea664469fe74e4f44235212461 (patch)
treedf29076135a2240702ccf9195186b65281506457 /proxy_network.c
parentb10511e5bf694e9ec0bc60e82edf8f67d74891f2 (diff)
downloadmemcached-46487041a498dcea664469fe74e4f44235212461.tar.gz
proxy: fix bugs in be validation step
Two bugs in the backend validation stage: 1) If requests are coming in while validation is happening, the event handler will be reset to the main handler, which would get a VERSION response and blow up on a parsing error. 2) If the validate request results in an EAGAIN it would automatically pass validation, which would lead to the same bug as above.
Diffstat (limited to 'proxy_network.c')
-rw-r--r--proxy_network.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/proxy_network.c b/proxy_network.c
index 26a0dbf..074b172 100644
--- a/proxy_network.c
+++ b/proxy_network.c
@@ -528,7 +528,7 @@ static void proxy_event_handler(evutil_socket_t fd, short which, void *arg) {
if (flags == -1) {
_reset_bad_backend(be, P_BE_FAIL_WRITING);
_backend_failed(be);
- } else {
+ } else if (!be->validating) {
flags = be->can_write ? EV_READ|EV_TIMEOUT : EV_READ|EV_WRITE|EV_TIMEOUT;
_set_event(be, t->base, flags, tmp_time, proxy_backend_handler);
}
@@ -1124,6 +1124,7 @@ static void proxy_beconn_handler(const int fd, const short which, void *arg) {
return;
}
_set_event(be, be->event_thread->base, EV_READ, tmp_time, proxy_beconn_handler);
+ return;
}
// Passed validation, don't need to re-read, flush any pending writes.