ev_connects.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1997-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* ev_connects.c - implement asynch connect/accept for the eventlib
* vix 16sep96 [initial]
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: ev_connects.c,v 8.32 2001/07/03 13:26:35 marka Exp $";
#endif
/* Import. */
#include "port_before.h"
#include "fd_setsize.h"
#include <unistd.h>
#include <isc/eventlib.h>
#include <isc/assertions.h>
#include "eventlib_p.h"
#include "port_after.h"
/* Macros. */
0 \
) \
)
/* Forward. */
/* Public. */
int
{
int mode;
/*
* Remember the nonblocking status. We assume that either evSelectFD
* has not been done to this fd, or that if it has then the caller
* will evCancelConn before they evDeselectFD. If our assumptions
* are not met, then we might restore the old nonblocking status
* incorrectly.
*/
if ((mode & PORT_NONBLOCK) == 0) {
#ifdef USE_FIONBIO_IOCTL
int on = 1;
#else
#endif
}
return (-1);
}
if (id)
return (0);
}
int
{
/* Do the select() first to get the socket into nonblocking mode. */
return (-1);
}
errno != EWOULDBLOCK &&
errno != EINPROGRESS) {
return (-1);
}
/* No error, or EWOULDBLOCK. select() tells when it's ready. */
if (id)
return (0);
}
int
int mode;
if (mode == -1) {
return (-1);
} else {
#ifdef USE_FIONBIO_IOCTL
int on = 1;
#else
#endif
}
}
/* Unlink from ctx->conns. */
else
/*
* Remove `this' from the ctx->accepts list (zero or more times).
*/
{
}
}
/* Wrap up and get out. */
return (0);
}
return (-1);
}
return (0);
}
int ret;
return (-1);
}
return (0);
if (ret == 0)
return (ret);
}
int
return (-1);
}
}
} else
} else {
return (-1);
}
}
return (0);
}
/* Private. */
static void
union {
struct sockaddr_in in;
#ifndef NO_SOCKADDR_UN
struct sockaddr_un un;
#endif
int new;
new = -1;
}
if (new >= 0) {
new = -1;
}
return;
}
static void
union {
struct sockaddr_in in;
#ifndef NO_SOCKADDR_UN
struct sockaddr_un un;
#endif
char buf[1];
void *conn_uap;
int socket_errno = 0;
#ifdef SO_ERROR
optlen = sizeof socket_errno;
if (fd < 0 &&
&optlen) < 0)
else
#endif
socket_errno ||
#ifdef NETREAD_BROKEN
0 ||
#else
#endif
fd = -1;
}
}