MinGW: fix socket closing in wrong place

This commit is contained in:
Linus Yang
2018-03-22 19:31:01 +08:00
parent f399189e13
commit 1f9dd2fbf4
+8 -4
View File
@@ -110,6 +110,7 @@ static struct ev_signal sigterm_watcher;
static struct ev_signal sigchld_watcher;
static struct ev_signal sigusr1_watcher;
#else
#ifndef LIB_ONLY
static struct plugin_watcher_t {
ev_io io;
SOCKET fd;
@@ -117,6 +118,7 @@ static struct plugin_watcher_t {
int valid;
} plugin_watcher;
#endif
#endif
#ifdef HAVE_SETRLIMIT
#ifndef LIB_ONLY
@@ -1323,7 +1325,9 @@ signal_cb(EV_P_ ev_signal *w, int revents)
ev_signal_stop(EV_DEFAULT, &sigchld_watcher);
ev_signal_stop(EV_DEFAULT, &sigusr1_watcher);
#else
#ifndef LIB_ONLY
ev_io_stop(EV_DEFAULT, &plugin_watcher.io);
#endif
#endif
keep_resolving = 0;
ev_unloop(EV_A_ EVUNLOOP_ALL);
@@ -1890,6 +1894,10 @@ main(int argc, char **argv)
}
#ifdef __MINGW32__
if (plugin_watcher.valid) {
closesocket(plugin_watcher.fd);
}
winsock_cleanup();
#endif
@@ -2039,10 +2047,6 @@ _start_ss_local_server(profile_t profile, ss_local_callback callback, void *udat
}
#ifdef __MINGW32__
if (plugin_watcher.valid) {
closesocket(plugin_watcher.fd);
}
winsock_cleanup();
#endif