optimized pypy environ helper

This commit is contained in:
Unbit
2013-05-18 19:45:18 +02:00
parent dd4b2e8bc2
commit 22da8d9ba2
2 changed files with 12 additions and 38 deletions
+3 -26
View File
@@ -47,33 +47,10 @@ int uwsgi_pypy_helper_register_rpc(char *name, int argc, void *func) {
return uwsgi_register_rpc(name, &pypy_plugin, argc, func);
}
int uwsgi_pypy_helper_vars(int core) {
struct iovec *uwsgi_pypy_helper_environ(int core, uint16_t *len) {
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[core].req;
return wsgi_req->var_cnt;
}
char *uwsgi_pypy_helper_key(int core, int pos) {
uwsgi_log("[key] core = %d pos = %d\n", core, pos);
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[core].req;
return wsgi_req->hvec[pos].iov_base;
}
int uwsgi_pypy_helper_keylen(int core, int pos) {
uwsgi_log("[keylen] core = %d pos = %d\n", core, pos);
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[core].req;
return wsgi_req->hvec[pos].iov_len;
}
char *uwsgi_pypy_helper_val(int core, int pos) {
uwsgi_log("[val] core = %d pos = %d\n", core, pos);
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[core].req;
return wsgi_req->hvec[pos+1].iov_base;
}
int uwsgi_pypy_helper_vallen(int core, int pos) {
uwsgi_log("[vallen] core = %d pos = %d\n", core, pos);
struct wsgi_request *wsgi_req = &uwsgi.workers[uwsgi.mywid].cores[core].req;
return wsgi_req->hvec[pos+1].iov_len;
*len = wsgi_req->var_cnt;
return wsgi_req->hvec;
}
void uwsgi_pypy_helper_status(int core, char *status, int status_len) {
+9 -12
View File
@@ -12,13 +12,12 @@ void free(void *);
void (*uwsgi_pypy_hook_loader)(char *);
void (*uwsgi_pypy_hook_request)(int);
char *uwsgi_pypy_helper_key(int, int);
int uwsgi_pypy_helper_keylen(int, int);
struct iovec {
char *iov_base;
uint64_t iov_len;
};
char *uwsgi_pypy_helper_val(int, int);
int uwsgi_pypy_helper_vallen(int, int);
int uwsgi_pypy_helper_vars(int);
struct iovec *uwsgi_pypy_helper_environ(int, uint16_t *);
void uwsgi_pypy_helper_status(int, char *, int);
void uwsgi_pypy_helper_header(int, char *, int, char *, int);
@@ -67,12 +66,10 @@ def uwsgi_pypy_wsgi_handler(core):
pass
environ = {}
n = lib.uwsgi_pypy_helper_vars(core)
print "[n] core = %d vars = %d" % (core, n)
for i in range(0, n, 2):
key = ffi.string( lib.uwsgi_pypy_helper_key(core, i), lib.uwsgi_pypy_helper_keylen(core, i) )
value = ffi.string( lib.uwsgi_pypy_helper_val(core, i), lib.uwsgi_pypy_helper_vallen(core, i) )
environ[key] = value
nv = ffi.new("uint16_t *")
iov = lib.uwsgi_pypy_helper_environ(core, nv)
for i in range(0, nv[0], 2):
environ[ffi.string(iov[i].iov_base, iov[i].iov_len)] = ffi.string(iov[i+1].iov_base, iov[i+1].iov_len)
environ['wsgi.version'] = (1, 0)
scheme = 'http'