[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Libevent 2.0.8 crashes on Windows without WSAStartup



On Mon, Oct 25, 2010 at 11:02 PM, bottiger1@xxxxxxxxx
<bottiger1@xxxxxxxxx> wrote:
> I've compiled libevent on windows 7 32bit with Mingw successfully.
> Unfortunately when I run a few test programs, some of them will print:
>
> [warn] evsig_init: socketpair: Successful WSAStartup not yet performed
> [WSANOTINITIALISED ]
> [warn] evthread_make_base_notifiable: socketpair: Successful
> WSAStartup not yet performed [WSANOTINITIALISED ]
> Couldn't get an event_base
>
> I found out that the ones that didn't crash like bench_http.c had this
> code right before calling event_base_new().
>
> #ifdef WIN32
> WSADATA WSAData;
> WSAStartup(0x101, &WSAData);
>
> I put that code in, and it seems to fix the problem. Is this intended
> behavior?

Not sure.  It's been that way at least since before I started working
on Libevent.

> I feel that this code should be inside event_base_new().

I'm not too sure about that.  There's no requirement that
event_base_new() be called before any socket operations be called, and
I wouldn't want to add such a requirement.  So a preventive call to
WSAStartup in event_base_new() might help some people who were new to
Windows socket programming (if they called event_base_new() before
they made any socket calls), but it wouldn't help others.

People more experienced than I am about Windows can probably weigh in
on what the right thing is here.  Either way, it would have to be for
2.1; we're trying very hard not to change the 2.0 core API while we
get it stable.

peace,
-- 
Nick

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.