Author: Armin Rigo <[email protected]>
Branch: errno-again
Changeset: r75430:6eda442d4d39
Date: 2015-01-18 23:41 +0100
http://bitbucket.org/pypy/pypy/changeset/6eda442d4d39/
Log: Try to fix Windows test failures by also saving WSAGetLastError()
using the same mechanism.
diff --git a/rpython/jit/backend/x86/callbuilder.py
b/rpython/jit/backend/x86/callbuilder.py
--- a/rpython/jit/backend/x86/callbuilder.py
+++ b/rpython/jit/backend/x86/callbuilder.py
@@ -242,9 +242,14 @@
mc.MOV32_rm(edi.value, (edi.value, 0))
mc.MOV32_mr((tlofsreg.value, rpy_errno), edi.value)
- if handle_lasterror and (save_err & rffi.RFFI_SAVE_LASTERROR):
- from rpython.rlib.rwin32 import _GetLastError
- GetLastError_addr = self.asm.cpu.cast_ptr_to_int(_GetLastError)
+ if handle_lasterror and (save_err & (rffi.RFFI_SAVE_LASTERROR |
+ rffi.RFFI_SAVE_WSALASTERROR)):
+ if save_err & rffi.RFFI_SAVE_LASTERROR:
+ from rpython.rlib.rwin32 import _GetLastError
+ GetLastError_addr = self.asm.cpu.cast_ptr_to_int(_GetLastError)
+ else:
+ from rpython.rlib._rsocket_rffi import _WSAGetLastError as WSAE
+ GetLastError_addr = self.asm.cpu.cast_ptr_to_int(WSAE)
assert isinstance(self, CallBuilder32) # Windows 32-bit only
#
rpy_lasterror = llerrno.get_rpy_lasterror_offset(self.asm.cpu)
diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -462,7 +462,7 @@
if WIN32:
WSAEVENT = cConfig.WSAEVENT
WSANETWORKEVENTS = cConfig.WSANETWORKEVENTS
- SAVE_ERR = rffi.RFFI_ERR_NONE
+ SAVE_ERR = rffi.RFFI_SAVE_WSALASTERROR
else:
SAVE_ERR = rffi.RFFI_SAVE_ERRNO
timeval = cConfig.timeval
@@ -660,14 +660,14 @@
WSAStartup = external('WSAStartup', [rwin32.WORD, lltype.Ptr(WSAData)],
rffi.INT)
- WSAGetLastError = external('WSAGetLastError', [], rffi.INT,
releasegil=False)
- geterrno = WSAGetLastError
+ _WSAGetLastError = external('WSAGetLastError', [], rffi.INT,
+ _nowrapper=True, sandboxsafe=True)
+
+ geterrno = rwin32.GetLastError_saved
# In tests, the first call to GetLastError is always wrong, because error
# is hidden by operations in ll2ctypes. Call it now.
- WSAGetLastError()
-
- from rpython.rlib import rwin32
+ _WSAGetLastError()
def socket_strerror_str(errno):
return rwin32.FormatError(errno)
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -126,12 +126,17 @@
@specialize.call_location()
def _errno_after(save_err):
- if WIN32 and (save_err & rffi.RFFI_SAVE_LASTERROR):
- from rpython.rlib import rthread, rwin32
- err = rwin32._GetLastError()
- # careful, setraw() overwrites GetLastError.
- # We must read it first, before the errno handling.
- rthread.tlfield_rpy_lasterror.setraw(err)
+ if WIN32:
+ if save_err & rffi.RFFI_SAVE_LASTERROR:
+ from rpython.rlib import rthread, rwin32
+ err = rwin32._GetLastError()
+ # careful, setraw() overwrites GetLastError.
+ # We must read it first, before the errno handling.
+ rthread.tlfield_rpy_lasterror.setraw(err)
+ elif save_err & rffi.RFFI_SAVE_WSALASTERROR:
+ from rpython.rlib import rthread, _rsocket_rffi
+ err = _rsocket_rffi._WSAGetLastError()
+ rthread.tlfield_rpy_lasterror.setraw(err)
if save_err & rffi.RFFI_SAVE_ERRNO:
from rpython.rlib import rthread
rthread.tlfield_rpy_errno.setraw(_get_errno())
diff --git a/rpython/rtyper/lltypesystem/rffi.py
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -66,6 +66,7 @@
RFFI_FULL_ERRNO_ZERO = RFFI_SAVE_ERRNO | RFFI_ZERO_ERRNO_BEFORE
RFFI_SAVE_LASTERROR = 8 # win32: save GetLastError() after the call
RFFI_READSAVED_LASTERROR = 16 # win32: call SetLastError() before the call
+RFFI_SAVE_WSALASTERROR = 32 # win32: save WSAGetLastError() after the call
RFFI_FULL_LASTERROR = RFFI_SAVE_LASTERROR | RFFI_READSAVED_LASTERROR
RFFI_ERR_NONE = 0
RFFI_ERR_ALL = RFFI_FULL_ERRNO | RFFI_FULL_LASTERROR
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit