Skip to content

Commit 84dd526

Browse files
danbevFishrock123
authored andcommitted
src: renaming ares_task struct to node_ares_task
This commit attempts to fix one of the items in #4641, which was to remove a TODO comment from env.h regarding the naming of the ares_task_t struct. Also, the struct ares_task_list was renamed to node_ares_task_list following the same reasoning that is does not belong to the c-ares API. PR-URL: #7345 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Conflicts: src/env.h
1 parent fa9e6f7 commit 84dd526

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

src/cares_wrap.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
9191
}
9292

9393

94-
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
94+
static int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
9595
if (a->sock < b->sock)
9696
return -1;
9797
if (a->sock > b->sock)
@@ -100,7 +100,7 @@ static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
100100
}
101101

102102

103-
RB_GENERATE_STATIC(ares_task_list, ares_task_t, node, cmp_ares_tasks)
103+
RB_GENERATE_STATIC(node_ares_task_list, node_ares_task, node, cmp_ares_tasks)
104104

105105

106106

@@ -114,7 +114,7 @@ static void ares_timeout(uv_timer_t* handle) {
114114

115115

116116
static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
117-
ares_task_t* task = ContainerOf(&ares_task_t::poll_watcher, watcher);
117+
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher, watcher);
118118
Environment* env = task->env;
119119

120120
/* Reset the idle timer */
@@ -135,15 +135,15 @@ static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
135135

136136

137137
static void ares_poll_close_cb(uv_handle_t* watcher) {
138-
ares_task_t* task = ContainerOf(&ares_task_t::poll_watcher,
138+
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher,
139139
reinterpret_cast<uv_poll_t*>(watcher));
140140
free(task);
141141
}
142142

143143

144-
/* Allocates and returns a new ares_task_t */
145-
static ares_task_t* ares_task_create(Environment* env, ares_socket_t sock) {
146-
ares_task_t* task = static_cast<ares_task_t*>(malloc(sizeof(*task)));
144+
/* Allocates and returns a new node_ares_task */
145+
static node_ares_task* ares_task_create(Environment* env, ares_socket_t sock) {
146+
node_ares_task* task = static_cast<node_ares_task*>(malloc(sizeof(*task)));
147147

148148
if (task == nullptr) {
149149
/* Out of memory. */
@@ -169,11 +169,11 @@ static void ares_sockstate_cb(void* data,
169169
int read,
170170
int write) {
171171
Environment* env = static_cast<Environment*>(data);
172-
ares_task_t* task;
172+
node_ares_task* task;
173173

174-
ares_task_t lookup_task;
174+
node_ares_task lookup_task;
175175
lookup_task.sock = sock;
176-
task = RB_FIND(ares_task_list, env->cares_task_list(), &lookup_task);
176+
task = RB_FIND(node_ares_task_list, env->cares_task_list(), &lookup_task);
177177

178178
if (read || write) {
179179
if (!task) {
@@ -194,7 +194,7 @@ static void ares_sockstate_cb(void* data,
194194
return;
195195
}
196196

197-
RB_INSERT(ares_task_list, env->cares_task_list(), task);
197+
RB_INSERT(node_ares_task_list, env->cares_task_list(), task);
198198
}
199199

200200
/* This should never fail. If it fails anyway, the query will eventually */
@@ -210,7 +210,7 @@ static void ares_sockstate_cb(void* data,
210210
CHECK(task &&
211211
"When an ares socket is closed we should have a handle for it");
212212

213-
RB_REMOVE(ares_task_list, env->cares_task_list(), task);
213+
RB_REMOVE(node_ares_task_list, env->cares_task_list(), task);
214214
uv_close(reinterpret_cast<uv_handle_t*>(&task->poll_watcher),
215215
ares_poll_close_cb);
216216

src/env-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ inline ares_channel* Environment::cares_channel_ptr() {
428428
return &cares_channel_;
429429
}
430430

431-
inline ares_task_list* Environment::cares_task_list() {
431+
inline node_ares_task_list* Environment::cares_task_list() {
432432
return &cares_task_list_;
433433
}
434434

src/env.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,14 @@ namespace node {
291291

292292
class Environment;
293293

294-
// TODO(bnoordhuis) Rename struct, the ares_ prefix implies it's part
295-
// of the c-ares API while the _t suffix implies it's a typedef.
296-
struct ares_task_t {
294+
struct node_ares_task {
297295
Environment* env;
298296
ares_socket_t sock;
299297
uv_poll_t poll_watcher;
300-
RB_ENTRY(ares_task_t) node;
298+
RB_ENTRY(node_ares_task) node;
301299
};
302300

303-
RB_HEAD(ares_task_list, ares_task_t);
301+
RB_HEAD(node_ares_task_list, node_ares_task);
304302

305303
class Environment {
306304
public:
@@ -472,7 +470,7 @@ class Environment {
472470
inline uv_timer_t* cares_timer_handle();
473471
inline ares_channel cares_channel();
474472
inline ares_channel* cares_channel_ptr();
475-
inline ares_task_list* cares_task_list();
473+
inline node_ares_task_list* cares_task_list();
476474

477475
inline bool using_domains() const;
478476
inline void set_using_domains(bool value);
@@ -588,7 +586,7 @@ class Environment {
588586
const uint64_t timer_base_;
589587
uv_timer_t cares_timer_handle_;
590588
ares_channel cares_channel_;
591-
ares_task_list cares_task_list_;
589+
node_ares_task_list cares_task_list_;
592590
bool using_domains_;
593591
bool printed_error_;
594592
bool trace_sync_io_;

0 commit comments

Comments
 (0)