Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
bd6585a7
Commit
bd6585a7
authored
Mar 16, 2012
by
Carlos Martín Nieto
Committed by
Vicent Martí
Apr 11, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
netops: show winsock error messages on Windows
parent
56b7df10
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
src/netops.c
+23
-3
No files found.
src/netops.c
View file @
bd6585a7
...
@@ -25,6 +25,26 @@
...
@@ -25,6 +25,26 @@
#include "common.h"
#include "common.h"
#include "netops.h"
#include "netops.h"
#include "posix.h"
#include "posix.h"
#include "buffer.h"
#ifdef GIT_WIN32
static
void
net_set_error
(
const
char
*
str
)
{
int
size
,
error
=
WSAGetLastError
();
LPSTR
err_str
=
NULL
;
size
=
FormatMessage
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
,
0
,
error
,
0
,
(
LPSTR
)
&
err_str
,
0
,
0
);
giterr_set
(
GITERR_NET
,
"%s: $s"
,
str
,
err_str
);
LocalFree
(
err_str
);
}
#else
static
void
net_set_error
(
const
char
*
str
)
{
giterr_set
(
GITERR_NET
,
"%s: %s"
,
str
,
strerror
(
errno
));
}
#endif
void
gitno_buffer_setup
(
gitno_buffer
*
buf
,
char
*
data
,
unsigned
int
len
,
int
fd
)
void
gitno_buffer_setup
(
gitno_buffer
*
buf
,
char
*
data
,
unsigned
int
len
,
int
fd
)
{
{
...
@@ -45,7 +65,7 @@ int gitno_recv(gitno_buffer *buf)
...
@@ -45,7 +65,7 @@ int gitno_recv(gitno_buffer *buf)
return
0
;
return
0
;
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
giterr_set
(
GITERR_NET
,
"Error receiving data"
);
net_set_error
(
"Error receiving data"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -100,7 +120,7 @@ int gitno_connect(const char *host, const char *port)
...
@@ -100,7 +120,7 @@ int gitno_connect(const char *host, const char *port)
#else
#else
if
(
s
<
0
)
{
if
(
s
<
0
)
{
#endif
#endif
giterr_set
(
GITERR_OS
,
"Error creating socket"
);
net_set_error
(
"Error creating socket"
);
freeaddrinfo
(
info
);
freeaddrinfo
(
info
);
return
-
1
;
return
-
1
;
}
}
...
@@ -132,7 +152,7 @@ int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags)
...
@@ -132,7 +152,7 @@ int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags)
ret
=
send
(
s
,
msg
+
off
,
len
-
off
,
flags
);
ret
=
send
(
s
,
msg
+
off
,
len
-
off
,
flags
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
giterr_set
(
GITERR_OS
,
"Error sending data: %s"
,
strerror
(
errno
)
);
net_set_error
(
"Error sending data"
);
return
-
1
;
return
-
1
;
}
}
...
...
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