|
|
@@ -192,7 +192,7 @@ read:
|
|
|
}
|
|
|
else {
|
|
|
io->error = socket_errno();
|
|
|
- perror("read");
|
|
|
+ /* perror("read"); */
|
|
|
goto read_error;
|
|
|
}
|
|
|
}
|
|
|
@@ -253,7 +253,7 @@ write:
|
|
|
}
|
|
|
else {
|
|
|
io->error = socket_errno();
|
|
|
- perror("write");
|
|
|
+ /* perror("write"); */
|
|
|
goto write_error;
|
|
|
}
|
|
|
}
|
|
|
@@ -295,6 +295,9 @@ static void hio_handle_events(hio_t* io) {
|
|
|
io->events &= ~WRITE_EVENT;
|
|
|
}
|
|
|
if (io->connect) {
|
|
|
+#ifdef OS_WIN
|
|
|
+ htimer_del((htimer_t*)io->userdata);
|
|
|
+#endif
|
|
|
// NOTE: connect just do once
|
|
|
// ONESHOT
|
|
|
io->connect = 0;
|
|
|
@@ -314,6 +317,13 @@ int hio_accept(hio_t* io) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+#ifdef OS_WIN
|
|
|
+#define CONNECT_TIMEOUT 5000 // ms
|
|
|
+static void connect_timeout_cb(htimer_t* timer) {
|
|
|
+ hio_close((hio_t*)timer->userdata);
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
int hio_connect(hio_t* io) {
|
|
|
int ret = connect(io->fd, io->peeraddr, sizeof(sockaddr_un));
|
|
|
#ifdef OS_WIN
|
|
|
@@ -332,6 +342,11 @@ int hio_connect(hio_t* io) {
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+#ifdef OS_WIN
|
|
|
+ htimer_t* timer = htimer_add(io->loop, connect_timeout_cb, CONNECT_TIMEOUT, 1);
|
|
|
+ timer->userdata = io;
|
|
|
+ io->userdata = timer;
|
|
|
+#endif
|
|
|
return hio_add(io, hio_handle_events, WRITE_EVENT);
|
|
|
}
|
|
|
|
|
|
@@ -372,7 +387,7 @@ try_write:
|
|
|
goto enqueue;
|
|
|
}
|
|
|
else {
|
|
|
- perror("write");
|
|
|
+ /* perror("write"); */
|
|
|
io->error = socket_errno();
|
|
|
goto write_error;
|
|
|
}
|