You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2014/09/17 22:18:45 UTC
svn commit: r1625801 - in /qpid/proton/trunk/proton-c:
bindings/python/cproton.i bindings/python/proton.py include/proton/object.h
src/object/object.c
Author: rhs
Date: Wed Sep 17 20:18:44 2014
New Revision: 1625801
URL: http://svn.apache.org/r1625801
Log:
fixed refcounting bug for posting python objects to a collector
Modified:
qpid/proton/trunk/proton-c/bindings/python/cproton.i
qpid/proton/trunk/proton-c/bindings/python/proton.py
qpid/proton/trunk/proton-c/include/proton/object.h
qpid/proton/trunk/proton-c/src/object/object.c
Modified: qpid/proton/trunk/proton-c/bindings/python/cproton.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/cproton.i?rev=1625801&r1=1625800&r2=1625801&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/cproton.i (original)
+++ qpid/proton/trunk/proton-c/bindings/python/cproton.i Wed Sep 17 20:18:44 2014
@@ -227,7 +227,38 @@ bool pn_ssl_get_protocol_name(pn_ssl_t *
int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
%ignore pn_ssl_get_peer_hostname;
+%immutable PN_PYREF;
%inline %{
+ PN_EXTERN extern const pn_class_t *PN_PYREF;
+
+ #define CID_pn_pyref CID_pn_void
+ #define pn_pyref_new NULL
+ #define pn_pyref_initialize NULL
+ #define pn_pyref_finalize NULL
+ #define pn_pyref_free NULL
+ #define pn_pyref_hashcode pn_void_hashcode
+ #define pn_pyref_compare pn_void_compare
+ #define pn_pyref_inspect pn_void_inspect
+
+ static void pn_pyref_incref(void *object) {
+ Py_XINCREF(object);
+ }
+
+ static void pn_pyref_decref(void *object) {
+ Py_XDECREF(object);
+ }
+
+ static int pn_pyref_refcount(void *object) {
+ return 1;
+ }
+
+ static const pn_class_t *pn_pyref_reify(void *object) {
+ return PN_PYREF;
+ }
+
+ PN_EXTERN const pn_class_t PNI_PYREF = PN_METACLASS(pn_pyref);
+ PN_EXTERN const pn_class_t *PN_PYREF = &PNI_PYREF;
+
void *pn_py2void(PyObject *object) {
return object;
}
Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1625801&r1=1625800&r2=1625801&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/trunk/proton-c/bindings/python/proton.py Wed Sep 17 20:18:44 2014
@@ -3323,6 +3323,7 @@ class SSLSessionDetails(object):
wrappers = {
"pn_void": lambda x: pn_void2py(x),
+ "pn_pyref": lambda x: pn_void2py(x),
"pn_connection": lambda x: Connection._wrap_connection(pn_cast_pn_connection(x)),
"pn_session": lambda x: Session._wrap_session(pn_cast_pn_session(x)),
"pn_link": lambda x: Link._wrap_link(pn_cast_pn_link(x)),
@@ -3337,7 +3338,7 @@ class Collector:
self._contexts = set()
def put(self, obj, etype):
- pn_collector_put(self._impl, PN_VOID, pn_py2void(obj), etype)
+ pn_collector_put(self._impl, PN_PYREF, pn_py2void(obj), etype)
def peek(self):
event = pn_collector_peek(self._impl)
Modified: qpid/proton/trunk/proton-c/include/proton/object.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/object.h?rev=1625801&r1=1625800&r2=1625801&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/object.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/object.h Wed Sep 17 20:18:44 2014
@@ -109,6 +109,10 @@ PN_EXTERN intptr_t pn_class_compare(cons
PN_EXTERN bool pn_class_equals(const pn_class_t *clazz, void *a, void *b);
PN_EXTERN int pn_class_inspect(const pn_class_t *clazz, void *object, pn_string_t *dst);
+PN_EXTERN uintptr_t pn_void_hashcode(void *object);
+PN_EXTERN intptr_t pn_void_compare(void *a, void *b);
+PN_EXTERN int pn_void_inspect(void *object, pn_string_t *dst);
+
PN_EXTERN void *pn_object_new(const pn_class_t *clazz, size_t size);
PN_EXTERN const pn_class_t *pn_object_reify(void *object);
PN_EXTERN void pn_object_incref(void *object);
Modified: qpid/proton/trunk/proton-c/src/object/object.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/object/object.c?rev=1625801&r1=1625800&r2=1625801&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/object/object.c (original)
+++ qpid/proton/trunk/proton-c/src/object/object.c Wed Sep 17 20:18:44 2014
@@ -40,9 +40,9 @@ static int pn_void_refcount(void *object
#define pn_void_finalize NULL
static void pn_void_free(void *object) { free(object); }
static const pn_class_t *pn_void_reify(void *object) { return PN_VOID; }
-static uintptr_t pn_void_hashcode(void *object) { return (uintptr_t) object; }
-static intptr_t pn_void_compare(void *a, void *b) { return (intptr_t) b - (intptr_t) a; }
-static int pn_void_inspect(void *object, pn_string_t *dst) { return pn_string_addf(dst, "%p", object); }
+uintptr_t pn_void_hashcode(void *object) { return (uintptr_t) object; }
+intptr_t pn_void_compare(void *a, void *b) { return (intptr_t) b - (intptr_t) a; }
+int pn_void_inspect(void *object, pn_string_t *dst) { return pn_string_addf(dst, "%p", object); }
const pn_class_t PNI_VOID = PN_METACLASS(pn_void);
const pn_class_t *PN_VOID = &PNI_VOID;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org