Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Petr Menšík
BIND
Commits
cbe22be4
Commit
cbe22be4
authored
Mar 12, 2019
by
Petr Menšík
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove few lines in unix socket handling
Reuse the same checks two times, make difference minimal.
parent
3365064f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
27 deletions
+15
-27
lib/isc/unix/socket.c
lib/isc/unix/socket.c
+15
-27
No files found.
lib/isc/unix/socket.c
View file @
cbe22be4
...
...
@@ -4290,22 +4290,33 @@ isc_socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
#define S_ISSOCK(mode) 0
#endif
if
(
active
)
{
if
(
stat
(
sockaddr
->
type
.
sunix
.
sun_path
,
&
sb
)
<
0
)
{
if
(
stat
(
sockaddr
->
type
.
sunix
.
sun_path
,
&
sb
)
<
0
)
{
switch
(
errno
)
{
case
ENOENT
:
if
(
active
)
/* We exited cleanly last time */
break
;
/* intentional falltrough */
default:
strerror_r
(
errno
,
strbuf
,
sizeof
(
strbuf
));
isc_log_write
(
isc_lctx
,
ISC_LOGCATEGORY_GENERAL
,
ISC_LOGMODULE_SOCKET
,
ISC_LOG_ERROR
,
ISC_LOGMODULE_SOCKET
,
active
?
ISC_LOG_ERROR
:
ISC_LOG_WARNING
,
"isc_socket_cleanunix: stat(%s): %s"
,
sockaddr
->
type
.
sunix
.
sun_path
,
strbuf
);
return
;
}
}
else
{
if
(
!
(
S_ISSOCK
(
sb
.
st_mode
)
||
S_ISFIFO
(
sb
.
st_mode
)))
{
isc_log_write
(
isc_lctx
,
ISC_LOGCATEGORY_GENERAL
,
ISC_LOGMODULE_SOCKET
,
ISC_LOG_ERROR
,
ISC_LOGMODULE_SOCKET
,
active
?
ISC_LOG_ERROR
:
ISC_LOG_WARNING
,
"isc_socket_cleanunix: %s: not a socket"
,
sockaddr
->
type
.
sunix
.
sun_path
);
return
;
}
}
if
(
active
)
{
if
(
unlink
(
sockaddr
->
type
.
sunix
.
sun_path
)
<
0
)
{
strerror_r
(
errno
,
strbuf
,
sizeof
(
strbuf
));
isc_log_write
(
isc_lctx
,
ISC_LOGCATEGORY_GENERAL
,
...
...
@@ -4326,29 +4337,6 @@ isc_socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
return
;
}
if
(
stat
(
sockaddr
->
type
.
sunix
.
sun_path
,
&
sb
)
<
0
)
{
switch
(
errno
)
{
case
ENOENT
:
/* We exited cleanly last time */
break
;
default:
strerror_r
(
errno
,
strbuf
,
sizeof
(
strbuf
));
isc_log_write
(
isc_lctx
,
ISC_LOGCATEGORY_GENERAL
,
ISC_LOGMODULE_SOCKET
,
ISC_LOG_WARNING
,
"isc_socket_cleanunix: stat(%s): %s"
,
sockaddr
->
type
.
sunix
.
sun_path
,
strbuf
);
break
;
}
goto
cleanup
;
}
if
(
!
(
S_ISSOCK
(
sb
.
st_mode
)
||
S_ISFIFO
(
sb
.
st_mode
)))
{
isc_log_write
(
isc_lctx
,
ISC_LOGCATEGORY_GENERAL
,
ISC_LOGMODULE_SOCKET
,
ISC_LOG_WARNING
,
"isc_socket_cleanunix: %s: not a socket"
,
sockaddr
->
type
.
sunix
.
sun_path
);
goto
cleanup
;
}
if
(
connect
(
s
,
(
const
struct
sockaddr
*
)
&
sockaddr
->
type
.
sunix
,
sizeof
(
sockaddr
->
type
.
sunix
))
<
0
)
{
switch
(
errno
)
{
...
...
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