Skip to content

Commit 3b5cede

Browse files
danbevMyles Borins
authored and
Myles Borins
committed
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent f6f0b38 commit 3b5cede

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

src/cares_wrap.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
123123
}
124124

125125

126-
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
126+
static int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
127127
if (a->sock < b->sock)
128128
return -1;
129129
if (a->sock > b->sock)
@@ -132,7 +132,7 @@ static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
132132
}
133133

134134

135-
RB_GENERATE_STATIC(ares_task_list, ares_task_t, node, cmp_ares_tasks)
135+
RB_GENERATE_STATIC(node_ares_task_list, node_ares_task, node, cmp_ares_tasks)
136136

137137

138138

@@ -146,7 +146,7 @@ static void ares_timeout(uv_timer_t* handle) {
146146

147147

148148
static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
149-
ares_task_t* task = ContainerOf(&ares_task_t::poll_watcher, watcher);
149+
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher, watcher);
150150
Environment* env = task->env;
151151

152152
/* Reset the idle timer */
@@ -167,15 +167,15 @@ static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
167167

168168

169169
static void ares_poll_close_cb(uv_handle_t* watcher) {
170-
ares_task_t* task = ContainerOf(&ares_task_t::poll_watcher,
170+
node_ares_task* task = ContainerOf(&node_ares_task::poll_watcher,
171171
reinterpret_cast<uv_poll_t*>(watcher));
172172
free(task);
173173
}
174174

175175

176-
/* Allocates and returns a new ares_task_t */
177-
static ares_task_t* ares_task_create(Environment* env, ares_socket_t sock) {
178-
ares_task_t* task = static_cast<ares_task_t*>(malloc(sizeof(*task)));
176+
/* Allocates and returns a new node_ares_task */
177+
static node_ares_task* ares_task_create(Environment* env, ares_socket_t sock) {
178+
node_ares_task* task = static_cast<node_ares_task*>(malloc(sizeof(*task)));
179179

180180
if (task == nullptr) {
181181
/* Out of memory. */
@@ -201,11 +201,11 @@ static void ares_sockstate_cb(void* data,
201201
int read,
202202
int write) {
203203
Environment* env = static_cast<Environment*>(data);
204-
ares_task_t* task;
204+
node_ares_task* task;
205205

206-
ares_task_t lookup_task;
206+
node_ares_task lookup_task;
207207
lookup_task.sock = sock;
208-
task = RB_FIND(ares_task_list, env->cares_task_list(), &lookup_task);
208+
task = RB_FIND(node_ares_task_list, env->cares_task_list(), &lookup_task);
209209

210210
if (read || write) {
211211
if (!task) {
@@ -226,7 +226,7 @@ static void ares_sockstate_cb(void* data,
226226
return;
227227
}
228228

229-
RB_INSERT(ares_task_list, env->cares_task_list(), task);
229+
RB_INSERT(node_ares_task_list, env->cares_task_list(), task);
230230
}
231231

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

245-
RB_REMOVE(ares_task_list, env->cares_task_list(), task);
245+
RB_REMOVE(node_ares_task_list, env->cares_task_list(), task);
246246
uv_close(reinterpret_cast<uv_handle_t*>(&task->poll_watcher),
247247
ares_poll_close_cb);
248248

src/env-inl.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ inline ares_channel* Environment::cares_channel_ptr() {
398398
return &cares_channel_;
399399
}
400400

401-
inline ares_task_list* Environment::cares_task_list() {
401+
inline node_ares_task_list* Environment::cares_task_list() {
402402
return &cares_task_list_;
403403
}
404404

src/env.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,14 @@ namespace node {
259259

260260
class Environment;
261261

262-
// TODO(bnoordhuis) Rename struct, the ares_ prefix implies it's part
263-
// of the c-ares API while the _t suffix implies it's a typedef.
264-
struct ares_task_t {
262+
struct node_ares_task {
265263
Environment* env;
266264
ares_socket_t sock;
267265
uv_poll_t poll_watcher;
268-
RB_ENTRY(ares_task_t) node;
266+
RB_ENTRY(node_ares_task) node;
269267
};
270268

271-
RB_HEAD(ares_task_list, ares_task_t);
269+
RB_HEAD(node_ares_task_list, node_ares_task);
272270

273271
class Environment {
274272
public:
@@ -440,7 +438,7 @@ class Environment {
440438
inline uv_timer_t* cares_timer_handle();
441439
inline ares_channel cares_channel();
442440
inline ares_channel* cares_channel_ptr();
443-
inline ares_task_list* cares_task_list();
441+
inline node_ares_task_list* cares_task_list();
444442

445443
inline bool using_domains() const;
446444
inline void set_using_domains(bool value);
@@ -542,7 +540,7 @@ class Environment {
542540
const uint64_t timer_base_;
543541
uv_timer_t cares_timer_handle_;
544542
ares_channel cares_channel_;
545-
ares_task_list cares_task_list_;
543+
node_ares_task_list cares_task_list_;
546544
bool using_domains_;
547545
bool printed_error_;
548546
bool trace_sync_io_;

0 commit comments

Comments
 (0)