summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-08-31 21:38:23 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2023-08-24 16:40:09 +0200
commit5b49aa37acdd3a9c8935fbcdbe95d1e9207ce56c (patch)
tree67f02b7a82658aa8b5b39d5192d07188162da610 /sysdep/unix
parent6c4b6ee21a0ed81a5310acbfcadb7c13ac248620 (diff)
Unix: debug
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c30
-rw-r--r--sysdep/unix/main.c3
2 files changed, 32 insertions, 1 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index e5450fe9..3e3bedb2 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -810,6 +810,8 @@ sk_free(resource *r)
{
sock *s = (sock *) r;
+ log(L_TRACE "sk_free %d %d", s->fd, s->type);
+
sk_free_bufs(s);
#ifdef HAVE_LIBSSH
@@ -1537,18 +1539,35 @@ sk_open_unix(sock *s, char *name)
return 0;
}
+static void hexdump(const char *data, socklen_t size)
+{
+ char buf[1024]="";
+
+ for (unsigned int i = 0; i < size; i++)
+ {
+ sprintf(buf + i*3, "%02x ", data[i]);
+ }
+ log(L_TRACE "sk_connect_unix: %s", buf);
+}
+
int
sk_connect_unix(sock *s, char *name, socklen_t namelen)
{
struct sockaddr_un sa;
int fd;
+ log(L_TRACE "sk_connect_unix %d %s", name[0], name + 1);
+
if (namelen > sizeof(sa.sun_path))
return -1;
+ log(L_TRACE "sk_connect_unix 2");
+
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
- return -1;
+ return -2;
+
+ log(L_TRACE "sk_connect_unix 3");
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
{
@@ -1556,11 +1575,15 @@ sk_connect_unix(sock *s, char *name, socklen_t namelen)
return -3;
}
+ log(L_TRACE "sk_connect_unix 4");
+
/* Path length checked in test_old_bird() */
memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX;
memcpy(sa.sun_path, name, namelen);
+ hexdump((const char*)&sa, sizeof(sa.sun_family) + namelen);
+
s->fd = fd;
s->type = SK_UNIX_ACTIVE;
s->ttx = ""; /* Force s->ttx != s->tpos */
@@ -1573,6 +1596,8 @@ sk_connect_unix(sock *s, char *name, socklen_t namelen)
ERR2("connect");
}
+ log(L_TRACE "sk_connect_unix 5");
+
sk_insert(s);
return 0;
@@ -1947,7 +1972,10 @@ sk_read_noflush(sock *s, int revents)
}
}
else if (!c)
+ {
+ if (s->type == SK_UNIX) log(L_TRACE "Unix socket nothing to read");
s->err_hook(s, 0);
+ }
else
{
s->rpos += c;
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
index 139aef35..208d3173 100644
--- a/sysdep/unix/main.c
+++ b/sysdep/unix/main.c
@@ -605,6 +605,7 @@ unlink_pid_file(void)
void
cmd_shutdown(void)
{
+ log_msg(L_INFO "cmd_shutdown");
if (cli_access_restricted())
return;
@@ -615,6 +616,7 @@ cmd_shutdown(void)
void
async_shutdown(void)
{
+ log_msg(L_INFO "async_shutdown");
DBG("Shutting down...\n");
order_shutdown(0);
}
@@ -622,6 +624,7 @@ async_shutdown(void)
void
sysdep_shutdown_done(void)
{
+ log_msg(L_INFO "sysdep_shutdown_done");
unlink_pid_file();
unlink(path_control_socket);
log_msg(L_FATAL "Shutdown completed");