Skip to content
This repository

Twemcache starts spinning with 100% CPU because of bad UDP packages #21

Merged
merged 1 commit into from about 1 year ago

2 participants

dknecht Yao Yue
dknecht

Patch from Upstream Memcached - memcached/memcached@954f6dd

"Don't permanently close UDP listeners on error
Also, don't inflate rbytes as we can only ever process one UDP packet at a
time.

Patch by pi3orama. Fixed by Dormando to use the correct state and actually
work."

Applying patch so that UDP requests cannot cause the server to spin o…
…ut of control

Patch from Upstream Memcached - memcached/memcached@954f6dd

Don't permanently close UDP listeners on error
Also, don't inflate rbytes as we can only ever process one UDP packet at a
time.

Patch by pi3orama. Fixed by Dormando to use the correct state and actually
work.

I'm not fully convinced of the rbytes bit. We must ensure that a UDP packet
with multiple commands in it has all of its commands processed before we can
possibly call recvfrom again.
40fcc8a
Yao Yue thinkingfish merged commit 1d0d8a5 into from
Yao Yue thinkingfish closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 2 authors.

Jan 04, 2013
Applying patch so that UDP requests cannot cause the server to spin o…
…ut of control

Patch from Upstream Memcached - memcached/memcached@954f6dd

Don't permanently close UDP listeners on error
Also, don't inflate rbytes as we can only ever process one UDP packet at a
time.

Patch by pi3orama. Fixed by Dormando to use the correct state and actually
work.

I'm not fully convinced of the rbytes bit. We must ensure that a UDP packet
with multiple commands in it has all of its commands processed before we can
possibly call recvfrom again.
40fcc8a
This page is out of date. Refresh to see the latest.
4  src/mc_connection.c
@@ -312,6 +312,10 @@ conn_cleanup(struct conn *c)
312 312
     if (c->write_and_free != NULL) {
313 313
         mc_free(c->write_and_free);
314 314
     }
  315
+
  316
+    if (c->udp) {
  317
+        conn_set_state(c, CONN_READ);
  318
+    }
315 319
 }
316 320
 
317 321
 void
2  src/mc_core.c
@@ -147,7 +147,7 @@ core_read_udp(struct conn *c)
147 147
         res -= 8;
148 148
         memmove(c->rbuf, c->rbuf + 8, res);
149 149
 
150  
-        c->rbytes += res;
  150
+        c->rbytes = res;
151 151
         c->rcurr = c->rbuf;
152 152
 
153 153
         return READ_DATA_RECEIVED;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.