Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
20a70bd4
Commit
20a70bd4
authored
5 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Add/use SOCKET_ERRNO (in place of ERROR_VALUE)
parent
dbc2b45f
No related branches found
No related tags found
No related merge requests found
Pipeline
#7312
passed
5 months ago
Stage: build
Stage: test
Stage: cleanup
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/xpdev/ini_file.c
+3
-3
3 additions, 3 deletions
src/xpdev/ini_file.c
src/xpdev/multisock.c
+1
-1
1 addition, 1 deletion
src/xpdev/multisock.c
src/xpdev/sockwrap.c
+8
-8
8 additions, 8 deletions
src/xpdev/sockwrap.c
src/xpdev/sockwrap.h
+2
-0
2 additions, 0 deletions
src/xpdev/sockwrap.h
with
14 additions
and
12 deletions
src/xpdev/ini_file.c
+
3
−
3
View file @
20a70bd4
...
@@ -2052,13 +2052,13 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
...
@@ -2052,13 +2052,13 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
len
=
sizeof
(
type
);
len
=
sizeof
(
type
);
if
((
result
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_TYPE
,
(
char
*
)
&
type
,
&
len
))
!=
0
)
{
if
((
result
=
getsockopt
(
sock
,
SOL_SOCKET
,
SO_TYPE
,
(
char
*
)
&
type
,
&
len
))
!=
0
)
{
safe_snprintf
(
error
,
errlen
,
"%d (%s) getting socket type"
,
ERROR_VALUE
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
safe_snprintf
(
error
,
errlen
,
"%d (%s) getting socket type"
,
SOCKET_ERRNO
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
return
(
result
);
return
(
result
);
}
}
#ifdef IPPROTO_IPV6
#ifdef IPPROTO_IPV6
len
=
sizeof
(
addr
);
len
=
sizeof
(
addr
);
if
((
result
=
getsockname
(
sock
,
&
addr
.
addr
,
&
len
))
!=
0
)
{
if
((
result
=
getsockname
(
sock
,
&
addr
.
addr
,
&
len
))
!=
0
)
{
safe_snprintf
(
error
,
errlen
,
"%d (%s) getting socket name"
,
ERROR_VALUE
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
safe_snprintf
(
error
,
errlen
,
"%d (%s) getting socket name"
,
SOCKET_ERRNO
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
return
(
result
);
return
(
result
);
}
}
#endif
#endif
...
@@ -2094,7 +2094,7 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
...
@@ -2094,7 +2094,7 @@ int iniGetSocketOptions(str_list_t list, const char* section, SOCKET sock
if
((
result
=
setsockopt
(
sock
,
level
,
option
,(
const
char
*
)
vp
,
len
))
!=
0
)
{
if
((
result
=
setsockopt
(
sock
,
level
,
option
,(
const
char
*
)
vp
,
len
))
!=
0
)
{
safe_snprintf
(
error
,
errlen
,
"%d (%s) setting socket option (%s, %d) to %d"
safe_snprintf
(
error
,
errlen
,
"%d (%s) setting socket option (%s, %d) to %d"
,
ERROR_VALUE
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)),
name
,
option
,
value
);
,
SOCKET_ERRNO
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)),
name
,
option
,
value
);
return
(
result
);
return
(
result
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/multisock.c
+
1
−
1
View file @
20a70bd4
...
@@ -155,7 +155,7 @@ bool xpms_add(struct xpms_set *xpms_set, int domain, int type,
...
@@ -155,7 +155,7 @@ bool xpms_add(struct xpms_set *xpms_set, int domain, int type,
if
(
listen
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
,
SOMAXCONN
)
==-
1
)
{
if
(
listen
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
,
SOMAXCONN
)
==-
1
)
{
if
(
xpms_set
->
lprintf
)
if
(
xpms_set
->
lprintf
)
xpms_set
->
lprintf
(
LOG_WARNING
,
"%04d !%s ERROR %d listening on port %d: %s"
xpms_set
->
lprintf
(
LOG_WARNING
,
"%04d !%s ERROR %d listening on port %d: %s"
,
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
,
prot
,
ERROR_VALUE
,
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
,
prot
,
SOCKET_ERRNO
,
port
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
,
port
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
closesocket
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
);
closesocket
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
sock
);
FREE_AND_NULL
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
address
);
FREE_AND_NULL
(
xpms_set
->
socks
[
xpms_set
->
sock_count
].
address
);
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/sockwrap.c
+
8
−
8
View file @
20a70bd4
...
@@ -197,7 +197,7 @@ off_t sendfilesocket(int sock, int file, off_t *offset, off_t count)
...
@@ -197,7 +197,7 @@ off_t sendfilesocket(int sock, int file, off_t *offset, off_t count)
wr
=
sendsocket
(
sock
,
buf
+
i
,
rd
-
i
);
wr
=
sendsocket
(
sock
,
buf
+
i
,
rd
-
i
);
if
(
wr
>
0
)
if
(
wr
>
0
)
continue
;
continue
;
if
(
wr
==
SOCKET_ERROR
&&
ERROR_VALUE
==
EWOULDBLOCK
)
{
if
(
wr
==
SOCKET_ERROR
&&
SOCKET_ERRNO
==
EWOULDBLOCK
)
{
wr
=
0
;
wr
=
0
;
SLEEP
(
1
);
SLEEP
(
1
);
continue
;
continue
;
...
@@ -337,7 +337,7 @@ bool socket_check(SOCKET sock, bool* rd_p, bool* wr_p, DWORD timeout)
...
@@ -337,7 +337,7 @@ bool socket_check(SOCKET sock, bool* rd_p, bool* wr_p, DWORD timeout)
if
(
pfd
.
revents
&
~
(
POLLOUT
)
&&
(
rd_p
!=
NULL
||
wr_p
==
NULL
))
{
if
(
pfd
.
revents
&
~
(
POLLOUT
)
&&
(
rd_p
!=
NULL
||
wr_p
==
NULL
))
{
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
ERROR_VALUE
==
EMSGSIZE
))
{
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
SOCKET_ERRNO
==
EMSGSIZE
))
{
if
(
rd_p
!=
NULL
)
if
(
rd_p
!=
NULL
)
*
rd_p
=
true
;
*
rd_p
=
true
;
return
true
;
return
true
;
...
@@ -400,7 +400,7 @@ bool socket_check(SOCKET sock, bool* rd_p, bool* wr_p, DWORD timeout)
...
@@ -400,7 +400,7 @@ bool socket_check(SOCKET sock, bool* rd_p, bool* wr_p, DWORD timeout)
if
(
rd_p
!=
NULL
||
wr_p
==
NULL
)
{
if
(
rd_p
!=
NULL
||
wr_p
==
NULL
)
{
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
if
(
rd
==
1
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
ERROR_VALUE
==
EMSGSIZE
))
{
||
(
rd
==
SOCKET_ERROR
&&
SOCKET_ERRNO
==
EMSGSIZE
))
{
if
(
rd_p
!=
NULL
)
if
(
rd_p
!=
NULL
)
*
rd_p
=
true
;
*
rd_p
=
true
;
return
(
true
);
return
(
true
);
...
@@ -514,7 +514,7 @@ bool socket_recvdone(SOCKET sock, int timeout)
...
@@ -514,7 +514,7 @@ bool socket_recvdone(SOCKET sock, int timeout)
case
1
:
case
1
:
if
(
pfd
.
revents
)
{
if
(
pfd
.
revents
)
{
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
ERROR_VALUE
==
EMSGSIZE
))
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
SOCKET_ERRNO
==
EMSGSIZE
))
return
false
;
return
false
;
return
true
;
return
true
;
}
}
...
@@ -548,7 +548,7 @@ bool socket_recvdone(SOCKET sock, int timeout)
...
@@ -548,7 +548,7 @@ bool socket_recvdone(SOCKET sock, int timeout)
return
false
;
return
false
;
}
}
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
rd
=
recv
(
sock
,
&
ch
,
1
,
MSG_PEEK
);
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
ERROR_VALUE
==
EMSGSIZE
))
if
(
rd
==
1
||
(
rd
==
SOCKET_ERROR
&&
SOCKET_ERRNO
==
EMSGSIZE
))
return
false
;
return
false
;
return
true
;
return
true
;
#endif
#endif
...
@@ -573,7 +573,7 @@ int retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
...
@@ -573,7 +573,7 @@ int retry_bind(SOCKET s, const struct sockaddr *addr, socklen_t addrlen
break
;
break
;
if
(
lprintf
!=
NULL
)
if
(
lprintf
!=
NULL
)
lprintf
(
i
<
retries
?
LOG_WARNING
:
LOG_CRIT
lprintf
(
i
<
retries
?
LOG_WARNING
:
LOG_CRIT
,
"%04d !ERROR %d binding %s socket%s: %s"
,
s
,
ERROR_VALUE
,
prot
,
port_str
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
,
"%04d !ERROR %d binding %s socket%s: %s"
,
s
,
SOCKET_ERRNO
,
prot
,
port_str
,
SOCKET_STRERROR
(
err
,
sizeof
(
err
)));
if
(
i
<
retries
)
{
if
(
i
<
retries
)
{
if
(
lprintf
!=
NULL
)
if
(
lprintf
!=
NULL
)
lprintf
(
LOG_WARNING
,
"%04d Will retry in %u seconds (%u of %u)"
lprintf
(
LOG_WARNING
,
"%04d Will retry in %u seconds (%u of %u)"
...
@@ -592,7 +592,7 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
...
@@ -592,7 +592,7 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
result
=
connect
(
sock
,
addr
,
size
);
result
=
connect
(
sock
,
addr
,
size
);
if
(
result
==
SOCKET_ERROR
)
{
if
(
result
==
SOCKET_ERROR
)
{
result
=
ERROR_VALUE
;
result
=
SOCKET_ERRNO
;
if
(
result
==
EWOULDBLOCK
||
result
==
EINPROGRESS
)
{
if
(
result
==
EWOULDBLOCK
||
result
==
EINPROGRESS
)
{
if
(
socket_writable
(
sock
,
timeout
*
1000
))
{
if
(
socket_writable
(
sock
,
timeout
*
1000
))
{
result
=
0
;
result
=
0
;
...
@@ -600,7 +600,7 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
...
@@ -600,7 +600,7 @@ int nonblocking_connect(SOCKET sock, struct sockaddr* addr, size_t size, unsigne
else
{
else
{
optlen
=
sizeof
(
result
);
optlen
=
sizeof
(
result
);
if
(
getsockopt
(
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
void
*
)
&
result
,
&
optlen
)
==
SOCKET_ERROR
)
if
(
getsockopt
(
sock
,
SOL_SOCKET
,
SO_ERROR
,
(
void
*
)
&
result
,
&
optlen
)
==
SOCKET_ERROR
)
result
=
ERROR_VALUE
;
result
=
SOCKET_ERRNO
;
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/sockwrap.h
+
2
−
0
View file @
20a70bd4
...
@@ -175,6 +175,7 @@ union xp_sockaddr {
...
@@ -175,6 +175,7 @@ union xp_sockaddr {
#define sa_family_t ushort
#define sa_family_t ushort
typedef
uint32_t
in_addr_t
;
typedef
uint32_t
in_addr_t
;
#define SOCKET_ERRNO socket_errno(true)
#define ERROR_VALUE socket_errno(true) // Deprecated
#define ERROR_VALUE socket_errno(true) // Deprecated
#define sendsocket(s,b,l) send(s,b,l,0)
#define sendsocket(s,b,l) send(s,b,l,0)
typedef
ULONG
nfds_t
;
typedef
ULONG
nfds_t
;
...
@@ -206,6 +207,7 @@ typedef ULONG nfds_t;
...
@@ -206,6 +207,7 @@ typedef ULONG nfds_t;
#define INVALID_SOCKET (SOCKET)(~0)
#define INVALID_SOCKET (SOCKET)(~0)
#define closesocket close
#define closesocket close
#define ioctlsocket ioctl
#define ioctlsocket ioctl
#define SOCKET_ERRNO errno
#define ERROR_VALUE errno
#define ERROR_VALUE errno
#define sendsocket write
/* FreeBSD send() is broken */
#define sendsocket write
/* FreeBSD send() is broken */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment