[Xcb] [PATCH 3/3] Use WSAStartup()/WSACleanup() on WIN32

Ryan Pavlik rpavlik at iastate.edu
Thu Jan 5 14:29:47 PST 2012


On Thu, Jan 5, 2012 at 3:28 PM, Josh Triplett <josh at joshtriplett.org> wrote:

> On Thu, Jan 05, 2012 at 08:57:54PM +0000, Jon TURNEY wrote:
> > From: Ryan Pavlik <rpavlik at iastate.edu>
> >
> > The alternative is to use these in every WIN32 application which uses
> xcb. Doing
> > it this way should be safe, as, according to MSDN, "There must be a call
> to
> > WSACleanup for each successful call to WSAStartup. Only the final
> WSACleanup
> > function call performs the actual cleanup. The preceding calls simply
> decrement
> > an internal reference count"
> [...]
> > Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
>
> Typically a patch needs a signoff by its author, not just the person
> submitting it.  XCB doesn't particularly require signoffs, but if you
> want to follow that convention you should have the original author sign
> off.
>
> > --- a/src/xcb_conn.c
> > +++ b/src/xcb_conn.c
> > @@ -313,6 +313,10 @@ void xcb_disconnect(xcb_connection_t *c)
> >      _xcb_xid_destroy(c);
> >
> >      free(c);
> > +
> > +#ifdef _WIN32
> > +    WSACleanup();
> > +#endif
> >  }
> >
> >  /* Private interface */
> > diff --git a/src/xcb_util.c b/src/xcb_util.c
> > index 62c51e1..d64c904 100644
> > --- a/src/xcb_util.c
> > +++ b/src/xcb_util.c
> > @@ -426,8 +426,13 @@ xcb_connection_t
> *xcb_connect_to_display_with_auth_info(const char *displayname,
> >      if(!parsed) {
> >          c = (xcb_connection_t *) &error_connection;
> >          goto out;
> > -    } else
> > +    } else {
> > +#ifdef _WIN32
> > +        WSADATA wsaData;
> > +        WSAStartup(MAKEWORD(2, 2), &wsaData);
> > +#endif
> >          fd = _xcb_open(host, protocol, display);
> > +    }
>
> What happens if the application using XCB has already called WSAStartup,
> and passes a lower version number than 2.2?  Will XCB's call to
> WSAStartup cause Winsock to start assuming 2.2 semantics instead of
> whatever older semantics the application requested?  Or will Winsock
> just tell XCB to use the older version?  In the latter case, can XCB
> live with that?
>
> - Josh Triplett
>

I'm not sure, but 2.2 is available since a patch for Windows 95, so I'm
pretty confident that it's a safe alternative.

Jon, if you put these patches in some publicly-accessible repo I can go
through and sign off on them easily.

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20120105/3c79df47/attachment.html>


More information about the Xcb mailing list