about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--include/uv_link_t.h16
-rw-r--r--src/uv_link_observer_t.c9
-rw-r--r--src/uv_link_source_t.c22
-rw-r--r--test/src/test-uv-link-source-t.c4
4 files changed, 31 insertions, 20 deletions
diff --git a/include/uv_link_t.h b/include/uv_link_t.h
index a964211..63e2410 100644
--- a/include/uv_link_t.h
+++ b/include/uv_link_t.h
@@ -14,14 +14,15 @@ typedef void (*uv_link_alloc_cb)(uv_link_t* link,
 typedef void (*uv_link_read_cb)(uv_link_t* link,
                                 ssize_t nread,
                                 const uv_buf_t* buf);
-typedef void (*uv_link_write_cb)(uv_link_t* link, int status);
-typedef void (*uv_link_shutdown_cb)(uv_link_t* link, int status);
+typedef void (*uv_link_write_cb)(uv_link_t* source, int status);
+typedef void (*uv_link_shutdown_cb)(uv_link_t* source, int status);
 
 struct uv_link_methods_s {
   int (*read_start)(uv_link_t* link);
   int (*read_stop)(uv_link_t* link);
 
   int (*write)(uv_link_t* link,
+               uv_link_t* source,
                const uv_buf_t bufs[],
                unsigned int nbufs,
                uv_stream_t* send_handle,
@@ -30,7 +31,7 @@ struct uv_link_methods_s {
                    const uv_buf_t bufs[],
                    unsigned int nbufs);
 
-  int (*shutdown)(uv_link_t* link, uv_link_shutdown_cb cb);
+  int (*shutdown)(uv_link_t* link, uv_link_t* source, uv_link_shutdown_cb cb);
 
   /* Overriding callbacks */
   uv_link_alloc_cb alloc_cb_override;
@@ -81,11 +82,12 @@ static int uv_link_read_stop(uv_link_t* link) {
 }
 
 static int uv_link_write(uv_link_t* link,
+                         uv_link_t* source,
                          const uv_buf_t bufs[],
                          unsigned int nbufs,
                          uv_stream_t* send_handle,
                          uv_link_write_cb cb) {
-  return link->methods->write(link, bufs, nbufs, send_handle, cb);
+  return link->methods->write(link, source, bufs, nbufs, send_handle, cb);
 }
 
 
@@ -95,8 +97,10 @@ static int uv_link_try_write(uv_link_t* link,
   return link->methods->try_write(link, bufs, nbufs);
 }
 
-static int uv_link_shutdown(uv_link_t* link, uv_link_shutdown_cb cb) {
-  return link->methods->shutdown(link, cb);
+static int uv_link_shutdown(uv_link_t* link,
+                            uv_link_t* source,
+                            uv_link_shutdown_cb cb) {
+  return link->methods->shutdown(link, source, cb);
 }
 
 /* Link Source */
diff --git a/src/uv_link_observer_t.c b/src/uv_link_observer_t.c
index cb7ec06..07f3dca 100644
--- a/src/uv_link_observer_t.c
+++ b/src/uv_link_observer_t.c
@@ -23,6 +23,7 @@ static int uv_link_observer_read_stop(uv_link_t* link) {
 
 
 static int uv_link_observer_write(uv_link_t* link,
+                                  uv_link_t* source,
                                   const uv_buf_t bufs[],
                                   unsigned int nbufs,
                                   uv_stream_t* send_handle,
@@ -31,7 +32,7 @@ static int uv_link_observer_write(uv_link_t* link,
 
   observer = container_of(link, uv_link_observer_t, link);
 
-  return uv_link_write(observer->target, bufs, nbufs, send_handle, cb);
+  return uv_link_write(observer->target, source, bufs, nbufs, send_handle, cb);
 }
 
 
@@ -46,12 +47,14 @@ static int uv_link_observer_try_write(uv_link_t* link,
 }
 
 
-static int uv_link_observer_shutdown(uv_link_t* link, uv_link_shutdown_cb cb) {
+static int uv_link_observer_shutdown(uv_link_t* link,
+                                     uv_link_t* source,
+                                     uv_link_shutdown_cb cb) {
   uv_link_observer_t* observer;
 
   observer = container_of(link, uv_link_observer_t, link);
 
-  return uv_link_shutdown(observer->target, cb);
+  return uv_link_shutdown(observer->target, source, cb);
 }
 
 
diff --git a/src/uv_link_source_t.c b/src/uv_link_source_t.c
index d648b78..d3d4c3f 100644
--- a/src/uv_link_source_t.c
+++ b/src/uv_link_source_t.c
@@ -71,22 +71,23 @@ static void uv_link_source_wrap_write_cb(uv_write_t* req, int status) {
 
 
 static int uv_link_source_write(uv_link_t* link,
+                                uv_link_t* source,
                                 const uv_buf_t bufs[],
                                 unsigned int nbufs,
                                 uv_stream_t* send_handle,
                                 uv_link_write_cb cb) {
-  uv_link_source_t* source;
+  uv_link_source_t* s;
   uv_link_source_write_t* req;
 
-  source = container_of(link, uv_link_source_t, link);
+  s= container_of(link, uv_link_source_t, link);
   req = malloc(sizeof(*req));
   if (req == NULL)
     return UV_ENOMEM;
 
-  req->link = link;
+  req->link = source;
   req->write_cb = cb;
 
-  return uv_write2(&req->req, source->stream, bufs, nbufs, send_handle,
+  return uv_write2(&req->req, s->stream, bufs, nbufs, send_handle,
                    uv_link_source_wrap_write_cb);
 }
 
@@ -111,21 +112,22 @@ static void uv_link_source_wrap_shutdown_cb(uv_shutdown_t* req, int status) {
 }
 
 
-static int uv_link_source_shutdown(uv_link_t* link, uv_link_shutdown_cb cb) {
-  uv_link_source_t* source;
+static int uv_link_source_shutdown(uv_link_t* link,
+                                   uv_link_t* source,
+                                   uv_link_shutdown_cb cb) {
+  uv_link_source_t* s;
   uv_link_source_shutdown_t* req;
 
-  source = container_of(link, uv_link_source_t, link);
+  s = container_of(link, uv_link_source_t, link);
 
   req = malloc(sizeof(*req));
   if (req == NULL)
     return UV_ENOMEM;
 
-  req->link = link;
+  req->link = source;
   req->shutdown_cb = cb;
 
-  return uv_shutdown(&req->req, source->stream,
-                     uv_link_source_wrap_shutdown_cb);
+  return uv_shutdown(&req->req, s->stream, uv_link_source_wrap_shutdown_cb);
 }
 
 
diff --git a/test/src/test-uv-link-source-t.c b/test/src/test-uv-link-source-t.c
index 404543a..3187aaf 100644
--- a/test/src/test-uv-link-source-t.c
+++ b/test/src/test-uv-link-source-t.c
@@ -38,7 +38,9 @@ static void test_writes() {
 
   /* .write() should work */
   buf = uv_buf_init("x", 1);
-  CHECK_EQ(uv_link_write(&source.link, &buf, 1, NULL, source_write_cb), 0,
+  CHECK_EQ(uv_link_write(&source.link, &source.link, &buf, 1, NULL,
+                         source_write_cb),
+           0,
            "source.link.write() should return 0");
 
   CHECK_EQ(uv_run(loop, UV_RUN_DEFAULT), 0, "uv_run()");