Skip to content

Commit d33861b

Browse files
committed
avoid C API calls in checking ipc max length
can't define module global C types
1 parent 66da3db commit d33861b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

zmq/backend/cython/_externs.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cdef extern from "mutex.h" nogil:
77
cdef int mutex_unlock(mutex_t*)
88

99
cdef extern from "getpid_compat.h":
10-
int getpid()
10+
cdef int getpid()
1111

1212
cdef extern from "ipcmaxlen.h":
13-
int get_ipc_path_max_len()
13+
cdef int get_ipc_path_max_len()

zmq/backend/cython/_zmq.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
_check_version,
157157
)
158158

159-
IPC_PATH_MAX_LEN = get_ipc_path_max_len()
159+
IPC_PATH_MAX_LEN: int = get_ipc_path_max_len()
160160

161161

162162
@cfunc
@@ -925,10 +925,11 @@ def bind(self, addr: str | bytes):
925925
rc: C.int = zmq_bind(self.handle, c_addr)
926926
if rc != 0:
927927
_errno: C.int = _zmq_errno()
928-
if IPC_PATH_MAX_LEN and _errno == ENAMETOOLONG:
928+
_ipc_max: C.int = get_ipc_path_max_len()
929+
if _ipc_max and _errno == ENAMETOOLONG:
929930
path = addr.split('://', 1)[-1]
930931
msg = (
931-
f'ipc path "{path}" is longer than {IPC_PATH_MAX_LEN} '
932+
f'ipc path "{path}" is longer than {_ipc_max} '
932933
'characters (sizeof(sockaddr_un.sun_path)). '
933934
'zmq.IPC_PATH_MAX_LEN constant can be used '
934935
'to check addr length (if it is defined).'

0 commit comments

Comments
 (0)