-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTERNAL: Refactor a memcached_fetch function #337
base: develop
Are you sure you want to change the base?
Conversation
b7882cb
to
b1080f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฆฌ๋ทฐ ์๋ฃ
libmemcached/fetch.cc
Outdated
|
||
if (flags) | ||
*flags= 0; | ||
*error= (result_buffer == NULL) ? *error : MEMCACHED_KEY_TOO_BIG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋์ ๊ฐ์ด ํฉ์๋ค.
if (result_buffer != NULL) *error= MEMCACHED_KEY_TOO_BIG;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ๋์์ต๋๋ค.
result_buffer= memcached_fetch_result(ptr, result_buffer, error); | ||
if (result_buffer == NULL or memcached_failed(*error)) | ||
if (result_buffer == NULL || result_buffer->key_length > MEMCACHED_MAX_KEY) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result_buffer != NULL์ด์ง๋ง, *error ๊ฐ์ด failture์ธ ๊ฒฝ์ฐ๋ ์๋ค๋ ๊ฒ์ด์ฃ ?
memcached_fetch_result() ํจ์์์
result_buffer != NULL์ด๋ฉด์ result_buffer->key_length > MEMCACHED_MAX_KEY ๊ฒฝ์ฐ
MEMCACHED_KEY_TOO_BIG ์๋ฌ ์ค์ ํ์ฌ ๋ฆฌํดํ๋ ค๋ ์๋๊ฐ ์์๋ ๊ฒ์ด ์๋์ง ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋๊น์ง๋ ๋ชจ๋ฅด๊ฒ ์ผ๋ memcached_fetch_result์์ MEMCACHED_MAX_KEY๋ฅผ ๋ฐํํ๋ ํํ๊ฐ ๋ ์์ฐ์ค๋ฌ์ด ๊ฒ ๊ฐ์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ing-eoking
๋
ผ๋ฆฌ์ ์ผ๋ก ๋ด์,
result_buffer->key_length > MEMCACHED_MAX_KEY ์ธ ๊ฒฝ์ฐ ์ค๋ฅ๋ฅผ ๋ฆฌํดํ ํ์๋ ์์ด ๋ณด์
๋๋ค.
ํนํ๋, memcached_fetch()์์๋ key์ ๋ํด ๊ด์ฌ์ด ์๊ณ ๋จ์ง value๋ง ์กฐํํ๋ ๊ฒฝ์ฐ์
๋๋ค.
์ด๋ฌํ ์กฐ๊ฑด ๊ฒ์ฌ๊ฐ ๋ค์ด๊ฐ ์ด์ ๋ฅผ ๊ฐ๋จํ ํ์ธํด ๋ณผ ์ ์์๊น์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libmemcached ์ปค๋ฐ ๋ฉ์์ง๋ฅผ ํ์ธํ ๊ฒฐ๊ณผ, ๋ฐ๋ก ์ด์ ๋ฅผ ์ ์ด ๋์ง๋ ์์์ต๋๋ค.
awesomized/libmemcached#7e592f0
We now check return key size for memcached_fetch() to make sure it is not
too big (compared to original ascii server). result_st is now initialized
differently. This should make it a bit faster.
ํ์ง๋ง result_buffer->key_length > MEMCACHED_MAX_KEY
๋น๊ต๋ฅผ memcached_fetch
๋ memcached_fetch_result
์์ ํ๋ ๊ฒ์ ๋ค์ ๋ถ์์ฐ์ค๋ฌ์ ๋ณด์
๋๋ค.
result_buffer ๊ตฌ์กฐ์ฒด ๋ด์ item_key ๋ณ์๊ฐ ์ด๋ฏธ MEMCACHED_MAX_KEY ํฌ๊ธฐ๋ก ๊ณ ์ ๋์ด ์์ต๋๋ค.
ํค๋ฅผ ์ ์ฅํ ๋ ์ค๋ฒํ๋ก์ฐ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ ์ด๋ฅผ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ด ๋ ์ ํฉํ์ง ์์๊น ์๊ฐ๋ฉ๋๋ค.
struct memcached_result_st {
...
size_t key_length;
...
char item_key[MEMCACHED_MAX_KEY];
...
};
913a854
to
c8c28b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฆฌ๋ทฐ ์๋ฃ
libmemcached/fetch.cc
Outdated
else if (result->key_length > MEMCACHED_MAX_KEY) | ||
{ | ||
*error= MEMCACHED_KEY_TOO_BIG; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result๊ฐ ์กด์ฌํ ๊ฒฝ์ฐ๋ ์์์ ์ด๋ฏธ return ํ๊ธฐ ๋๋ฌธ์, ์ด ์ฝ๋๊ฐ ์ํ๋ ์๊ฐ ์์ต๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memcached_fetch_result()
ํธ์ถํ๋ ๊ฒฝ์ฐ๋ memcached_fetch() ์ธ์ ๋ค๋ฅธ ๊ฒฝ์ฐ๋ ์์ต๋๋ค.
MEMCACHED_KEY_TOO_BIG ์ค๋ฅ๋ฅผ ๋ฆฌํดํ๊ฒ ๋ง๋ค๋ฉด, ๋ค๋ฅธ ํธ์ถ ๊ฒฝ์ฐ์๋ ๋ฌธ์ ๊ฐ ์๋ค๋ ๊ฒ์ ํ์ธํ ์ํ์ธ๊ฐ์?
ํ์ธํ๊ธฐ ์ด๋ ต๋ค๋ฉด, ํ์ฌ๋ก๋ ์ฒ์ PR ์ฒ๋ผ memcached_fetch()์์๋ง MEMCACHED_KEY_TOO_BIG ์ค๋ฅ๋ฅผ ์ค์ ํ๊ฒ ํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๋ฏ ํฉ๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฐ์ ์ด์ PR๋ก ๋ณต๊ตฌํ์ต๋๋ค.
MEMCACHED_KEY_TOO_BIG ์ค๋ฅ๋ฅผ ๋ฆฌํดํ๊ฒ ๋ง๋ค๋ฉด, ๋ค๋ฅธ ํธ์ถ ๊ฒฝ์ฐ์๋ ๋ฌธ์ ๊ฐ ์๋ค๋ ๊ฒ์ ํ์ธํ ์ํ์ธ๊ฐ์?
๋ฐ๋ก ํ์ธ์ ํ์ง ์์์ต๋๋ค. ๋ค๋ง, memcached_fetch_result()
๊ฐ ๊ณต๊ฐ๋ API๋ผ ๋ด๋ถ์์ ์ด๋ป๊ฒ ์ฌ์ฉ๋๋์ง ํ์ธํ๋ค๊ณ ํด์ ๋ฌธ์ ๊ฐ ์๋ค๊ณ ๋จ์ ํ ์๋ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
๐ Related Issue
โจ๏ธ What I did
if (result_buffer == NULL || memcached_failed(*error))
์กฐ๊ฑด๋ฌธ์์memcached_failed
๋ฅผ ์ ๊ฑฐํ์ต๋๋ค.