-
Notifications
You must be signed in to change notification settings - Fork 2
Fork support #4
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
base: master
Are you sure you want to change the base?
Fork support #4
Changes from all commits
0d574d9
a4b7e08
3b1837f
6f16397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,6 +175,48 @@ void __attribute__ ((destructor)) msk_internals_fini(void) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Reset global state. | ||
| * Should (only) be called to reset global data in child process after a fork. | ||
| */ | ||
| void msk_lib_reset(void) | ||
| { | ||
| /* Close epoll fd's */ | ||
| if (msk_global_state->cm_epollfd != 0) | ||
| close(msk_global_state->cm_epollfd); | ||
|
|
||
| if (msk_global_state->cq_epollfd != 0) | ||
| close(msk_global_state->cq_epollfd); | ||
|
|
||
| if (msk_global_state->stats_epollfd != 0) | ||
| close(msk_global_state->stats_epollfd); | ||
|
|
||
| /* Free worker pool resources */ | ||
| if (msk_global_state->worker_pool.w_efd != 0) | ||
| close(msk_global_state->worker_pool.w_efd); | ||
|
|
||
| if (msk_global_state->worker_pool.m_efd != 0) | ||
| close(msk_global_state->worker_pool.m_efd); | ||
|
|
||
| if (msk_global_state->worker_pool.thrids) | ||
| free(msk_global_state->worker_pool.thrids); | ||
|
|
||
| if (msk_global_state->worker_pool.wd_queue) | ||
| free(msk_global_state->worker_pool.wd_queue); | ||
|
|
||
| /* Brutal re-initialization of global state */ | ||
| memset(msk_global_state, 0, sizeof(*msk_global_state)); | ||
|
|
||
| msk_global_state->run_threads = 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should do that beforefreeing the various items/closing fd and try to join threads like in Actually we might be able to reuse these directly, it will free/realloc msk_global_state but the cost is negligible compared to thread joins etc so just something like |
||
| if (pthread_mutex_init(&msk_global_state->lock, NULL)) | ||
| ERROR_LOG("pthread_mutex_init failed?!"); | ||
|
|
||
| #ifdef HAVE_RDMA_LIB_RESET | ||
| /* Reset librdmacm (Mellanox MOFED interface) */ | ||
| rdma_lib_reset(); | ||
| #endif | ||
| } | ||
|
|
||
| /* forward declarations */ | ||
|
|
||
| static void *msk_cq_thread(void *arg); | ||
|
|
@@ -212,6 +254,17 @@ static inline int msk_cond_timedwait(int debug, | |
| } | ||
|
|
||
|
|
||
| /** | ||
| * msk_fork_init: wrapper around ibv_fork_init() | ||
| * Initialize libibverbs to support fork(). | ||
| * | ||
| * @return 0 on success, the value of errno on failure | ||
| */ | ||
| int msk_fork_init(void) | ||
| { | ||
| return ibv_fork_init(); | ||
| } | ||
|
|
||
| /** | ||
| * msk_getpd: helper function to get the right pd for a given trans | ||
| * | ||
|
|
||
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.
(these are missing in
msk_internals_finiand should be added there regardless of reusing the functions; thanks for finding these)