From aa5da48594c1634de9f439bcf223acff3fb1fcd8 Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Thu, 28 Mar 2013 16:51:52 -0700 Subject: [PATCH] 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. --- src/node_dtrace.cc | 19 ++++++++++--------- src/node_provider.d | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 3e53164..49ebf07 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -91,7 +91,8 @@ using namespace v8; } \ node_dtrace_connection_t conn; \ Local _##conn = Local::Cast(arg); \ - SLURP_INT(_##conn, fd, &conn.fd); \ + Local _handle = (_##conn)->Get(String::New("_handle"))->ToObject(); \ + SLURP_INT(_handle, fd, &conn.fd); \ SLURP_STRING(_##conn, remoteAddress, &conn.remote); \ SLURP_INT(_##conn, remotePort, &conn.port); \ SLURP_INT(_##conn, bufferSize, &conn.buffered); @@ -139,7 +140,7 @@ Handle DTRACE_NET_SERVER_CONNECTION(const Arguments& args) { NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \ conn.buffered); #else - NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port); + NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); @@ -157,7 +158,7 @@ Handle DTRACE_NET_STREAM_END(const Arguments& args) { #ifdef HAVE_SYSTEMTAP NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered); #else - NODE_NET_STREAM_END(&conn, conn.remote, conn.port); + NODE_NET_STREAM_END(&conn, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); @@ -181,7 +182,7 @@ Handle DTRACE_NET_SOCKET_READ(const Arguments& args) { "argument 1 to be number of bytes")))); } int nbytes = args[1]->Int32Value(); - NODE_NET_SOCKET_READ(&conn, nbytes, conn.remote, conn.port); + NODE_NET_SOCKET_READ(&conn, nbytes, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); @@ -205,7 +206,7 @@ Handle DTRACE_NET_SOCKET_WRITE(const Arguments& args) { "argument 1 to be number of bytes")))); } int nbytes = args[1]->Int32Value(); - NODE_NET_SOCKET_WRITE(&conn, nbytes, conn.remote, conn.port); + NODE_NET_SOCKET_WRITE(&conn, nbytes, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); @@ -248,7 +249,7 @@ Handle DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { conn.buffered); #else NODE_HTTP_SERVER_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \ - req.url); + req.url, conn.fd); #endif return Undefined(node_isolate); } @@ -265,7 +266,7 @@ Handle DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) { #ifdef HAVE_SYSTEMTAP NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered); #else - NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port); + NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); @@ -312,7 +313,7 @@ Handle DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) { conn.buffered); #else NODE_HTTP_CLIENT_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \ - req.url); + req.url, conn.fd); #endif return Undefined(node_isolate); } @@ -328,7 +329,7 @@ Handle DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) { #ifdef HAVE_SYSTEMTAP NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered); #else - NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port); + NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port, conn.fd); #endif return Undefined(node_isolate); diff --git a/src/node_provider.d b/src/node_provider.d index 4c526d4..6f95b03 100644 --- a/src/node_provider.d +++ b/src/node_provider.d @@ -53,25 +53,28 @@ typedef struct { provider node { probe net__server__connection(node_dtrace_connection_t *c, - const char *a, int p) : (node_connection_t *c, string a, int p); + const char *a, int p, int fd) : (node_connection_t *c, string a, int p, + int fd); probe net__stream__end(node_dtrace_connection_t *c, const char *a, - int p) : (node_connection_t *c, string a, int p); + int p, int fd) : (node_connection_t *c, string a, int p, int fd); probe net__socket__read(node_dtrace_connection_t *c, int b, - const char *a, int p) : (node_connection_t *c, int b, string a, int p); + const char *a, int p, int fd) : (node_connection_t *c, int b, string a, + int p, int fd); probe net__socket__write(node_dtrace_connection_t *c, int b, - const char *a, int p) : (node_connection_t *c, int b, string a, int p); + const char *a, int p, int fd) : (node_connection_t *c, int b, string a, + int p, int fd); probe http__server__request(node_dtrace_http_server_request_t *h, node_dtrace_connection_t *c, const char *a, int p, const char *m, - const char *u) : (node_http_request_t *h, node_connection_t *c, - string a, int p, string m, string u); + const char *u, int fd) : (node_http_request_t *h, node_connection_t *c, + string a, int p, string m, string u, int fd); probe http__server__response(node_dtrace_connection_t *c, const char *a, - int p) : (node_connection_t *c, string a, int p); + int p, int fd) : (node_connection_t *c, string a, int p, int fd); probe http__client__request(node_dtrace_http_client_request_t *h, node_dtrace_connection_t *c, const char *a, int p, const char *m, - const char *u) : (node_http_request_t *h, node_connection_t *c, string a, - int p, string m, string u); + const char *u, int fd) : (node_http_request_t *h, node_connection_t *c, + string a, int p, string m, string u, int fd); probe http__client__response(node_dtrace_connection_t *c, const char *a, - int p) : (node_connection_t *c, string a, int p); + int p, int fd) : (node_connection_t *c, string a, int p, int fd); probe gc__start(int t, int f); probe gc__done(int t, int f); }; -- 2.7.4