mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 07:22:34 +00:00
Fixed unwanted recvfrom() with signal handler logs
This commit is contained in:
parent
77ef274f76
commit
eeeebe6cb2
4 changed files with 16 additions and 9 deletions
3
CHANGES
3
CHANGES
|
@ -56,6 +56,9 @@ Corrections:
|
|||
|
||||
Procan tries to find out VSOCK CID only when running as root
|
||||
|
||||
The mechanism for deferring logs from signal handlers had an issue that
|
||||
caused lots of unwanted recvfrom() calls.
|
||||
|
||||
Features:
|
||||
VSOCK, VSOCK-L support options pf, socktype, prototype (currently
|
||||
useless)
|
||||
|
|
15
error.c
15
error.c
|
@ -58,9 +58,9 @@ static void msg2(
|
|||
int level, int exitcode, int handler, const char *text);
|
||||
static void _msg(int level, const char *buff, const char *syslp);
|
||||
|
||||
sig_atomic_t diag_in_handler; /* !=0 indicates to msg() that in signal handler */
|
||||
sig_atomic_t diag_immediate_msg; /* !=0 prints messages even from within signal handler instead of deferring them */
|
||||
sig_atomic_t diag_immediate_exit; /* !=0 calls exit() from diag_exit() even when in signal handler. For system() */
|
||||
volatile sig_atomic_t diag_in_handler; /* !=0 indicates to msg() that in signal handler */
|
||||
volatile sig_atomic_t diag_immediate_msg; /* !=0 prints messages even from within signal handler instead of deferring them */
|
||||
volatile sig_atomic_t diag_immediate_exit; /* !=0 calls exit() from diag_exit() even when in signal handler. For system() */
|
||||
|
||||
static struct wordent facilitynames[] = {
|
||||
{"auth", (void *)LOG_AUTH},
|
||||
|
@ -108,7 +108,7 @@ struct sermsg {
|
|||
static int diaginitialized;
|
||||
static int diag_sock_send = -1;
|
||||
static int diag_sock_recv = -1;
|
||||
static int diag_msg_avail = 0; /* !=0: messages from within signal handler may be waiting */
|
||||
static volatile sig_atomic_t diag_msg_avail = 0; /* !=0: messages from within signal handler may be waiting */
|
||||
|
||||
|
||||
static int diag_sock_pair(void) {
|
||||
|
@ -278,7 +278,6 @@ void msg(int level, const char *format, ...) {
|
|||
/* in normal program flow (not in signal handler) */
|
||||
/* first flush the queue of datagrams from the socket */
|
||||
if (diag_msg_avail && !diag_in_handler) {
|
||||
diag_msg_avail = 0; /* _before_ flush to prevent inconsistent state when signal occurs inbetween */
|
||||
diag_flush();
|
||||
}
|
||||
|
||||
|
@ -418,6 +417,11 @@ void diag_flush(void) {
|
|||
struct diag_dgram recv_dgram;
|
||||
char exitmsg[20];
|
||||
|
||||
if (diag_msg_avail == 0) {
|
||||
return;
|
||||
}
|
||||
diag_msg_avail = 0;
|
||||
|
||||
if (!diagopts.signalsafe) {
|
||||
return;
|
||||
}
|
||||
|
@ -500,6 +504,7 @@ void diag_exit(int status) {
|
|||
|MSG_NOSIGNAL
|
||||
#endif
|
||||
);
|
||||
diag_msg_avail = 1;
|
||||
return;
|
||||
}
|
||||
_diag_exit(status);
|
||||
|
|
6
error.h
6
error.h
|
@ -228,9 +228,9 @@ struct diag_dgram {
|
|||
char text[TEXTLEN];
|
||||
} ;
|
||||
|
||||
extern sig_atomic_t diag_in_handler;
|
||||
extern sig_atomic_t diag_immediate_msg;
|
||||
extern sig_atomic_t diag_immediate_exit;
|
||||
extern volatile sig_atomic_t diag_in_handler;
|
||||
extern volatile sig_atomic_t diag_immediate_msg;
|
||||
extern volatile sig_atomic_t diag_immediate_exit;
|
||||
|
||||
extern void diag_set(char what, const char *arg);
|
||||
extern void diag_set_int(char what, int arg);
|
||||
|
|
1
socat.c
1
socat.c
|
@ -85,7 +85,6 @@ const char copyright_ssleay[] = "This product includes software written by Tim H
|
|||
|
||||
bool havelock;
|
||||
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
const char **arg1, *a;
|
||||
char *mainwaitstring;
|
||||
|
|
Loading…
Reference in a new issue