mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 21:51:30 +00:00
fixed goroutines support
This commit is contained in:
@@ -4,7 +4,7 @@ extern struct uwsgi_server uwsgi;
|
||||
|
||||
void (*uwsgi_go_helper_post_fork_c)();
|
||||
void (*uwsgi_go_helper_post_init_c)();
|
||||
void * (*uwsgi_go_helper_env_new_c)();
|
||||
void * (*uwsgi_go_helper_env_new_c)(struct wsgi_request *);
|
||||
void (*uwsgi_go_helper_env_add_c)(void *, char *, int, char *, int);
|
||||
void (*uwsgi_go_helper_request_c)(void *, struct wsgi_request *);
|
||||
int (*uwsgi_go_helper_signal_handler_c)(int, void *);
|
||||
@@ -28,7 +28,9 @@ struct uwsgi_option uwsgi_go_options[] = {
|
||||
};
|
||||
|
||||
int uwsgi_go_init() {
|
||||
|
||||
// build the functions table
|
||||
|
||||
uwsgi_go_helper_post_fork_c = dlsym(RTLD_DEFAULT, "uwsgi_go_helper_post_fork");
|
||||
if (!uwsgi_go_helper_post_fork_c) { uwsgi_log("[uwsgi-go] unable to load uwsgi_go_helper_post_fork function\n"); exit(1); }
|
||||
|
||||
@@ -67,15 +69,16 @@ int uwsgi_go_request(struct wsgi_request *wsgi_req) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *env = uwsgi_go_helper_env_new_c();
|
||||
wsgi_req->async_environ = uwsgi_go_helper_env_new_c(wsgi_req);
|
||||
int i;
|
||||
for(i=0;i<wsgi_req->var_cnt;i++) {
|
||||
uwsgi_go_helper_env_add_c(env, wsgi_req->hvec[i].iov_base, wsgi_req->hvec[i].iov_len,
|
||||
uwsgi_go_helper_env_add_c(wsgi_req->async_environ, wsgi_req->hvec[i].iov_base, wsgi_req->hvec[i].iov_len,
|
||||
wsgi_req->hvec[i+1].iov_base, wsgi_req->hvec[i+1].iov_len);
|
||||
i++;
|
||||
}
|
||||
|
||||
uwsgi_go_helper_request_c(env, wsgi_req);
|
||||
|
||||
uwsgi_go_helper_request_c(wsgi_req->async_environ, wsgi_req);
|
||||
|
||||
return UWSGI_OK;
|
||||
}
|
||||
@@ -95,8 +98,7 @@ void goroutines_loop() {
|
||||
for (i = 1; i < uwsgi.async; i++) {
|
||||
uwsgi_go_helper_run_core_c(i);
|
||||
}
|
||||
long y = 0;
|
||||
simple_loop_run((void *) y);
|
||||
simple_loop_run_int(0);
|
||||
}
|
||||
|
||||
void uwsgi_go_on_load() {
|
||||
|
||||
@@ -34,6 +34,8 @@ type AppInterface interface {
|
||||
// global instance
|
||||
var uwsgi_instance AppInterface
|
||||
var uwsgi_modifier1 int = -1;
|
||||
var uwsgi_env_gc = make(map[*C.struct_wsgi_request](*map[string]string))
|
||||
var uwsgi_signals_gc = make([]*func(int), 256)
|
||||
|
||||
type App struct {
|
||||
}
|
||||
@@ -86,6 +88,7 @@ func (app *App) RegisterSignal(signum int, who string, handler func(int)) bool {
|
||||
}
|
||||
}
|
||||
if int(C.uwsgi_register_signal(C.uint8_t(signum), C.CString(who), unsafe.Pointer(&handler), C.uint8_t(uwsgi_modifier1))) == 0 {
|
||||
uwsgi_signals_gc[signum] = &handler
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -115,9 +118,10 @@ func uwsgi_go_helper_post_init() {
|
||||
}
|
||||
|
||||
//export uwsgi_go_helper_env_new
|
||||
func uwsgi_go_helper_env_new() *map[string]string {
|
||||
func uwsgi_go_helper_env_new(wsgi_req *C.struct_wsgi_request) *map[string]string {
|
||||
var env map[string]string
|
||||
env = make(map[string]string)
|
||||
uwsgi_env_gc[wsgi_req] = &env
|
||||
return &env
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user