Skip to content
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

CLEANUP: Move event callback functions to mc_util files #713

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

ing-eoking
Copy link
Collaborator

@ing-eoking ing-eoking commented Nov 10, 2023

기존 내용은 노션 및 이슈에 정리되었으므로 지웠습니다.

event callbacks 함수를 mc_util 파일로 이동시킵니다.

@ing-eoking ing-eoking marked this pull request as draft November 10, 2023 01:40
@ing-eoking ing-eoking force-pushed the develop-util branch 2 times, most recently from 97f89c3 to b0c9f49 Compare November 10, 2023 02:37
@ing-eoking ing-eoking marked this pull request as ready for review November 10, 2023 03:24
@ing-eoking

This comment was marked as off-topic.

namsic

This comment was marked as outdated.

@namsic namsic marked this pull request as draft November 30, 2023 00:57
@ing-eoking ing-eoking changed the title CLEANUP: Move utilization functions to mc_util CLEANUP: Move event callback functions to mc_util files Mar 4, 2024
@ing-eoking ing-eoking requested a review from namsic March 4, 2024 03:04
@ing-eoking ing-eoking marked this pull request as ready for review March 4, 2024 03:04
@jhpark816
Copy link
Collaborator

@namsic 리뷰 진행합시다.

Copy link
Collaborator

@namsic namsic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhpark816
언뜻 보기에 callback function의 구현은 engine과 직접 관련이 없어 보이는데,
engine_xxx 형태의 변수 네이밍이나 ENGINE_HANDLE 타입을 인자로 받는 등의 이유가 있을까요?

mc_util.h Outdated
@@ -17,6 +17,7 @@
#ifndef MC_UTIL_H
#define MC_UTIL_H

#include <memcached/engine.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engine.h가 아니라 callback.h만 include해도 충분할 것으로 생각합니다.

Copy link
Collaborator Author

@ing-eoking ing-eoking Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 내용 수정되었습니다.

별개로 다른 모듈에서의 헤더 계층 구조도 이상하다고 생각됩니다.
engine.h에서는 extension.h를 include하고 있기에 따로 include할 이유가 없습니다.

#include <memcached/extension.h>
#include <memcached/engine.h>

위와 같이 모듈을 include하고 있는 모듈은 아래와 같습니다.

  • extension_logger
  • memcached
  • syslog_logger
  • item_base
  • mock_server(test용)

@jhpark816 @namsic

이는 해당 모듈이 extension과 engine API를 활용한다는 것을 알려주는 목적인가요?
개인적으로 저는 extension에 있는 token_t가 왜 있는지도 모르겠습니다.
util이나 types 모듈에 넣는게 낫지 않을까? 생각됩니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ing-eoking
구현 의도는 모릅니다.
여튼, 본 이슈 후에 아래 2가지 사항을 이슈로 등록하여 처리하시죠.

  • include 관계 정리
  • extension.h 파일 정리

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네. 정리하여 올리겠습니다.

mc_util.c Outdated
Comment on lines 630 to 635
/* event handlers structure */
static struct engine_event_handler {
EVENT_CALLBACK cb;
const void *cb_data;
struct engine_event_handler *next;
} *engine_event_handlers[MAX_ENGINE_EVENT_TYPE + 1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개인적으로 기존처럼 구조체 정의와 배열 선언이 분리되어 있는 편이 더 읽기 좋다고 생각합니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engine_event_handlers 배열이 초기화되는 것이 보장되나요?

Copy link
Collaborator Author

@ing-eoking ing-eoking Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namsic
구조체 내부 길이가 길지 않아 변수 선언과 구조체 내부가 함께 있으면,
내부 정보를 같이 볼 수 있어 코드에 대한 빠른 파악이 될 수 있다고 생각했습니다.
분리되어 있는 편이 읽기가 편하시다면 변경하겠습니다.

추가 의견으로 저는 별개로 분리 시 eigne_event_handler 구조체를 memcached.h와 같이
mc_util.h에 위치시켜 외부로 드러낼 필요는 없다고 생각됩니다.

@jhpark816
해당 구조체 변수는 global 변수이므로 OS에서 무조건 0으로 초기화가 보장됩니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eigne_event_handler 구조체를 헤더 파일에 두지 맙시다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namsic
의견 부탁드립니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ing-eoking
eigne_event_handler 구조체를 여기에 두더라도,
구조체 정의와 배열 선언을 분리하자는 의견입니다.

Copy link
Collaborator Author

@ing-eoking ing-eoking Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhpark816
구조체 정의와 배열 선언을 분리할 경우
구조체 정의를 소스의 맨 위로 두거나
아래와 같이 구현되어야 합니다.

/* event handlers structure */
struct engine_event_handler {
    EVENT_CALLBACK cb;
    const void *cb_data;
    struct engine_event_handler *next;
};
static struct engine_event_handler *engine_event_handlers[MAX_ENGINE_EVENT_TYPE + 1];

예제의 형태는 크게 차이가 없다고 생각되어서
구조체 정의를 소스의 맨 위로 위치시키는게 읽기 편하신 형태인건지 궁금하여 요청드렸습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위의 예와 같이 구현합시다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정되었습니다.

t/topkeys.t Outdated
@@ -6,6 +6,8 @@ use FindBin qw($Bin);
use lib "$Bin/lib";
use MemcachedTest;

delete $ENV{"MEMCACHED_TOP_KEYS"};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에 들어갈 사항이 아닙니다.

Copy link
Collaborator Author

@ing-eoking ing-eoking Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정되었습니다.
테스트 수정은 크지 않아 branch를 변경안하고 push하다보니 잘못 들어갔습니다.

@ing-eoking ing-eoking force-pushed the develop-util branch 2 times, most recently from db87318 to 105f0b7 Compare March 5, 2024 02:44
@jhpark816
Copy link
Collaborator

@namsic 리뷰 바랍니다.

@jhpark816 jhpark816 merged commit e4dc39e into naver:develop Mar 5, 2024
1 check passed
@ing-eoking ing-eoking deleted the develop-util branch March 5, 2024 03:26
@ing-eoking
Copy link
Collaborator Author

ing-eoking commented Mar 5, 2024

commit 이력이 이상하여 수정 중이었습니다만..;
처리가 된 것 같습니다.

메일이 왔었네요. 늦게 확인했습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants