* Main initialization function, init multi_context object.
*/
void
-multi_init(struct multi_context *m, struct context *t, bool tcp_mode, int thread_mode)
+multi_init(struct multi_context *m, struct context *t, bool tcp_mode)
{
int dev = DEV_TYPE_UNDEF;
*/
CLEAR(*m);
- m->thread_mode = thread_mode;
-
/*
* Real address hash table (source port number is
* considered to be part of the address). Used
void
multi_uninit(struct multi_context *m)
{
- if (m->thread_mode & MC_WORK_THREAD)
- {
- multi_top_free(m);
- m->thread_mode = MC_UNDEF;
- }
- else if (m->thread_mode)
+ if (m->hash)
{
- if (m->hash)
- {
- struct hash_iterator hi;
- struct hash_element *he;
+ struct hash_iterator hi;
+ struct hash_element *he;
- hash_iterator_init(m->iter, &hi);
- while ((he = hash_iterator_next(&hi)))
- {
- struct multi_instance *mi = (struct multi_instance *) he->value;
- mi->did_iter = false;
- multi_close_instance(m, mi, true);
- }
- hash_iterator_free(&hi);
+ hash_iterator_init(m->iter, &hi);
+ while ((he = hash_iterator_next(&hi)))
+ {
+ struct multi_instance *mi = (struct multi_instance *) he->value;
+ mi->did_iter = false;
+ multi_close_instance(m, mi, true);
+ }
+ hash_iterator_free(&hi);
- multi_reap_all(m);
+ multi_reap_all(m);
- hash_free(m->hash);
- hash_free(m->vhash);
- hash_free(m->iter);
+ hash_free(m->hash);
+ hash_free(m->vhash);
+ hash_free(m->iter);
#ifdef ENABLE_MANAGEMENT
- hash_free(m->cid_hash);
+ hash_free(m->cid_hash);
#endif
- m->hash = NULL;
+ m->hash = NULL;
- free(m->instances);
+ free(m->instances);
#ifdef ENABLE_ASYNC_PUSH
- hash_free(m->inotify_watchers);
- m->inotify_watchers = NULL;
+ hash_free(m->inotify_watchers);
+ m->inotify_watchers = NULL;
#endif
- schedule_free(m->schedule);
- mbuf_free(m->mbuf);
- ifconfig_pool_free(m->ifconfig_pool);
- frequency_limit_free(m->new_connection_limiter);
- multi_reap_free(m->reaper);
- mroute_helper_free(m->route_helper);
- multi_tcp_free(m->mtcp);
- m->thread_mode = MC_UNDEF;
- }
+ schedule_free(m->schedule);
+ mbuf_free(m->mbuf);
+ ifconfig_pool_free(m->ifconfig_pool);
+ frequency_limit_free(m->new_connection_limiter);
+ multi_reap_free(m->reaper);
+ mroute_helper_free(m->route_helper);
+ multi_tcp_free(m->mtcp);
}
}
* server-mode.
*/
struct multi_context {
-#define MC_UNDEF 0
-#define MC_SINGLE_THREADED (1<<0)
-#define MC_MULTI_THREADED_MASTER (1<<1)
-#define MC_MULTI_THREADED_WORKER (1<<2)
-#define MC_MULTI_THREADED_SCHEDULER (1<<3)
-#define MC_WORK_THREAD (MC_MULTI_THREADED_WORKER|MC_MULTI_THREADED_SCHEDULER)
- int thread_mode;
-
struct multi_instance **instances; /**< Array of multi_instances. An instance can be
* accessed using peer-id as an index. */
* Called by mtcp.c, mudp.c, or other (to be written) protocol drivers
*/
-void multi_init(struct multi_context *m, struct context *t, bool tcp_mode, int thread_mode);
+void multi_init(struct multi_context *m, struct context *t, bool tcp_mode);
void multi_uninit(struct multi_context *m);