mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-03 08:23:47 +00:00
Fix #1054
This commit is contained in:
+12
-16
@@ -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
|
||||
|
||||
+13
-4
@@ -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.");
|
||||
}
|
||||
|
||||
+4
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user