Skip to content

Instantly share code, notes, and snippets.

/0001-Bla.patch Secret

Created August 27, 2012 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/337256544ca428905b02 to your computer and use it in GitHub Desktop.
Save anonymous/337256544ca428905b02 to your computer and use it in GitHub Desktop.
From 17cad41597f007b6627d0c2e8fb5263b948d1792 Mon Sep 17 00:00:00 2001
From: Bert Belder <bertbelder@gmail.com>
Date: Mon, 27 Aug 2012 17:27:23 +0200
Subject: [PATCH 1/1] Bla
---
src/uv-common.h | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/uv-common.h b/src/uv-common.h
index 4608ee5..d54b051 100644
--- a/src/uv-common.h
+++ b/src/uv-common.h
@@ -59,6 +59,7 @@ enum {
# define UV__HANDLE_INTERNAL 0x80
# define UV__HANDLE_ACTIVE 0x40
# define UV__HANDLE_REF 0x20
+# define UV__HANDLE_CLOSING 0x01
#endif
extern const uv_err_t uv_ok_;
@@ -129,28 +130,40 @@ UNUSED static int uv__is_active(const uv_handle_t* h) {
UNUSED static void uv__handle_start(uv_handle_t* h) {
if (h->flags & UV__HANDLE_ACTIVE) return;
- if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
h->flags |= UV__HANDLE_ACTIVE;
+ if (h->flags & UV__HANDLE_CLOSING) return;
+ if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
}
#define uv__handle_start(h) uv__handle_start((uv_handle_t*)(h))
UNUSED static void uv__handle_stop(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_ACTIVE)) return;
- if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_ACTIVE;
+ if (h->flags & UV__HANDLE_CLOSING) return;
+ if (h->flags & UV__HANDLE_REF) uv__active_handle_rm(h);
}
#define uv__handle_stop(h) uv__handle_stop((uv_handle_t*)(h))
+UNUSED static void uv__handle_closing(uv_handle_t* h) {
+ assert(!(h->flags & UV__HANDLE_CLOSING));
+ h->flags |= UV__HANDLE_CLOSING;
+ if (h->flags & UV__HANDLE_ACTIVE) return;
+ if (h->flags & UV__HANDLE_REF) uv__active_handle_add(h);
+}
+#define uv__handle_closing(h) uv__handle_closing((uv_handle_t*)(h))
+
UNUSED static void uv__handle_ref(uv_handle_t* h) {
if (h->flags & UV__HANDLE_REF) return;
- if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_add(h);
+ if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
+ uv__active_handle_add(h);
h->flags |= UV__HANDLE_REF;
}
#define uv__handle_ref(h) uv__handle_ref((uv_handle_t*)(h))
UNUSED static void uv__handle_unref(uv_handle_t* h) {
if (!(h->flags & UV__HANDLE_REF)) return;
- if (h->flags & UV__HANDLE_ACTIVE) uv__active_handle_rm(h);
+ if (h->flags & (UV__HANDLE_ACTIVE | UV__HANDLE_CLOSING))
+ uv__active_handle_rm(h);
h->flags &= ~UV__HANDLE_REF;
}
#define uv__handle_unref(h) uv__handle_unref((uv_handle_t*)(h))
--
1.7.11.msysgit.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment