-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSAStartup issue on Windows #136
Comments
@gvanem Didn't you send us a WSAStartup patch !? Sorry, I was sure we had that applied, but can't find it any more. Could you resend it to me ? |
Ok, here is what I sent you in an email: --- a/src/wget.c 2016-11-08 19:54:27
+++ b/src/wget.c 2016-11-08 20:25:53
@@ -135,6 +135,37 @@
int
nthreads;
+#if defined(_WIN32)
+static void
+ws_cleanup (void)
+{
+ WSACleanup ();
+}
+
+/* Perform Windows specific initialization. */
+static void
+ws_startup (void)
+{
+ WSADATA data;
+ WORD requested = MAKEWORD (1, 1);
+ int err = WSAStartup (requested, &data);
+ if (err != 0)
+ {
+ fprintf (stderr, _("wget: Couldn't find usable socket driver.\n"));
+ exit (1);
+ }
+
+ if (data.wVersion < requested)
+ {
+ fprintf (stderr, _("wget: Couldn't find usable socket driver.\n"));
+ WSACleanup ();
+ exit (1);
+ }
+
+ atexit (ws_cleanup);
+}
+#endif
+
void set_exit_status(int status)
{
// use Wget exit status scheme:
@@ -857,11 +888,12 @@
textdomain("wget");
#endif
-#if defined(_WIN32) || defined(_WIN64)
+#if defined(_WIN32)
// not sure if this is needed for Windows
// signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, nop);
signal(SIGINT, nop);
+ ws_startup();
#else
// need to set some signals
struct sigaction sig_action; This is almost an exact copy & paste from Wget. |
@gvanem Thx, just found a gnulib module doing that. I integrated the socket startup/cleanup function deeper within the library, so that the examples benefit as well. After reading https://msdn.microsoft.com/en-us/library/windows/desktop/ms742213%28v=vs.85%29.aspx, I decided to use socket version 2.2. Any objections ? Could you test the latest commit and report back, please !? |
Doesn't work; I just added a |
Init NULL is OK, i'll fix wget.c when back from lunch. Do you know which network functions need handles and which need fds ? |
I suspect there is some problem with GnuLib's shimming of |
Regarding gnulib docs, mingw poll() should be ok: https://www.gnu.org/software/gnulib/manual/html_node/poll.html |
@gvanem Found a problem in gnulib/poll.c with MinGW - likely the same problem that you have. Before
insert
Not sure why, but recv() returns -1 (with error==0) when the socket is ready to read. |
It works sometimes. Other times I get a crash in |
Well, wget2 is documented to be POSIX + C99. That excludes Windows ATM. But color seqs should be easy... You are invited to provide patches, else there currently is no Win developer who does. |
BTW, the gnulib poll emulation for Win looks messy. If there is a WSAPoll, that should be used. But again, only a Win dev could make that. |
Some of my hacks is in |
wine doesn't know WSAPoll, again I can't test... |
Just stumbled upon https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ (sigh). |
Building using the mingw script produces a version that does not work on Windows:
The text was updated successfully, but these errors were encountered: