comparison mercurial/pure/osutil.py @ 27971:f7d0c28d34b3 stable

osutil: do not abort loading pure module just because libc has no recvmsg() On Solaris, recvmsg() is provided by libsocket.so. We could try hard to look for the library which provides 'recvmsg' symbol, but it would make little sense now since recvfds() won't work anyway on Solaris. So this patch just disables _recvmsg() on such platforms. Thanks to FUJIWARA Katsunori for spotting this problem.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 03 Feb 2016 22:47:27 +0900
parents 051b0dcec98b
children 7a157639b8f2
comparison
equal deleted inserted replaced
27970:3d23700cf4a9 27971:f7d0c28d34b3
102 ('cmsg_type', ctypes.c_int), 102 ('cmsg_type', ctypes.c_int),
103 ('cmsg_data', ctypes.c_ubyte * 0), 103 ('cmsg_data', ctypes.c_ubyte * 0),
104 ] 104 ]
105 105
106 _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) 106 _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
107 _recvmsg = _libc.recvmsg 107 _recvmsg = getattr(_libc, 'recvmsg', None)
108 _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long) 108 if _recvmsg:
109 _recvmsg.argtypes = (ctypes.c_int, ctypes.POINTER(_msghdr), ctypes.c_int) 109 _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long)
110 _recvmsg.argtypes = (ctypes.c_int, ctypes.POINTER(_msghdr),
111 ctypes.c_int)
112 else:
113 # recvmsg isn't always provided by libc; such systems are unsupported
114 def _recvmsg(sockfd, msg, flags):
115 raise NotImplementedError('unsupported platform')
110 116
111 def _CMSG_FIRSTHDR(msgh): 117 def _CMSG_FIRSTHDR(msgh):
112 if msgh.msg_controllen < ctypes.sizeof(_cmsghdr): 118 if msgh.msg_controllen < ctypes.sizeof(_cmsghdr):
113 return 119 return
114 cmsgptr = ctypes.cast(msgh.msg_control, ctypes.POINTER(_cmsghdr)) 120 cmsgptr = ctypes.cast(msgh.msg_control, ctypes.POINTER(_cmsghdr))