Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
de5c1fb8
Commit
de5c1fb8
authored
Feb 12, 2015
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Initialize winsock before creating socket in Windows builds.
parent
4fe1be14
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
5 deletions
+47
-5
ftp.c
dlls/wininet/ftp.c
+2
-0
internet.c
dlls/wininet/internet.c
+1
-0
internet.h
dlls/wininet/internet.h
+2
-0
netconnection.c
dlls/wininet/netconnection.c
+42
-5
No files found.
dlls/wininet/ftp.c
View file @
de5c1fb8
...
...
@@ -2573,6 +2573,7 @@ HINTERNET FTP_Connect(appinfo_t *hIC, LPCWSTR lpszServerName,
SendAsyncCallback
(
&
hIC
->
hdr
,
dwContext
,
INTERNET_STATUS_NAME_RESOLVED
,
szaddr
,
strlen
(
szaddr
)
+
1
);
init_winsock
();
nsocket
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
nsocket
==
-
1
)
{
...
...
@@ -2932,6 +2933,7 @@ static BOOL FTP_InitListenSocket(ftp_session_t *lpwfs)
TRACE
(
"
\n
"
);
init_winsock
();
lpwfs
->
lstnSocket
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
);
if
(
lpwfs
->
lstnSocket
==
-
1
)
{
...
...
dlls/wininet/internet.c
View file @
de5c1fb8
...
...
@@ -3477,6 +3477,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
if
(
!
GetAddress
(
hostW
,
port
,
(
struct
sockaddr
*
)
&
saddr
,
&
sa_len
))
goto
End
;
init_winsock
();
fd
=
socket
(
saddr
.
ss_family
,
SOCK_STREAM
,
0
);
if
(
fd
!=
-
1
)
{
...
...
dlls/wininet/internet.h
View file @
de5c1fb8
...
...
@@ -478,6 +478,8 @@ BOOL init_urlcache(void) DECLSPEC_HIDDEN;
void
free_urlcache
(
void
)
DECLSPEC_HIDDEN
;
void
free_cookie
(
void
)
DECLSPEC_HIDDEN
;
void
init_winsock
(
void
)
DECLSPEC_HIDDEN
;
#define MAX_REPLY_LEN 0x5B4
/* Used for debugging - maybe need to be shared in the Wine debugging code ? */
...
...
dlls/wininet/netconnection.c
View file @
de5c1fb8
...
...
@@ -27,6 +27,10 @@
#define NONAMELESSUNION
#if defined(__MINGW32__) || defined (_MSC_VER)
#define USE_WINSOCK
#endif
#ifdef USE_WINSOCK
#include <ws2tcpip.h>
#endif
...
...
@@ -62,7 +66,7 @@
#ifdef HAVE_NETINET_TCP_H
# include <netinet/tcp.h>
#endif
#if
!defined(__MINGW32__) && !defined(_MSC_VER)
#if
ndef USE_WINSOCK
#include <errno.h>
#endif
...
...
@@ -317,10 +321,38 @@ static BOOL ensure_cred_handle(void)
return
TRUE
;
}
#ifdef USE_WINSOCK
static
BOOL
winsock_loaded
=
FALSE
;
static
BOOL
WINAPI
winsock_startup
(
INIT_ONCE
*
once
,
void
*
param
,
void
**
context
)
{
WSADATA
wsa_data
;
DWORD
res
;
res
=
WSAStartup
(
MAKEWORD
(
1
,
1
),
&
wsa_data
);
if
(
res
==
ERROR_SUCCESS
)
winsock_loaded
=
TRUE
;
else
ERR
(
"WSAStartup failed: %u
\n
"
,
res
);
return
TRUE
;
}
#endif
void
init_winsock
(
void
)
{
#ifdef USE_WINSOCK
static
INIT_ONCE
init_once
=
INIT_ONCE_STATIC_INIT
;
InitOnceExecuteOnce
(
&
init_once
,
winsock_startup
,
NULL
,
NULL
);
#endif
}
static
DWORD
create_netconn_socket
(
server_t
*
server
,
netconn_t
*
netconn
,
DWORD
timeout
)
{
int
result
;
ULONG
flag
;
DWORD
res
;
init_winsock
();
assert
(
server
->
addr_len
);
result
=
netconn
->
socket
=
socket
(
server
->
addr
.
ss_family
,
SOCK_STREAM
,
0
);
...
...
@@ -330,7 +362,8 @@ static DWORD create_netconn_socket(server_t *server, netconn_t *netconn, DWORD t
result
=
connect
(
netconn
->
socket
,
(
struct
sockaddr
*
)
&
server
->
addr
,
server
->
addr_len
);
if
(
result
==
-
1
)
{
if
(
sock_get_error
()
==
WSAEINPROGRESS
||
sock_get_error
()
==
WSAEWOULDBLOCK
)
{
res
=
sock_get_error
();
if
(
res
==
WSAEINPROGRESS
||
res
==
WSAEWOULDBLOCK
)
{
struct
pollfd
pfd
;
int
res
;
...
...
@@ -441,12 +474,16 @@ void NETCON_unload(void)
if
(
have_compat_cred_handle
)
FreeCredentialsHandle
(
&
compat_cred_handle
);
DeleteCriticalSection
(
&
init_sechandle_cs
);
#ifdef USE_WINSOCK
WSACleanup
();
#endif
}
/* translate a unix error code into a winsock one */
int
sock_get_error
(
void
)
{
#if
defined(__MINGW32__) || defined(_MSC_VER)
#if
def USE_WINSOCK
return
WSAGetLastError
();
#else
switch
(
errno
)
...
...
@@ -538,7 +575,7 @@ int sock_recv(int fd, void *msg, size_t len, int flags)
static
void
set_socket_blocking
(
int
socket
,
blocking_mode_t
mode
)
{
#if
defined(__MINGW32__) || defined (_MSC_VER)
#if
def USE_WINSOCK
ULONG
arg
=
mode
==
BLOCKING_DISALLOW
;
ioctlsocket
(
socket
,
FIONBIO
,
&
arg
);
#endif
...
...
@@ -1041,7 +1078,7 @@ BOOL NETCON_is_alive(netconn_t *netconn)
len
=
sock_recv
(
netconn
->
socket
,
&
b
,
1
,
MSG_PEEK
|
MSG_DONTWAIT
);
return
len
==
1
||
(
len
==
-
1
&&
sock_get_error
()
==
WSAEWOULDBLOCK
);
#elif defined(
__MINGW32__) || defined(_MSC_VER
)
#elif defined(
USE_WINSOCK
)
ULONG
mode
;
int
len
;
char
b
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment