diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 12:57:38 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-12 23:34:17 +0100 |
commit | 513729bbab3faacfa4eb48b1572fce8ae413179e (patch) | |
tree | 605c454fe4f9595cb44869283d2d4e1b640961f8 | |
parent | 0d2888fb4950d7b3f1e19237f80a16a2253b37ec (diff) |
Unix: Implement SK_UNIX_ACTIVE
-rw-r--r-- | lib/socket.h | 1 | ||||
-rw-r--r-- | sysdep/unix/io.c | 35 |
2 files changed, 32 insertions, 4 deletions
diff --git a/lib/socket.h b/lib/socket.h index 96fedeeb..90006fd2 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -143,6 +143,7 @@ extern int sk_priority_control; /* Suggested priority for control traffic, shou #define SK_UNIX 9 #define SK_SSH_ACTIVE 10 /* - - * * - ? - DA = host */ #define SK_SSH 11 +#define SK_UNIX_ACTIVE 12 /* * Socket subtypes diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 14bf99fe..22c96d63 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -1050,6 +1050,14 @@ sk_tcp_connected(sock *s) s->tx_hook(s); } +static void +sk_unix_connected(sock *s) +{ + sk_alloc_bufs(s); + s->type = SK_UNIX; + s->tx_hook(s); +} + #ifdef HAVE_LIBSSH static void sk_ssh_connected(sock *s) @@ -1535,13 +1543,26 @@ sk_connect_unix(sock *s, char *name, socklen_t namelen) sa.sun_family = AF_UNIX; memcpy(sa.sun_path, name, namelen); - if (connect(fd, (struct sockaddr *) &sa, sizeof(sa.sun_family) + namelen) < 0) - return -1; - s->fd = fd; - s->type = SK_UNIX; + s->type = SK_UNIX_ACTIVE; + s->ttx = ""; /* Force s->ttx != s->tpos */ + + if (connect(fd, (struct sockaddr *) &sa, sizeof(sa.sun_family) + namelen) >= 0) + sk_unix_connected(s); + else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && + errno != ECONNREFUSED && errno != EHOSTUNREACH && errno != ENETUNREACH) + { + ERR2("connect"); + } + sk_insert(s); + /* sk_alloc_bufs(s); Shouldn't be needed with SK_UNIX_ACTIVE */ return 0; + + err: + close(fd); + s->fd = -1; + return -1; } @@ -1962,6 +1983,12 @@ sk_write(sock *s) return 0; } + case SK_UNIX_ACTIVE: + { + sk_unix_connected(s); + return 0; + } + #ifdef HAVE_LIBSSH case SK_SSH_ACTIVE: { |