mirror of
https://github.com/janet-lang/janet
synced 2026-10-09 01:01:41 +00:00
Tweaks.
This commit is contained in:
@@ -2471,6 +2471,9 @@ Janet janet_ev_lasterr(void) {
|
||||
c++;
|
||||
}
|
||||
size_t len = c - msgbuf;
|
||||
if (len) {
|
||||
*c++ = ' '; /* Padding between message and error code */
|
||||
}
|
||||
snprintf(c, sizeof(msgbuf) - len, "(%d)", code);
|
||||
return janet_cstringv(msgbuf);
|
||||
}
|
||||
|
||||
+8
-3
@@ -81,6 +81,11 @@ const JanetAbstractType janet_address_type = {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Just in case */
|
||||
#ifdef JANET_WINDOWS
|
||||
#define socklen_t int
|
||||
#endif
|
||||
|
||||
/* maximum number of bytes in a socket address host (post name resolution) */
|
||||
#ifdef JANET_WINDOWS
|
||||
#ifdef JANET_NO_IPV6
|
||||
@@ -195,19 +200,19 @@ void net_callback_connect(JanetFiber *fiber, JanetAsyncEvent event) {
|
||||
/* We should be using ConnectEx here */
|
||||
int res = 0;
|
||||
int size = sizeof(res);
|
||||
int r = getsockopt((SOCKET)stream->handle, SOL_SOCKET, SO_CONNECT_TIME, (char *)&res, &size);
|
||||
int r = getsockopt(as_socket(stream->handle), SOL_SOCKET, SO_CONNECT_TIME, (char *)&res, &size);
|
||||
if (r == NO_ERROR && res == (~0)) {
|
||||
return; /* This apparently indicates we haven't yet gotten a connection */
|
||||
}
|
||||
const int no_error = NO_ERROR;
|
||||
if (r == NO_ERROR) { /* Last sockopt worked, one more */
|
||||
/* Put socket in a good state instead of an empty default state. */
|
||||
r = setsockopt((SOCKET)stream->handle, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
|
||||
r = setsockopt(as_socket(stream->handle), SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
|
||||
}
|
||||
#else
|
||||
int res = 0;
|
||||
socklen_t size = sizeof(res);
|
||||
int r = getsockopt(stream->handle, SOL_SOCKET, SO_ERROR, &res, &size);
|
||||
int r = getsockopt(as_socket(stream->handle), SOL_SOCKET, SO_ERROR, &res, &size);
|
||||
const int no_error = 0;
|
||||
#endif
|
||||
if (r == no_error) {
|
||||
|
||||
Reference in New Issue
Block a user