Browse files

node 0.8.x compatibility fixes (libuv api changes in 0.7.x)

  • Loading branch information...
1 parent a252e69 commit a76abb83ab4db707f4dee4bbd13e1487d59dc88f Damian Beresford committed Aug 28, 2012
Showing with 15 additions and 5 deletions.
  1. +2 −2 AUTHORS
  2. +2 −2 README.md
  3. +11 −1 exiv2node.cc
View
4 AUTHORS
@@ -1,4 +1,4 @@
# Ordered by first contribution date
-
+Damian Beresford <dberesford@gmail.com>
Ryan French <frenchrya@gmail.com>
-andrew morton <drewish@katherinehouse.com>
+Andrew Morton <drewish@katherinehouse.com>
View
4 README.md
@@ -7,8 +7,8 @@ asynchronous support for reading & writing image metadata via
## Dependencies
-To build this addon you'll need the Exiv2 library and headers, see
-[their download page](http://www.exiv2.org/download.html) for more information.
+To build this addon you'll need the Exiv2 library and headers. On Debian/Ubuntu, `sudo apt-get install exiv2 libexiv2-dev`. See the
+[Exiv2 download page](http://www.exiv2.org/download.html) for more information.
The tests are written using [Mocha](https://github.com/visionmedia/mocha) and
[Should](https://github.com/visionmedia/should.js).
View
12 exiv2node.cc
@@ -1,6 +1,7 @@
#include <v8.h>
#include <node.h>
#include <node_buffer.h>
+#include <node_version.h>
#include <unistd.h>
#include <string>
#include <map>
@@ -14,6 +15,7 @@ using namespace v8;
// Create a map of strings for passing them back and forth between the V8 and
// worker threads.
typedef std::map<std::string, std::string> tag_map_t;
+uv_async_t g_async;
// Base structure for passing data to and from our libuv workers.
struct Baton {
@@ -24,15 +26,23 @@ struct Baton {
tag_map_t *tags;
Baton(Local<String> fn_, Handle<Function> cb_) {
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_ref((uv_handle_t *) & g_async);
+#else
uv_ref(uv_default_loop());
+#endif
request.data = this;
cb = Persistent<Function>::New(cb_);
fileName = std::string(*String::AsciiValue(fn_));
exifException = std::string();
tags = new tag_map_t();
}
virtual ~Baton() {
- uv_unref(uv_default_loop());
+#if NODE_VERSION_AT_LEAST(0, 7, 9)
+ uv_unref((uv_handle_t *) & g_async);
+#else
+ uv_unref(uv_default_loop());
+#endif
cb.Dispose();
delete tags;
}

0 comments on commit a76abb8

Please sign in to comment.