From c09e1091691213b66c0592756a25481ab51a7db7 Mon Sep 17 00:00:00 2001 From: Radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Thu, 15 Aug 2024 19:30:57 +0000 Subject: [PATCH] reformat / name update --- ww/devices/capture/capture_linux.c | 12 ++++++------ ww/devices/raw/raw_linux.c | 23 ++++++++++++----------- ww/devices/tun/tun_linux.c | 12 ++++++------ ww/ww.c | 27 ++++++++++++--------------- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/ww/devices/capture/capture_linux.c b/ww/devices/capture/capture_linux.c index c753f02..3824aae 100644 --- a/ww/devices/capture/capture_linux.c +++ b/ww/devices/capture/capture_linux.c @@ -445,15 +445,15 @@ capture_device_t *createCaptureDevice(const char *name, uint32_t queue_number, v LOGE("CaptureDevice: unable to set netfilter queue maximum length to %u", kQueueLen); } - generic_pool_t *sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, + generic_pool_t *reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); - buffer_pool_t *bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, - sb_pool, GSTATE.ram_profile); + buffer_pool_t *reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, + reader_sb_pool, GSTATE.ram_profile); generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, 1, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); buffer_pool_t *writer_bpool = - createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool, 1); + createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, writer_sb_pool, 1); capture_device_t *cdev = globalMalloc(sizeof(capture_device_t)); @@ -464,12 +464,12 @@ capture_device_t *createCaptureDevice(const char *name, uint32_t queue_number, v .routine_writer = routineWriteToCapture, .socket = socket_netfilter, .queue_number = queue_number, - .reader_shift_buffer_pool = sb_pool, + .reader_shift_buffer_pool = reader_sb_pool, .read_event_callback = cb, .userdata = userdata, .writer_buffer_channel = hchanOpen(sizeof(void *), kCaptureWriteChannelQueueMax), .reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap), - .reader_buffer_pool = bpool, + .reader_buffer_pool = reader_bpool, .writer_shift_buffer_pool = writer_sb_pool, .writer_buffer_pool = writer_bpool}; diff --git a/ww/devices/raw/raw_linux.c b/ww/devices/raw/raw_linux.c index 43d89e1..24bcb52 100644 --- a/ww/devices/raw/raw_linux.c +++ b/ww/devices/raw/raw_linux.c @@ -214,25 +214,26 @@ raw_device_t *createRawDevice(const char *name, uint32_t mark, void *userdata, R raw_device_t *rdev = globalMalloc(sizeof(raw_device_t)); - generic_pool_t *sb_pool = NULL; - buffer_pool_t *bpool = NULL; - master_pool_t *mpool = NULL; + generic_pool_t *reader_sb_pool = NULL; + buffer_pool_t *reader_bpool = NULL; + master_pool_t *reader_message_pool = NULL; if (cb != NULL) { // if the user really wanted to read from raw socket - sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, + reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); - bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool, + reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, reader_sb_pool, GSTATE.ram_profile); - mpool = newMasterPoolWithCap(kMasterMessagePoolCap); + reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap); - installMasterPoolAllocCallbacks(mpool, allocRawMsgPoolHandle, destroyRawMsgPoolHandle); + installMasterPoolAllocCallbacks(reader_message_pool, allocRawMsgPoolHandle, destroyRawMsgPoolHandle); } + generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); buffer_pool_t *writer_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, - GSTATE.masterpool_buffer_pools_small, sb_pool, GSTATE.ram_profile); + GSTATE.masterpool_buffer_pools_small, writer_sb_pool, GSTATE.ram_profile); *rdev = (raw_device_t) {.name = strdup(name), .running = false, @@ -241,12 +242,12 @@ raw_device_t *createRawDevice(const char *name, uint32_t mark, void *userdata, R .routine_writer = routineWriteToRaw, .socket = rsocket, .mark = mark, - .reader_shift_buffer_pool = sb_pool, + .reader_shift_buffer_pool = reader_sb_pool, .read_event_callback = cb, .userdata = userdata, .writer_buffer_channel = hchanOpen(sizeof(void *), kRawWriteChannelQueueMax), - .reader_message_pool = mpool, - .reader_buffer_pool = bpool, + .reader_message_pool = reader_message_pool, + .reader_buffer_pool = reader_bpool, .writer_shift_buffer_pool = writer_sb_pool, .writer_buffer_pool = writer_bpool}; diff --git a/ww/devices/tun/tun_linux.c b/ww/devices/tun/tun_linux.c index b013786..6acbfee 100644 --- a/ww/devices/tun/tun_linux.c +++ b/ww/devices/tun/tun_linux.c @@ -317,15 +317,15 @@ tun_device_t *createTunDevice(const char *name, bool offload, void *userdata, Tu return NULL; } - generic_pool_t *sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, + generic_pool_t *reader_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); - buffer_pool_t *bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, - sb_pool, (0) + GSTATE.ram_profile); + buffer_pool_t *reader_bpool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, + reader_sb_pool, (0) + GSTATE.ram_profile); generic_pool_t *writer_sb_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, 1, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); buffer_pool_t *writer_bpool = - createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, sb_pool, 1); + createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, writer_sb_pool, 1); tun_device_t *tdev = globalMalloc(sizeof(tun_device_t)); @@ -338,9 +338,9 @@ tun_device_t *createTunDevice(const char *name, bool offload, void *userdata, Tu .read_event_callback = cb, .userdata = userdata, .writer_buffer_channel = hchanOpen(sizeof(void *), kTunWriteChannelQueueMax), - .reader_shift_buffer_pool = sb_pool, + .reader_shift_buffer_pool = reader_sb_pool, .reader_message_pool = newMasterPoolWithCap(kMasterMessagePoolCap), - .reader_buffer_pool = bpool, + .reader_buffer_pool = reader_bpool, .writer_shift_buffer_pool = writer_sb_pool, .writer_buffer_pool = writer_bpool diff --git a/ww/ww.c b/ww/ww.c index efd6f04..a86cd74 100644 --- a/ww/ww.c +++ b/ww/ww.c @@ -35,28 +35,24 @@ static void initalizeWorker(worker_t *worker, tid_t tid) { *worker = (worker_t) {.tid = tid}; - worker->context_pool = newGenericPoolWithCap(GSTATE.masterpool_context_pools, (16) + GSTATE.ram_profile, - allocContextPoolHandle, destroyContextPoolHandle); - GSTATE.shortcut_context_pools[tid] = getWorker(tid)->context_pool; - - worker->line_pool = newGenericPoolWithCap(GSTATE.masterpool_line_pools, (8) + GSTATE.ram_profile, - allocLinePoolHandle, destroyLinePoolHandle); - GSTATE.shortcut_line_pools[tid] = getWorker(tid)->line_pool; - + worker->loop = hloop_new(HLOOP_FLAG_AUTO_FREE, worker->buffer_pool, tid); + worker->context_pool = newGenericPoolWithCap(GSTATE.masterpool_context_pools, (16) + GSTATE.ram_profile, + allocContextPoolHandle, destroyContextPoolHandle); + worker->line_pool = newGenericPoolWithCap(GSTATE.masterpool_line_pools, (8) + GSTATE.ram_profile, + allocLinePoolHandle, destroyLinePoolHandle); worker->pipeline_msg_pool = newGenericPoolWithCap(GSTATE.masterpool_pipeline_msg_pools, (8) + GSTATE.ram_profile, allocPipeLineMsgPoolHandle, destroyPipeLineMsgPoolHandle); - GSTATE.shortcut_pipeline_msg_pools[tid] = getWorker(tid)->pipeline_msg_pool; - worker->shift_buffer_pool = newGenericPoolWithCap(GSTATE.masterpool_shift_buffer_pools, (64) + GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle); - GSTATE.shortcut_shift_buffer_pools[tid] = getWorker(tid)->shift_buffer_pool; - worker->buffer_pool = createBufferPool(GSTATE.masterpool_buffer_pools_large, GSTATE.masterpool_buffer_pools_small, worker->shift_buffer_pool, (0) + GSTATE.ram_profile); - GSTATE.shortcut_buffer_pools[tid] = getWorker(tid)->buffer_pool; - worker->loop = hloop_new(HLOOP_FLAG_AUTO_FREE, worker->buffer_pool, tid); - GSTATE.shortcut_loops[tid] = getWorker(tid)->loop; + GSTATE.shortcut_context_pools[tid] = worker->context_pool; + GSTATE.shortcut_line_pools[tid] = worker->line_pool; + GSTATE.shortcut_pipeline_msg_pools[tid] = worker->pipeline_msg_pool; + GSTATE.shortcut_shift_buffer_pools[tid] = worker->shift_buffer_pool; + GSTATE.shortcut_buffer_pools[tid] = worker->buffer_pool; + GSTATE.shortcut_loops[tid] = worker->loop; } static void runWorker(worker_t *worker) @@ -188,6 +184,7 @@ void createWW(const ww_construction_data_t init_data) GSTATE.signal_manager = createSignalManager(); startSignalManager(); } + // [Section] setup SocketMangager { GSTATE.socekt_manager = createSocketManager();