@@ -105,65 +105,26 @@ void ReportPath(uv_handle_t* h, std::ostringstream& out) {
105
105
106
106
// Utility function to walk libuv handles.
107
107
void WalkHandle (uv_handle_t * h, void * arg) {
108
- std::string type;
108
+ const char * type = uv_handle_type_name (h-> type ) ;
109
109
std::ostringstream data;
110
110
JSONWriter* writer = static_cast <JSONWriter*>(arg);
111
111
uv_any_handle* handle = reinterpret_cast <uv_any_handle*>(h);
112
112
113
- // List all the types so we get a compile warning if we've missed one,
114
- // (using default: supresses the compiler warning).
115
113
switch (h->type ) {
116
- case UV_UNKNOWN_HANDLE:
117
- type = " unknown" ;
118
- break ;
119
- case UV_ASYNC:
120
- type = " async" ;
121
- break ;
122
- case UV_CHECK:
123
- type = " check" ;
124
- break ;
125
- case UV_FS_EVENT: {
126
- type = " fs_event" ;
127
- ReportPath (h, data);
128
- break ;
129
- }
130
- case UV_FS_POLL: {
131
- type = " fs_poll" ;
114
+ case UV_FS_EVENT:
115
+ case UV_FS_POLL:
132
116
ReportPath (h, data);
133
117
break ;
134
- }
135
- case UV_HANDLE:
136
- type = " handle" ;
137
- break ;
138
- case UV_IDLE:
139
- type = " idle" ;
140
- break ;
141
- case UV_NAMED_PIPE:
142
- type = " pipe" ;
143
- break ;
144
- case UV_POLL:
145
- type = " poll" ;
146
- break ;
147
- case UV_PREPARE:
148
- type = " prepare" ;
149
- break ;
150
- case UV_PROCESS: {
151
- type = " process" ;
118
+ case UV_PROCESS:
152
119
data << " pid: " << handle->process .pid ;
153
120
break ;
154
- }
155
- case UV_STREAM:
156
- type = " stream" ;
157
- break ;
158
- case UV_TCP: {
159
- type = " tcp" ;
121
+ case UV_TCP:
122
+ case UV_UDP:
160
123
ReportEndpoints (h, data);
161
124
break ;
162
- }
163
125
case UV_TIMER: {
164
126
uint64_t due = handle->timer .timeout ;
165
127
uint64_t now = uv_now (handle->timer .loop );
166
- type = " timer" ;
167
128
data << " repeat: " << uv_timer_get_repeat (&(handle->timer ));
168
129
if (due > now) {
169
130
data << " , timeout in: " << (due - now) << " ms" ;
@@ -174,35 +135,23 @@ void WalkHandle(uv_handle_t* h, void* arg) {
174
135
}
175
136
case UV_TTY: {
176
137
int height, width, rc;
177
- type = " tty" ;
178
138
rc = uv_tty_get_winsize (&(handle->tty ), &width, &height);
179
139
if (rc == 0 ) {
180
140
data << " width: " << width << " , height: " << height;
181
141
}
182
142
break ;
183
143
}
184
- case UV_UDP: {
185
- type = " udp" ;
186
- ReportEndpoints (h, data);
187
- break ;
188
- }
189
144
case UV_SIGNAL: {
190
145
// SIGWINCH is used by libuv so always appears.
191
146
// See http://docs.libuv.org/en/v1.x/signal.html
192
- type = " signal" ;
193
147
data << " signum: " << handle->signal .signum
194
148
#ifndef _WIN32
195
149
<< " (" << node::signo_string (handle->signal .signum ) << " )"
196
150
#endif
197
151
<< " " ;
198
152
break ;
199
153
}
200
- case UV_FILE:
201
- type = " file" ;
202
- break ;
203
- // We shouldn't see "max" type
204
- case UV_HANDLE_TYPE_MAX:
205
- type = " max" ;
154
+ default :
206
155
break ;
207
156
}
208
157
0 commit comments