GSocket does not support ENOTSOCK
g_io_error_from_errno()
doesn't handle ENOTSOCK
(which is a legitimate POSIX error code for the cases when you pass something that isn't a valid socket object [anymore].
Curiously, the sister function, g_io_error_from_win32_error()
, does handle the Windows equivalent, WSAENOTSOCK
, returning G_IO_ERROR_INVALID_ARGUMENT
, which is not as good as the non-existent G_IO_ERROR_NOT_A_SOCKET
, but still better than the very generic G_IO_ERROR_FAILED
.
I have 2 patches that fix this. One is
--- glib-2.59.3/gio/gioerror.c 2019-02-18 09:12:32.000000000 +0000
+++ glib-2.59.3/gio/gioerror.c 2019-03-16 13:10:15.586363200 +0000
@@ -320,9 +320,11 @@
case WSA_INVALID_HANDLE:
case WSA_INVALID_PARAMETER:
case WSAEINVAL:
+ return G_IO_ERROR_INVALID_ARGUMENT;
+
case WSAEBADF:
case WSAENOTSOCK:
- return G_IO_ERROR_INVALID_ARGUMENT;
+ return G_IO_ERROR_FAILED;
case WSAEPROTONOSUPPORT:
return G_IO_ERROR_NOT_SUPPORTED;
The other is
--- glib-2.59.3/gio/gioerror.c 2019-02-18 09:12:32.000000000 +0000
+++ glib-2.59.3/gio/gioerror.c 2019-03-16 13:12:22.710154300 +0000
@@ -272,6 +272,12 @@
break;
#endif
+#ifdef ENOTSOCK
+ case ENOTSOCK:
+ return G_IO_ERROR_INVALID_ARGUMENT;
+ break;
+#endif
+
default:
return G_IO_ERROR_FAILED;
break;
Which one do i create a MR for?