Skip to content

Commit aca31e3

Browse files
tjfontaineisaacs
authored andcommitted
dtrace: actually use the _handle.fd value
When using the DTrace/systemtap subsystems it would be helpful to actually have an fd associated with the requests and responses.
1 parent bf22f99 commit aca31e3

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

src/node_dtrace.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ using namespace v8;
9191
} \
9292
node_dtrace_connection_t conn; \
9393
Local<Object> _##conn = Local<Object>::Cast(arg); \
94-
SLURP_INT(_##conn, fd, &conn.fd); \
94+
Local<Object> _handle = (_##conn)->Get(String::New("_handle"))->ToObject(); \
95+
SLURP_INT(_handle, fd, &conn.fd); \
9596
SLURP_STRING(_##conn, remoteAddress, &conn.remote); \
9697
SLURP_INT(_##conn, remotePort, &conn.port); \
9798
SLURP_INT(_##conn, bufferSize, &conn.buffered);
@@ -139,7 +140,7 @@ Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
139140
NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \
140141
conn.buffered);
141142
#else
142-
NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port);
143+
NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port, conn.fd);
143144
#endif
144145

145146
return Undefined();
@@ -157,7 +158,7 @@ Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
157158
#ifdef HAVE_SYSTEMTAP
158159
NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered);
159160
#else
160-
NODE_NET_STREAM_END(&conn, conn.remote, conn.port);
161+
NODE_NET_STREAM_END(&conn, conn.remote, conn.port, conn.fd);
161162
#endif
162163

163164
return Undefined();
@@ -181,7 +182,7 @@ Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
181182
"argument 1 to be number of bytes"))));
182183
}
183184
int nbytes = args[1]->Int32Value();
184-
NODE_NET_SOCKET_READ(&conn, nbytes, conn.remote, conn.port);
185+
NODE_NET_SOCKET_READ(&conn, nbytes, conn.remote, conn.port, conn.fd);
185186
#endif
186187

187188
return Undefined();
@@ -205,7 +206,7 @@ Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
205206
"argument 1 to be number of bytes"))));
206207
}
207208
int nbytes = args[1]->Int32Value();
208-
NODE_NET_SOCKET_WRITE(&conn, nbytes, conn.remote, conn.port);
209+
NODE_NET_SOCKET_WRITE(&conn, nbytes, conn.remote, conn.port, conn.fd);
209210
#endif
210211

211212
return Undefined();
@@ -248,7 +249,7 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
248249
conn.buffered);
249250
#else
250251
NODE_HTTP_SERVER_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
251-
req.url);
252+
req.url, conn.fd);
252253
#endif
253254
return Undefined();
254255
}
@@ -265,7 +266,7 @@ Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
265266
#ifdef HAVE_SYSTEMTAP
266267
NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
267268
#else
268-
NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port);
269+
NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port, conn.fd);
269270
#endif
270271

271272
return Undefined();
@@ -312,7 +313,7 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
312313
conn.buffered);
313314
#else
314315
NODE_HTTP_CLIENT_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
315-
req.url);
316+
req.url, conn.fd);
316317
#endif
317318
return Undefined();
318319
}
@@ -328,7 +329,7 @@ Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
328329
#ifdef HAVE_SYSTEMTAP
329330
NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
330331
#else
331-
NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port);
332+
NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port, conn.fd);
332333
#endif
333334

334335
return Undefined();

src/node_provider.d

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,28 @@ typedef struct {
5353

5454
provider node {
5555
probe net__server__connection(node_dtrace_connection_t *c,
56-
const char *a, int p) : (node_connection_t *c, string a, int p);
56+
const char *a, int p, int fd) : (node_connection_t *c, string a, int p,
57+
int fd);
5758
probe net__stream__end(node_dtrace_connection_t *c, const char *a,
58-
int p) : (node_connection_t *c, string a, int p);
59+
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
5960
probe net__socket__read(node_dtrace_connection_t *c, int b,
60-
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
61+
const char *a, int p, int fd) : (node_connection_t *c, int b, string a,
62+
int p, int fd);
6163
probe net__socket__write(node_dtrace_connection_t *c, int b,
62-
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
64+
const char *a, int p, int fd) : (node_connection_t *c, int b, string a,
65+
int p, int fd);
6366
probe http__server__request(node_dtrace_http_server_request_t *h,
6467
node_dtrace_connection_t *c, const char *a, int p, const char *m,
65-
const char *u) : (node_http_request_t *h, node_connection_t *c,
66-
string a, int p, string m, string u);
68+
const char *u, int fd) : (node_http_request_t *h, node_connection_t *c,
69+
string a, int p, string m, string u, int fd);
6770
probe http__server__response(node_dtrace_connection_t *c, const char *a,
68-
int p) : (node_connection_t *c, string a, int p);
71+
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
6972
probe http__client__request(node_dtrace_http_client_request_t *h,
7073
node_dtrace_connection_t *c, const char *a, int p, const char *m,
71-
const char *u) : (node_http_request_t *h, node_connection_t *c, string a,
72-
int p, string m, string u);
74+
const char *u, int fd) : (node_http_request_t *h, node_connection_t *c,
75+
string a, int p, string m, string u, int fd);
7376
probe http__client__response(node_dtrace_connection_t *c, const char *a,
74-
int p) : (node_connection_t *c, string a, int p);
77+
int p, int fd) : (node_connection_t *c, string a, int p, int fd);
7578
probe gc__start(int t, int f);
7679
probe gc__done(int t, int f);
7780
};

0 commit comments

Comments
 (0)