mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 21:51:30 +00:00
backported pypy fixes from 2.1
This commit is contained in:
+12
-12
@@ -393,7 +393,7 @@ class WSGIinput(object):
|
||||
rlen = ffi.new('ssize_t*')
|
||||
chunk = lib.uwsgi_request_body_read(self.wsgi_req, size, rlen)
|
||||
if chunk != ffi.NULL:
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
if rlen[0] < 0:
|
||||
raise IOError("error reading wsgi.input")
|
||||
raise IOError("error waiting for wsgi.input")
|
||||
@@ -402,7 +402,7 @@ class WSGIinput(object):
|
||||
rlen = ffi.new('ssize_t*')
|
||||
chunk = lib.uwsgi_request_body_readline(self.wsgi_req, hint, rlen)
|
||||
if chunk != ffi.NULL:
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
if rlen[0] < 0:
|
||||
raise IOError("error reading line from wsgi.input")
|
||||
raise IOError("error waiting for line on wsgi.input")
|
||||
@@ -521,7 +521,7 @@ class uwsgi_pypy_RPC(object):
|
||||
def __call__(self, argc, argv, argvs, buf):
|
||||
pargs = []
|
||||
for i in range(0, argc):
|
||||
pargs.append(ffi.string(argv[i], argvs[i]))
|
||||
pargs.append(ffi.buffer(argv[i], argvs[i])[:])
|
||||
response = self.func(*pargs)
|
||||
if len(response) > 0:
|
||||
buf[0] = lib.uwsgi_malloc(len(response))
|
||||
@@ -560,7 +560,7 @@ def uwsgi_pypy_rpc(node, func, *args):
|
||||
|
||||
response = lib.uwsgi_do_rpc(c_node, ffi.new("char[]",func), argc, argv, argvs, rsize)
|
||||
if response:
|
||||
ret = ffi.string(response, rsize[0])
|
||||
ret = ffi.buffer(response, rsize[0])[:]
|
||||
lib.free(response)
|
||||
return ret
|
||||
return None
|
||||
@@ -587,7 +587,7 @@ def uwsgi_pypy_uwsgi_cache_get(key, cache=ffi.NULL):
|
||||
value = lib.uwsgi_cache_magic_get(key, len(key), vallen, ffi.NULL, cache)
|
||||
if value == ffi.NULL:
|
||||
return None
|
||||
ret = ffi.string(value, vallen[0])
|
||||
ret = ffi.buffer(value, vallen[0])[:]
|
||||
libc.free(value)
|
||||
return ret
|
||||
uwsgi.cache_get = uwsgi_pypy_uwsgi_cache_get
|
||||
@@ -617,8 +617,9 @@ def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
|
||||
uci = ffi.new('struct uwsgi_cache_item **')
|
||||
while True:
|
||||
uci[0] = lib.uwsgi_cache_keys(uc, pos, uci)
|
||||
if uci[0] == ffi.NULL: break
|
||||
l.append(ffi.string(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize))
|
||||
if uci[0] == ffi.NULL:
|
||||
break
|
||||
l.append(ffi.buffer(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize)[:])
|
||||
lib.uwsgi_cache_rwunlock(uc)
|
||||
return l
|
||||
uwsgi.cache_keys = uwsgi_pypy_uwsgi_cache_keys
|
||||
@@ -849,7 +850,7 @@ def uwsgi_pypy_websocket_recv():
|
||||
ub = lib.uwsgi_websocket_recv(wsgi_req);
|
||||
if ub == ffi.NULL:
|
||||
raise IOError("unable to receive websocket message")
|
||||
ret = ffi.string(ub.buf, ub.pos)
|
||||
ret = ffi.buffer(ub.buf, ub.pos)[:]
|
||||
lib.uwsgi_buffer_destroy(ub)
|
||||
return ret
|
||||
uwsgi.websocket_recv = uwsgi_pypy_websocket_recv
|
||||
@@ -862,7 +863,7 @@ def uwsgi_pypy_websocket_recv_nb():
|
||||
ub = lib.uwsgi_websocket_recv_nb(wsgi_req);
|
||||
if ub == ffi.NULL:
|
||||
raise IOError("unable to receive websocket message")
|
||||
ret = ffi.string(ub.buf, ub.pos)
|
||||
ret = ffi.buffer(ub.buf, ub.pos)[:]
|
||||
lib.uwsgi_buffer_destroy(ub)
|
||||
return ret
|
||||
uwsgi.websocket_recv_nb = uwsgi_pypy_websocket_recv_nb
|
||||
@@ -897,7 +898,7 @@ def uwsgi_pypy_chunked_read(timeout=0):
|
||||
chunk = lib.uwsgi_chunked_read(wsgi_req, rlen, timeout, 0)
|
||||
if chunk == ffi.NULL:
|
||||
raise IOError("unable to receive chunked part")
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
uwsgi.chunked_read = uwsgi_pypy_chunked_read
|
||||
|
||||
"""
|
||||
@@ -911,8 +912,7 @@ def uwsgi_pypy_chunked_read_nb():
|
||||
if lib.uwsgi_is_again() > 0:
|
||||
return None
|
||||
raise IOError("unable to receive chunked part")
|
||||
|
||||
return ffi.string(chunk, rlen[0])
|
||||
return ffi.buffer(chunk, rlen[0])[:]
|
||||
uwsgi.chunked_read_nb = uwsgi_pypy_chunked_read_nb
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user