Using CSTRZ mapping type for go executable.

This commit is contained in:
Max Romanov
2017-09-05 10:22:45 -07:00
parent f1685e371f
commit 1429cacd17
3 changed files with 6 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ typedef struct {
typedef struct { typedef struct {
nxt_str_t executable; char *executable;
} nxt_go_app_conf_t; } nxt_go_app_conf_t;

View File

@@ -38,7 +38,6 @@ nxt_sock_no_cloexec(nxt_socket_t fd)
static nxt_int_t static nxt_int_t
nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf) nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
{ {
char *go_path;
char *argv[2]; char *argv[2];
u_char buf[256]; u_char buf[256];
u_char *p; u_char *p;
@@ -86,16 +85,13 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
setenv("NXT_GO_PORTS", (char *)buf, 1); setenv("NXT_GO_PORTS", (char *)buf, 1);
go_path = malloc(c->executable.length + 1); argv[0] = c->executable;
nxt_memcpy(go_path, c->executable.start, c->executable.length);
go_path[c->executable.length] = '\0';
argv[0] = go_path;
argv[1] = NULL; argv[1] = NULL;
(void) execve(go_path, argv, environ); (void) execve(c->executable, argv, environ);
nxt_log(task, NXT_LOG_WARN, "execve(%s) failed %E", go_path, nxt_errno); nxt_log(task, NXT_LOG_WARN, "execve(%s) failed %E", c->executable,
nxt_errno);
return NXT_ERROR; return NXT_ERROR;
} }

View File

@@ -148,7 +148,7 @@ static nxt_conf_map_t nxt_common_app_conf[] = {
{ {
nxt_string("executable"), nxt_string("executable"),
NXT_CONF_MAP_STR, NXT_CONF_MAP_CSTRZ,
offsetof(nxt_common_app_conf_t, u.go.executable), offsetof(nxt_common_app_conf_t, u.go.executable),
}, },
}; };