Commit 20bd79b4 authored by Niels Möller's avatar Niels Möller

*** empty log message ***

Rev: ChangeLog:1.336.2.6
Rev: NEWS:1.76.2.3
Rev: src/io.c:1.128.2.2
parent a7f0089f
2001-05-23 Niels Mller <nisse@lysator.liu.se>
* src/xalloc.h (CHECK_TYPE) [!DEBUG_ALLOC]: Cast to (struct
lsh_object *).
(CHECK_SUBTYPE) [!DEBUG_ALLOC]: Likewise. XXX: Fix in main branch.
* src/io_commands.c (do_listen): Updated for changes to
address_info2sockaddr and io_listen.
(do_connect): Updated for changes to
address_info2sockaddr and io_connect.
* src/io.c (choose_address): Try creating a socket of the
appropriate type. XXX: Fix in some way or other in the main
branch.
(address_info2sockaddr): Added argument for returning an
appropriate socket.
(address_info2sockaddr) [WITH_IPV6]: Pass on argument to choose_address.
(address_info2sockaddr) [!WITH_IPV6]: Create socket.
(io_connect): Added socket argument.
(io_listen): Likewise.
(io_listen_local): Updated for the io_listen change.
(io_connect_local): Updated for the io_connect change.
2001-05-11 Niels Mller <nisse@cuckoo.hack.org>
* configure.in: Bumped version to 1.2.2.
......
News for the 1.2.3 release:
An lshd compiled with IPv6 support didn't work on machines
without IPv6. Fixed.
News for the 1.2.2 release:
Fixed the lshd --daemon feature.
......
......@@ -1159,7 +1159,8 @@ sockaddr2info(size_t addr_len UNUSED,
#if HAVE_GETADDRINFO
static struct addrinfo *
choose_address(struct addrinfo *list,
const int *preference)
const int *preference,
int *s)
{
int i;
for (i = 0; preference[i]; i++)
......@@ -1167,7 +1168,12 @@ choose_address(struct addrinfo *list,
struct addrinfo *p;
for (p = list; p; p = p->ai_next)
if (preference[i] == p->ai_family)
return p;
{
*s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if (*s<0)
continue;
return p;
}
}
return NULL;
}
......@@ -1178,8 +1184,7 @@ choose_address(struct addrinfo *list,
struct sockaddr *
address_info2sockaddr(socklen_t *length,
struct address_info *a,
/* Preferred address families. Zero-terminated array. */
const int *preference,
int *s,
int lookup)
{
char *host;
......@@ -1234,7 +1239,7 @@ address_info2sockaddr(socklen_t *length,
}
chosen = choose_address(list,
preference ? preference : default_preference);
default_preference, s);
if (!chosen)
{
freeaddrinfo(list);
......@@ -1307,6 +1312,15 @@ address_info2sockaddr(socklen_t *length,
memcpy(&addr->sin_addr, hp->h_addr, hp->h_length);
}
}
if (addr)
{
*s = socket(AF_INET, SOCK_STREAM, 0);
if (*s < 0)
{
lsh_space_free(addr);
addr = NULL;
}
}
return (struct sockaddr *) addr;
}
#endif /* !HAVE_GETADDRINFO */
......@@ -1376,16 +1390,15 @@ make_lsh_fd(struct io_backend *b,
/* Some code is taken from Thomas Bellman's tcputils. */
struct lsh_fd *
io_connect(struct io_backend *b,
int s,
struct sockaddr *remote,
socklen_t remote_length,
struct command_continuation *c,
struct exception_handler *e)
{
int s = socket(remote->sa_family, SOCK_STREAM, 0);
struct lsh_fd *fd;
if (s<0)
return NULL;
assert(s >= 0);
trace("io.c: Connecting using fd %i\n", s);
......@@ -1420,16 +1433,15 @@ io_connect(struct io_backend *b,
struct lsh_fd *
io_listen(struct io_backend *b,
int s,
struct sockaddr *local,
socklen_t length,
struct io_callback *callback,
struct exception_handler *e)
{
int s = socket(local->sa_family, SOCK_STREAM, 0);
struct lsh_fd *fd;
if (s<0)
return NULL;
assert(s >= 0);
trace("io.c: Listening on fd %i\n", s);
......@@ -1587,6 +1599,7 @@ io_listen_local(struct io_backend *b,
struct sockaddr_un *local;
socklen_t local_length;
int s;
struct lsh_fd *fd;
assert(info->directory && NUL_TERMINATED(info->directory));
......@@ -1627,7 +1640,10 @@ io_listen_local(struct io_backend *b,
old_umask = umask(0077);
/* Bind and listen */
fd = io_listen(b, (struct sockaddr *) local, local_length, callback, e);
s = socket(AF_UNIX, SOCK_STREAM, 0);
fd = ( (s >= 0)
? io_listen(b, s, (struct sockaddr *) local, local_length, callback, e)
: NULL);
/* Ok, now we restore umask and cwd */
umask(old_umask);
......@@ -1649,6 +1665,7 @@ io_connect_local(struct io_backend *b,
struct sockaddr_un *addr;
socklen_t addr_length;
int s;
struct lsh_fd *fd;
assert(info->directory && NUL_TERMINATED(info->directory));
......@@ -1669,8 +1686,11 @@ io_connect_local(struct io_backend *b,
old_cd = safe_pushd(info->directory->data, 0);
if (old_cd < 0)
return NULL;
fd = io_connect(b, (struct sockaddr *) addr, addr_length, c, e);
s = socket(AF_UNIX, SOCK_STREAM, 0);
fd = ( (s >= 0)
? io_connect(b, s, (struct sockaddr *) addr, addr_length, c, e)
: NULL);
safe_popd(old_cd, info->directory->data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment