mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 05:00:23 +00:00
lib: straight return on error on log open fail
I think I originally had some other code at the tail end of that function, but that's not the case anymore, and dropping out of the function with a straight "return -1" is more useful than trucking on with an invalid fd. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
5ce8577bd7
commit
e408a915a3
@ -877,14 +877,14 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
switch (zcf->dst) {
|
switch (zcf->dst) {
|
||||||
case ZLOG_5424_DST_NONE:
|
case ZLOG_5424_DST_NONE:
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
case ZLOG_5424_DST_FD:
|
case ZLOG_5424_DST_FD:
|
||||||
fd = dup(zcf->fd);
|
fd = dup(zcf->fd);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
"failed to dup() log file descriptor: %m (FD limit too low?)");
|
"failed to dup() log file descriptor: %m (FD limit too low?)");
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
optlen = sizeof(sock_type);
|
optlen = sizeof(sock_type);
|
||||||
@ -896,7 +896,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
case ZLOG_5424_DST_FIFO:
|
case ZLOG_5424_DST_FIFO:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
if (!zcf->file_nocreate) {
|
if (!zcf->file_nocreate) {
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
@ -909,7 +909,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
if (err == 0)
|
if (err == 0)
|
||||||
do_chown = true;
|
do_chown = true;
|
||||||
else if (errno != EEXIST)
|
else if (errno != EEXIST)
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = O_NONBLOCK;
|
flags = O_NONBLOCK;
|
||||||
@ -917,7 +917,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
|
|
||||||
case ZLOG_5424_DST_FILE:
|
case ZLOG_5424_DST_FILE:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
fd = open(zcf->filename, flags | O_WRONLY | O_APPEND |
|
fd = open(zcf->filename, flags | O_WRONLY | O_APPEND |
|
||||||
@ -929,7 +929,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
"could not open log file %pSE: %m",
|
"could not open log file %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
break;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
frr_with_privs (lib_privs) {
|
frr_with_privs (lib_privs) {
|
||||||
@ -957,11 +957,11 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
flog_err_sys(EC_LIB_SYSTEM_CALL,
|
||||||
"could not open or create log file %pSE: %m",
|
"could not open or create log file %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
case ZLOG_5424_DST_UNIX:
|
case ZLOG_5424_DST_UNIX:
|
||||||
if (!zcf->filename)
|
if (!zcf->filename)
|
||||||
break;
|
return -1;
|
||||||
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
memset(&sa, 0, sizeof(sa));
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
@ -993,6 +993,7 @@ static int zlog_5424_open(struct zlog_cfg_5424 *zcf, int sock_type)
|
|||||||
"could not connect to log unix path %pSE: %m",
|
"could not connect to log unix path %pSE: %m",
|
||||||
zcf->filename);
|
zcf->filename);
|
||||||
need_reconnect = true;
|
need_reconnect = true;
|
||||||
|
/* no return -1 here, trigger retry code below */
|
||||||
} else {
|
} else {
|
||||||
/* datagram sockets are connectionless, restarting
|
/* datagram sockets are connectionless, restarting
|
||||||
* the receiver may lose some packets but will resume
|
* the receiver may lose some packets but will resume
|
||||||
|
Loading…
Reference in New Issue
Block a user