Skip to content

Commit

Permalink
reformat / remove some code that we used with old connection manageme…
Browse files Browse the repository at this point in the history
…nt methods
  • Loading branch information
radkesvat committed May 29, 2024
1 parent b4881da commit 2bb3fbf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ww/tunnel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ typedef void (*LineFlowSignal)(void *state);
typedef struct line_s
{
hloop_t *loop;
socket_context_t src_ctx;
socket_context_t dest_ctx;
void *chains_state[kMaxChainLen];
void *up_state;
void *dw_state;
LineFlowSignal up_pause_cb;
Expand All @@ -60,16 +59,15 @@ typedef struct line_s
uint8_t lcid;
uint8_t auth_cur;
bool alive;

void *chains_state[];
socket_context_t src_ctx;
socket_context_t dest_ctx;

} line_t;

typedef struct context_s
{
line_t *line;
shift_buffer_t *payload;
int fd;
bool init;
bool est;
bool first;
Expand Down Expand Up @@ -103,21 +101,22 @@ void defaultDownStream(tunnel_t *self, context_t *c);

inline line_t *newLine(uint8_t tid)
{
size_t size = sizeof(line_t) + (sizeof(void *) * kMaxChainLen);
size_t size = sizeof(line_t);
line_t *result = malloc(size);
// memset(result, 0, size);
*result = (line_t){
.tid = tid,
.refc = 1,
.lcid = kMaxChainLen - 1,
.auth_cur = 0,
.loop = loops[tid],
.alive = true,
.tid = tid,
.refc = 1,
.lcid = kMaxChainLen - 1,
.auth_cur = 0,
.loop = loops[tid],
.alive = true,
.chains_state = {0},
// to set a port we need to know the AF family, default v4
.dest_ctx = (socket_context_t){.address.sa = (struct sockaddr){.sa_family = AF_INET, .sa_data = {0}}},
.src_ctx = (socket_context_t){.address.sa = (struct sockaddr){.sa_family = AF_INET, .sa_data = {0}}},
};
memset(&(result->chains_state), 0, (sizeof(void *) * kMaxChainLen));

return result;
}
inline bool isAlive(line_t *line)
Expand Down
13 changes: 13 additions & 0 deletions ww/ww.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
#define WW_UNLIKELY(x) (v)
#endif

#define MUSTALIGN2(n, w) assert(((w) & ((w) - 1)) == 0); /* alignment w is not a power of two */

// kCpuLineCacheSize is the size of a cache line of the target CPU.
// The value 64 covers i386, x86_64, arm32, arm64.
// Note that Intel TBB uses 128 (max_nfs_size).
// todo (platform code) set value depending on target preprocessor information.
enum
{
kCpuLineCacheSize = 64
};

#define ATTR_ALIGNED_LINE_CACHE __attribute__((aligned(kCpuLineCacheSize)))

struct ww_runtime_state_s;

WWEXPORT void setWW(struct ww_runtime_state_s *state);
Expand Down

0 comments on commit 2bb3fbf

Please sign in to comment.