Skip to content

Commit

Permalink
Merge pull request #33 from mosquito/fdsync-only-on-linux-for-thread-…
Browse files Browse the repository at this point in the history
…pool

Add define for HAVE_FDATASYNC for threadpool and bump to 0.9.21
  • Loading branch information
mosquito authored Jan 12, 2025
2 parents 5557acf + 4f37207 commit 6e60f2c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions caio/linux_aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,8 @@ static PyModuleDef linux_aio_module = {


PyMODINIT_FUNC PyInit_linux_aio(void) {
Py_Initialize();

struct utsname uname_data;

if (uname(&uname_data)) {
Expand Down
11 changes: 8 additions & 3 deletions caio/thread_aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ AIOContext_init(AIOContext *self, PyObject *args, PyObject *kwds)
return -1;
}

if (self->max_requests > MAX_QUEUE) {
if (self->max_requests >= (MAX_QUEUE - 1)) {
PyErr_Format(
PyExc_ValueError,
"max_requests too large. Allowed lower then %d",
MAX_QUEUE
MAX_QUEUE - 1
);
return -1;
}
Expand Down Expand Up @@ -170,8 +170,13 @@ void worker(void *arg) {
result = fsync(fileno);
break;
case THAIO_FDSYNC:
#ifdef HAVE_FDATASYNC
result = fdatasync(fileno);
#else
result = fsync(fileno);
#endif
break;

case THAIO_READ:
result = pread(fileno, buf, buf_size, offset);
break;
Expand Down Expand Up @@ -803,7 +808,7 @@ static PyModuleDef thread_aio_module = {


PyMODINIT_FUNC PyInit_thread_aio(void) {
PyEval_InitThreads();
Py_Initialize();

PyObject *m;

Expand Down
2 changes: 1 addition & 1 deletion caio/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

team_email = author_info[0][1]

version_info = (0, 9, 20)
version_info = (0, 9, 21)

__author__ = ", ".join("{} <{}>".format(*info) for info in author_info)
__version__ = ".".join(map(str, version_info))
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"{}/thread_aio.c".format(module_name),
"{}/src/threadpool/threadpool.c".format(module_name),
],
extra_compile_args=["-g"],
extra_compile_args=["-g", "-DHAVE_FDATASYNC"],
),
)
elif "darwin" in OS_NAME:
Expand All @@ -34,7 +34,7 @@
"{}/thread_aio.c".format(module_name),
"{}/src/threadpool/threadpool.c".format(module_name),
],
extra_compile_args=["-g", "-Wno-implicit-function-declaration"],
extra_compile_args=["-g"],
),
)
if "linux" in OS_NAME:
Expand Down

0 comments on commit 6e60f2c

Please sign in to comment.