added vassal's plugin hooks

This commit is contained in:
Unbit
2014-08-28 18:09:02 +02:00
parent 8cd13f2ad9
commit bcf1f46d33
2 changed files with 32 additions and 1 deletions
+26 -1
View File
@@ -1093,7 +1093,20 @@ int uwsgi_emperor_vassal_start(struct uwsgi_instance *n_ui) {
}
static void uwsgi_emperor_spawn_vassal(struct uwsgi_instance *n_ui) {
int i;
// run plugin hooks for the vassal
for (i = 0; i < 256; i++) {
if (uwsgi.p[i]->vassal) {
uwsgi.p[i]->vassal(n_ui);
}
}
for (i = 0; i < uwsgi.gp_cnt; i++) {
if (uwsgi.gp[i]->vassal) {
uwsgi.gp[i]->vassal(n_ui);
}
}
#ifdef __linux__
if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0)) {
@@ -1350,7 +1363,6 @@ static void uwsgi_emperor_spawn_vassal(struct uwsgi_instance *n_ui) {
}
// close all of the unneded fd
int i;
for (i = 3; i < (int) uwsgi.max_fd; i++) {
if (uwsgi_fd_is_safe(i))
continue;
@@ -1429,6 +1441,19 @@ static void uwsgi_emperor_spawn_vassal(struct uwsgi_instance *n_ui) {
func(n_ui->name, n_ui->uid, n_ui->gid);
}
// ->vassal_before_exec
for (i = 0; i < 256; i++) {
if (uwsgi.p[i]->vassal_before_exec) {
uwsgi.p[i]->vassal_before_exec(n_ui);
}
}
for (i = 0; i < uwsgi.gp_cnt; i++) {
if (uwsgi.gp[i]->vassal) {
uwsgi.gp[i]->vassal_before_exec(n_ui);
}
}
// start !!!
if (execvp(vassal_argv[0], vassal_argv)) {
uwsgi_error("execvp()");
+6
View File
@@ -6,6 +6,8 @@
extern "C" {
#endif
#define UWSGI_PLUGIN_API 1
#define UMAX16 65536
#define UMAX8 256
@@ -1000,6 +1002,7 @@ struct uwsgi_protocol {
};
struct uwsgi_server;
struct uwsgi_instance;
struct uwsgi_plugin {
@@ -1058,6 +1061,9 @@ struct uwsgi_plugin {
struct uwsgi_buffer* (*exception_msg)(struct wsgi_request *);
struct uwsgi_buffer* (*exception_repr)(struct wsgi_request *);
void (*exception_log)(struct wsgi_request *);
void (*vassal)(struct uwsgi_instance *);
void (*vassal_before_exec)(struct uwsgi_instance *);
};
#ifdef UWSGI_PCRE