diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 18:38:10 +0200 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-05-14 18:38:10 +0200 |
commit | 21a1a3ec1b319b1109a7d876cf946354d7b14c9b (patch) | |
tree | 6252e35cbaf5fa5cfdeba45ef40382593fbfd20a /sysdep | |
parent | 055b6e89fa1be9fbcce1821196b6502cf78f6108 (diff) |
WIP implement SK_UNIX_ACTIVE
Diffstat (limited to 'sysdep')
-rw-r--r-- | sysdep/unix/io.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 1a659567..814fa1ec 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -1052,6 +1052,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) @@ -1557,13 +1565,20 @@ sk_connect_unix(sock *s, char *name, socklen_t namelen) memcpy(sa.sun_path, name, namelen); hexdump((const char*)&sa, sizeof(sa.sun_family) + namelen); - if (connect(fd, (struct sockaddr *) &sa, sizeof(sa.sun_family) + namelen) < 0) - return -4; + + s->fd = fd; + 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"); + break; log(L_TRACE "sk_connect_unix 5"); - s->fd = fd; - s->type = SK_UNIX; sk_insert(s); sk_alloc_bufs(s); return 0; @@ -1987,6 +2002,12 @@ sk_write(sock *s) return 0; } + case SK_UNIX_ACTIVE: + { + sk_unix_connected(s); + return 0; + } + #ifdef HAVE_LIBSSH case SK_SSH_ACTIVE: { |