Browse Source

Fix #1054

pull/1060/head
Max Lv 8 years ago
parent
commit
51135c9184
3 changed files with 29 additions and 21 deletions
  1. 28
      src/local.c
  2. 17
      src/plugin.c
  3. 5
      src/tunnel.c

28
src/local.c

@ -110,9 +110,9 @@ static int fast_open = 0;
static struct ev_signal sigint_watcher;
static struct ev_signal sigterm_watcher;
static struct ev_signal sigchld_watcher;
#ifndef __MINGW32__
struct ev_signal sigusr1_watcher;
static struct ev_signal sigchld_watcher;
static struct ev_signal sigusr1_watcher;
#endif
#ifdef HAVE_SETRLIMIT
@ -1130,17 +1130,17 @@ signal_cb(EV_P_ ev_signal *w, int revents)
{
if (revents & EV_SIGNAL) {
switch (w->signum) {
#ifndef __MINGW32__
case SIGCHLD:
LOGE("plugin service exit unexpectedly");
case SIGINT:
case SIGTERM:
#ifndef __MINGW32__
case SIGUSR1:
#endif
case SIGINT:
case SIGTERM:
ev_signal_stop(EV_DEFAULT, &sigint_watcher);
ev_signal_stop(EV_DEFAULT, &sigterm_watcher);
ev_signal_stop(EV_DEFAULT, &sigchld_watcher);
#ifndef __MINGW32__
ev_signal_stop(EV_DEFAULT, &sigchld_watcher);
ev_signal_stop(EV_DEFAULT, &sigusr1_watcher);
#endif
keep_resolving = 0;
@ -1505,15 +1505,15 @@ main(int argc, char **argv)
listen_ctx.mptcp = mptcp;
// Setup signal handler
struct ev_signal sigint_watcher;
struct ev_signal sigterm_watcher;
struct ev_signal sigchld_watcher;
ev_signal_init(&sigint_watcher, signal_cb, SIGINT);
ev_signal_init(&sigterm_watcher, signal_cb, SIGTERM);
ev_signal_init(&sigchld_watcher, signal_cb, SIGCHLD);
ev_signal_start(EV_DEFAULT, &sigint_watcher);
ev_signal_start(EV_DEFAULT, &sigterm_watcher);
#ifndef __MINGW32__
ev_signal_init(&sigchld_watcher, signal_cb, SIGCHLD);
ev_signal_start(EV_DEFAULT, &sigchld_watcher);
#endif
struct ev_loop *loop = EV_DEFAULT;
@ -1599,10 +1599,6 @@ main(int argc, char **argv)
winsock_cleanup();
#endif
ev_signal_stop(EV_DEFAULT, &sigint_watcher);
ev_signal_stop(EV_DEFAULT, &sigterm_watcher);
ev_signal_stop(EV_DEFAULT, &sigchld_watcher);
return 0;
}
@ -1656,13 +1652,13 @@ start_ss_local_server(profile_t profile)
ev_signal_init(&sigint_watcher, signal_cb, SIGINT);
ev_signal_init(&sigterm_watcher, signal_cb, SIGTERM);
ev_signal_init(&sigchld_watcher, signal_cb, SIGCHLD);
ev_signal_start(EV_DEFAULT, &sigint_watcher);
ev_signal_start(EV_DEFAULT, &sigterm_watcher);
ev_signal_start(EV_DEFAULT, &sigchld_watcher);
#ifndef __MINGW32__
ev_signal_init(&sigusr1_watcher, signal_cb, SIGUSR1);
ev_signal_init(&sigchld_watcher, signal_cb, SIGCHLD);
ev_signal_start(EV_DEFAULT, &sigusr1_watcher);
ev_signal_start(EV_DEFAULT, &sigchld_watcher);
#endif
// Setup keys

17
src/plugin.c

@ -135,7 +135,8 @@ start_plugin(const char *plugin,
}
uint16_t
get_local_port() {
get_local_port()
{
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
return 0;
@ -162,7 +163,8 @@ get_local_port() {
}
void
stop_plugin() {
stop_plugin()
{
if (sub != NULL) {
cork_subprocess_abort(sub);
cork_subprocess_free(sub);
@ -171,6 +173,11 @@ stop_plugin() {
#else
#include "stdint.h"
#include "utils.h"
#include "plugin.h"
int
start_plugin(const char *plugin,
const char *remote_host,
@ -179,16 +186,18 @@ start_plugin(const char *plugin,
const char *local_port)
{
FATAL("Plugin is not supported on MinGW.");
return -1;
}
uint16_t
get_local_port()
{
FATAL("Plugin is not supported on MinGW.");
return 0;
}
int stop_plugin()
void
stop_plugin()
{
FATAL("Plugin is not supported on MinGW.");
}

5
src/tunnel.c

@ -101,9 +101,11 @@ static int auth = 0;
static int nofile = 0;
#endif
#ifndef __MINGW32__
static struct ev_signal sigint_watcher;
static struct ev_signal sigterm_watcher;
static struct ev_signal sigchld_watcher;
#endif
#ifndef __MINGW32__
static int
@ -714,6 +716,7 @@ accept_cb(EV_P_ ev_io *w, int revents)
ev_timer_start(EV_A_ & remote->send_ctx->watcher);
}
#ifndef __MINGW32__
static void
signal_cb(EV_P_ ev_signal *w, int revents)
{
@ -726,12 +729,12 @@ signal_cb(EV_P_ ev_signal *w, int revents)
ev_signal_stop(EV_DEFAULT, &sigint_watcher);
ev_signal_stop(EV_DEFAULT, &sigterm_watcher);
ev_signal_stop(EV_DEFAULT, &sigchld_watcher);
keep_resolving = 0;
ev_unloop(EV_A_ EVUNLOOP_ALL);
}
}
}
#endif
int
main(int argc, char **argv)

Loading…
Cancel
Save