mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
criu: print correct errno messages from pr_perror()
"%m" can't be used to print strerror(errno), because print_on_level()
calls gettimeofday() which can overwrite errno.
For example:
13486 connect(4, {sa_family=AF_INET, sin_port=htons(8880), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ENETUNREACH (Network is unreachable)
13486 gettimeofday({1423756664, 717423}, NULL) = 0
13486 open("/etc/localtime", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
13486 write(2, "15:57:44.717: 4: ERR: socket_udp.c:73: Can't connect (errno = 101 (Permission denied))\n", 91) = 91
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
9a392dff3a
commit
3f23bde548
3 changed files with 14 additions and 3 deletions
|
|
@ -20,6 +20,13 @@
|
|||
#ifndef __CRIU_LOG_H__
|
||||
#define __CRIU_LOG_H__
|
||||
|
||||
#ifndef CR_NOGLIBC
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#endif /* CR_NOGLIBC */
|
||||
|
||||
#define LOG_UNSET (-1)
|
||||
#define LOG_MSG (0) /* Print message regardless of log level */
|
||||
#define LOG_ERROR (1) /* Errors only, when we're in trouble */
|
||||
|
|
@ -74,7 +81,11 @@ extern void print_on_level(unsigned int loglevel, const char *format, ...)
|
|||
print_on_level(LOG_DEBUG, \
|
||||
LOG_PREFIX fmt, ##__VA_ARGS__)
|
||||
|
||||
#ifndef CR_NOGLIBC
|
||||
|
||||
#define pr_perror(fmt, ...) \
|
||||
pr_err(fmt ": %m\n", ##__VA_ARGS__)
|
||||
pr_err(fmt ": %s\n", ##__VA_ARGS__, strerror(errno))
|
||||
|
||||
#endif /* CR_NOGLIBC */
|
||||
|
||||
#endif /* __CR_LOG_LEVELS_H__ */
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ static inline void tcp_repair_off(int fd)
|
|||
|
||||
ret = sys_setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux));
|
||||
if (ret < 0)
|
||||
pr_perror("Failed to turn off repair mode on socket (%d)", ret);
|
||||
pr_err("Failed to turn off repair mode on socket (%d)", ret);
|
||||
}
|
||||
|
||||
extern void tcp_locked_conn_add(struct inet_sk_info *);
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ static void rst_tcp_repair_off(struct rst_tcp_sock *rts)
|
|||
|
||||
ret = sys_setsockopt(rts->sk, SOL_SOCKET, SO_REUSEADDR, &aux, sizeof(aux));
|
||||
if (ret < 0)
|
||||
pr_perror("Failed to restore of SO_REUSEADDR on socket (%d)", ret);
|
||||
pr_err("Failed to restore of SO_REUSEADDR on socket (%d)", ret);
|
||||
}
|
||||
|
||||
static void rst_tcp_socks_all(struct task_restore_args *ta)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue