Skip to content

Commit

Permalink
server: code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: He Xian <hexian000@outlook.com>
  • Loading branch information
hexian000 committed Nov 23, 2024
1 parent c744702 commit c5ef339
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
1 change: 0 additions & 1 deletion contrib/csnippets/algo/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ typedef bool (*table_iterate_cb)(
void *data);

enum table_flags {
TABLE_DEFAULT = 0,
/* set max load factor to 75%, trading space for speed */
TABLE_FAST = 1 << 0,
};
Expand Down
23 changes: 9 additions & 14 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,17 @@ server_new(struct ev_loop *loop, const struct config *restrict conf)
/* server mode: disable keepalive and resolve */
s->keepalive = 0.0;
}
int flags = 0;
if ((conf->mode & MODE_SERVER) != 0) {
s->sessions = table_new(TABLE_FAST);
if (s->sessions == NULL) {
LOGOOM();
server_free(s);
return NULL;
}
} else if ((conf->mode & MODE_CLIENT) != 0) {
s->sessions = table_new(TABLE_DEFAULT);
if (s->sessions == NULL) {
LOGOOM();
server_free(s);
return NULL;
}
flags |= TABLE_FAST;
}
s->sessions = table_new(flags);
if (s->sessions == NULL) {
LOGOOM();
server_free(s);
return NULL;
}
s->pkt.services = table_new(TABLE_DEFAULT);
s->pkt.services = table_new(flags);
if (s->pkt.services == NULL) {
LOGOOM();
server_free(s);
Expand Down

0 comments on commit c5ef339

Please sign in to comment.