Skip to content

Commit ee1461f

Browse files
danbevaddaleax
authored andcommitted
src: renaming ares_task struct to node_ares_task
This commit attempts to fix one of the items in nodejs#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: nodejs#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>
1 parent 110ce55 commit ee1461f

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
@@ -90,7 +90,7 @@ static void NewQueryReqWrap(const FunctionCallbackInfo<Value>& args) {
9090
}
9191

9292

93-
static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
93+
static int cmp_ares_tasks(const node_ares_task* a, const node_ares_task* b) {
9494
if (a->sock < b->sock)
9595
return -1;
9696
if (a->sock > b->sock)
@@ -99,7 +99,7 @@ static int cmp_ares_tasks(const ares_task_t* a, const ares_task_t* b) {
9999
}
100100

101101

102-
RB_GENERATE_STATIC(ares_task_list, ares_task_t, node, cmp_ares_tasks)
102+
RB_GENERATE_STATIC(node_ares_task_list, node_ares_task, node, cmp_ares_tasks)
103103

104104

105105

@@ -113,7 +113,7 @@ static void ares_timeout(uv_timer_t* handle) {
113113

114114

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

119119
/* Reset the idle timer */
@@ -134,15 +134,15 @@ static void ares_poll_cb(uv_poll_t* watcher, int status, int events) {
134134

135135

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

142142

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

147147
if (task == nullptr) {
148148
/* Out of memory. */
@@ -168,11 +168,11 @@ static void ares_sockstate_cb(void* data,
168168
int read,
169169
int write) {
170170
Environment* env = static_cast<Environment*>(data);
171-
ares_task_t* task;
171+
node_ares_task* task;
172172

173-
ares_task_t lookup_task;
173+
node_ares_task lookup_task;
174174
lookup_task.sock = sock;
175-
task = RB_FIND(ares_task_list, env->cares_task_list(), &lookup_task);
175+
task = RB_FIND(node_ares_task_list, env->cares_task_list(), &lookup_task);
176176

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

196-
RB_INSERT(ares_task_list, env->cares_task_list(), task);
196+
RB_INSERT(node_ares_task_list, env->cares_task_list(), task);
197197
}
198198

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

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

src/env-inl.h

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 7 deletions
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)