YoSTEALTH / Liburing

Liburing is Python + Cython wrapper around C Liburing, which is a helper to setup and tear-down io_uring instances.
https://pypi.org/project/liburing/
Creative Commons Zero v1.0 Universal
98 stars 3 forks source link

"void * user_data" param of Python layer "io_uring_prep_cancel" #11

Closed openalmeida closed 3 years ago

openalmeida commented 3 years ago

Hi,

an additional CFFI transfer is required to suit for the clang layer void *user_data define ?

# python
liburing.io_uring_prep_cancel(sqe, ???, 0)  # to cancel a socket ACCEPT sqe
                                            # e.g sqe.user_data = 1, how to transfer it to type "void *" 
// clang
static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe, void *user_data, int flags);
openalmeida commented 3 years ago

got it from the ffi cast api

liburing.io_uring_prep_cancel(sqe, liburing.helper.cast("void *", user_data), 0)
YoSTEALTH commented 3 years ago

@openalmeida thanks for point this out. user_data is used in few different places and it should be __u64 not sure why they are using void * in few functions

YoSTEALTH commented 3 years ago

@openalmeida Have you tried

liburing.io_uring_prep_cancel(sqe, user_data, 0)

I think this should work as well! As long as user_data type is int

openalmeida commented 3 years ago

@openalmeida Have you tried

liburing.io_uring_prep_cancel(sqe, user_data, 0)

I think this should work as well! As long as user_data type is int

Yes I have. It will case cffi "void *" dismatch "int" error:

TypeError: initializer for ctype 'void *' must be a cdata pointer, not int

the way of working for me is below which commented 8 days ago.

got it from the ffi cast api

liburing.io_uring_prep_cancel(sqe, liburing.helper.cast("void *", user_data), 0)
YoSTEALTH commented 3 years ago

@openalmeida I ended up creating wrapper functions to help with proper type used for user_data https://github.com/YoSTEALTH/Liburing/commit/17ae3317a74a31a389a20bfd68f3a588e9cab19a adapt your code accordingly