Skip to content

Commit

Permalink
Fix the windows socket issue with MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Nov 16, 2017
1 parent fa5ee69 commit 8df0a7c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/local.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

#ifdef __MINGW32__
#include "win32.h"
#define __ev_io_init(a, b, c, d) ev_io_init(a, b, _open_osfhandle(c, 0), d)
#else
#define __ev_io_init(a, b, c, d) ev_io_init(a, b, c, d)
#endif

#include "netutils.h"
Expand Down Expand Up @@ -669,8 +672,8 @@ new_remote(int fd, int timeout)
remote->recv_ctx->remote = remote;
remote->send_ctx->remote = remote;

ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
__ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
__ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb,
min(MAX_CONNECT_TIMEOUT, timeout), 0);
ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb,
Expand Down Expand Up @@ -733,8 +736,8 @@ new_server(int fd)
memset(server->obfs, 0, sizeof(obfs_t));
}

ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);
__ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
__ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);

cork_dllist_add(&connections, &server->entries);

Expand Down Expand Up @@ -1214,11 +1217,11 @@ main(int argc, char **argv)
ev_signal_start(EV_DEFAULT, &sigterm_watcher);
#endif

ev_timer parent_watcher;
#ifndef __MINGW32__
ev_timer parent_watcher;
ev_timer_init(&parent_watcher, parent_watcher_cb, 0, UPDATE_INTERVAL);
#endif
ev_timer_start(EV_DEFAULT, &parent_watcher);
#endif

struct ev_loop *loop = EV_DEFAULT;

Expand All @@ -1239,7 +1242,7 @@ main(int argc, char **argv)

listen_ctx.fd = listenfd;

ev_io_init(&listen_ctx.io, accept_cb, listenfd, EV_READ);
__ev_io_init(&listen_ctx.io, accept_cb, listenfd, EV_READ);
ev_io_start(loop, &listen_ctx.io);

#ifdef HAVE_LAUNCHD
Expand Down

0 comments on commit 8df0a7c

Please sign in to comment.