dtio->event_added_is_write = 0;
}
+/** close dtio socket and set it to -1 */
+static void dtio_close_fd(struct dt_io_thread* dtio)
+{
+#ifndef USE_WINSOCK
+ close(dtio->fd);
+#else
+ closesocket(dtio->fd);
+#endif
+ dtio->fd = -1;
+}
+
/** close and stop the output file descriptor event */
static void dtio_close_output(struct dt_io_thread* dtio)
{
dtio->ssl = NULL;
#endif
}
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
/* if there is a (partial) message, discard it
* we cannot send (the remainder of) it, and a new
log_err("dnstap io: failed to connect to \"%s\": %s",
to, wsa_strerror(WSAGetLastError()));
#endif
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
return 0;
}
return 1;
dtio->ip_str, wsa_strerror(WSAGetLastError()));
}
#endif
-
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
return 0;
}
return 1;
}
if(dtio->upstream_is_tls) {
if(!dtio_setup_ssl(dtio)) {
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
dtio_reconnect_enable(dtio);
return;
}
dtio->ssl = NULL;
#endif
}
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
dtio_reconnect_enable(dtio);
return;
}
dtio->ssl = NULL;
#endif
}
-#ifndef USE_WINSOCK
- close(dtio->fd);
-#else
- closesocket(dtio->fd);
-#endif
- dtio->fd = -1;
+ dtio_close_fd(dtio);
dtio_reconnect_enable(dtio);
return;
}