int check_connection_completion(int fd) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10); struct pollfd pfd; int retval; pfd.fd = fd; pfd.events = POLLOUT; #ifndef _WIN32 do { retval = poll(&pfd, 1, 0); } while (retval < 0 && errno == EINTR); #else retval = WSAPoll(&pfd, 1, 0); #endif if (retval == 1) { if (pfd.revents & POLLERR) { ssize_t n = send(fd, "", 1, 0); if (n < 0) { return sock_errno(); } else { VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded"); return EPROTO; } } return 0; } else if (retval < 0) { VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(sock_errno())); return errno; } else { return EAGAIN; } }
void acceptex_thread() { long sock_accex, recvd = 0; long locallen,clilen; char *Outbuff; int alloc = 1024; struct sockaddr_in local; struct sockaddr_in cli_addr; locallen = sizeof(local); clilen = sizeof(cli_addr); Outbuff = (char*) malloc( alloc ); if (Outbuff == NULL) { printf("malloc error"); total_threads++; exit(0); } Begin: sock_accex = -1; recvd = accept_and_recv(sockfd,&sock_accex,(struct sockaddr *)&cli_addr, &clilen,(struct sockaddr *)&local,&locallen,Outbuff,alloc); if(recvd < 0) { printf("error in acceptex recv= %d\n",sock_errno()); total_threads++; goto Begin; locallen = sizeof(local); clilen = sizeof(cli_addr); alloc =1024; recvd = accept_and_recv(sockfd,&sock_accex,(struct sockaddr *)&cli_addr, &clilen,(struct sockaddr *)&local,&locallen,Outbuff,alloc); if(recvd < 0) { printf("error in acceptex recv= %d\n",sock_errno()); } else { locallen = sizeof(local); clilen = sizeof(cli_addr); alloc =1024; recvd = accept_and_recv(sockfd,&sock_accex,(struct sockaddr *)&cli_addr, &clilen,(struct sockaddr *)&local,&locallen,Outbuff,alloc); if(recvd < 0) printf("error in acceptex recv= %d\n",sock_errno()); } } printf(" Local addr :%x, Local_addr_len :%d\n",local.sin_addr.s_addr,locallen); printf(" Bytes recieved with acceptex :%d\n",recvd); printf(" Msg recvd with acceptex :%s\n",Outbuff); printf(" Recv socket Id :%d\n",sock_accex); printf("Before soclose\n"); soclose(sock_accex); printf("after soclose\n"); total_threads++; return ; }
static int packet_socket(struct sock *sk, int type, int proto) { struct packet_priv *priv = rte_malloc(NULL, sizeof(*sk->priv), 0); if (!priv) return sock_errno(sk, ENOMEM); priv->type = type; sk->priv = priv; return sock_errno(sk, 0); }
int check_connection_completion(int fd) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 10); struct pollfd pfd; int retval; pfd.fd = fd; pfd.events = POLLOUT; #ifndef _WIN32 do { retval = poll(&pfd, 1, 0); } while (retval < 0 && errno == EINTR); #else fd_set wrset, exset; FD_ZERO(&wrset); FD_ZERO(&exset); FD_SET(fd, &exset); FD_SET(fd, &wrset); pfd.revents = 0; struct timeval tv = { 0, 0 }; /* WSAPoll is broken on Windows, instead do a select */ retval = select(0, NULL, &wrset, &exset, &tv); if (retval == 1) { if (FD_ISSET(fd, &wrset)) { pfd.revents |= pfd.events; } if (FD_ISSET(fd, &exset)) { pfd.revents |= POLLERR; } } #endif if (retval == 1) { if (pfd.revents & POLLERR) { ssize_t n = send(fd, "", 1, 0); if (n < 0) { return sock_errno(); } else { VLOG_ERR_RL(&rl, "poll return POLLERR but send succeeded"); return EPROTO; } } return 0; } else if (retval < 0) { VLOG_ERR_RL(&rl, "poll: %s", sock_strerror(sock_errno())); return errno; } else { return EAGAIN; } }
APR_DECLARE(apr_status_t) apr_socket_sendv(apr_socket_t *sock, const struct iovec *vec, apr_int32_t nvec, apr_size_t *len) { apr_status_t rv; struct iovec *tmpvec; int fds, err = 0; int nv_tosend, total = 0; /* Make sure writev() only gets fed 64k at a time */ for ( nv_tosend = 0; nv_tosend < nvec && total + vec[nv_tosend].iov_len < 65536; nv_tosend++ ) { total += vec[nv_tosend].iov_len; } tmpvec = alloca(sizeof(struct iovec) * nv_tosend); memcpy(tmpvec, vec, sizeof(struct iovec) * nv_tosend); do { if (!sock->nonblock || err == SOCEWOULDBLOCK) { fds = sock->socketdes; rv = select(&fds, 0, 1, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); if (rv != 1) { *len = 0; err = sock_errno(); if (rv == 0) return APR_TIMEUP; if (err == SOCEINTR) continue; return APR_OS2_STATUS(err); } } rv = writev(sock->socketdes, tmpvec, nv_tosend); err = rv < 0 ? sock_errno() : 0; } while (err == SOCEINTR || err == SOCEWOULDBLOCK); if (err) { *len = 0; return APR_OS2_STATUS(err); } *len = rv; return APR_SUCCESS; }
static int tlso_bio_read( BIO *b, char *buf, int len ) { struct tls_data *p; int ret; if ( buf == NULL || len <= 0 ) return 0; p = (struct tls_data *)BIO_get_data(b); if ( p == NULL || p->sbiod == NULL ) { return 0; } ret = LBER_SBIOD_READ_NEXT( p->sbiod, buf, len ); BIO_clear_retry_flags( b ); if ( ret < 0 ) { int err = sock_errno(); if ( err == EAGAIN || err == EWOULDBLOCK ) { BIO_set_retry_read( b ); } } return ret; }
/* protected by conn_mutex */ int ldap_int_flush_request( LDAP *ld, LDAPRequest *lr ) { LDAPConn *lc = lr->lr_conn; LDAP_ASSERT_MUTEX_OWNER( &ld->ld_conn_mutex ); if ( ber_flush2( lc->lconn_sb, lr->lr_ber, LBER_FLUSH_FREE_NEVER ) != 0 ) { if ( sock_errno() == EAGAIN ) { /* need to continue write later */ lr->lr_status = LDAP_REQST_WRITING; ldap_mark_select_write( ld, lc->lconn_sb ); ld->ld_errno = LDAP_BUSY; return -2; } else { ld->ld_errno = LDAP_SERVER_DOWN; ldap_free_request( ld, lr ); ldap_free_connection( ld, lc, 0, 0 ); return( -1 ); } } else { if ( lr->lr_parent == NULL ) { lr->lr_ber->ber_end = lr->lr_ber->ber_ptr; lr->lr_ber->ber_ptr = lr->lr_ber->ber_buf; } lr->lr_status = LDAP_REQST_INPROGRESS; /* sent -- waiting for a response */ ldap_mark_select_read( ld, lc->lconn_sb ); ldap_clear_select_write( ld, lc->lconn_sb ); } return 0; }
/* * xstrerror() - sock_errno/strerror-like wrapper */ const char * xstrerror_a(void) { int ierr; ierr = sock_errno(); return xbstrerror_i(ierr); }
static int new_tcp_stream(const char *name, int fd, int connect_status, struct stream **streamp) { struct sockaddr_storage local; socklen_t local_len = sizeof local; int on = 1; int retval; /* Get the local IP and port information */ retval = getsockname(fd, (struct sockaddr *) &local, &local_len); if (retval) { memset(&local, 0, sizeof local); } retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on); if (retval) { int error = sock_errno(); VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, sock_strerror(error)); close(fd); return error; } return new_fd_stream(name, fd, connect_status, streamp); }
static int packet_bind(struct sock *sk, const struct sockaddr *a, socklen_t addrlen) { struct sockaddr_ll *addr = (struct sockaddr_ll *)a; struct net_device *dev = NULL; if (addrlen != sizeof(*addr)) return sock_errno(sk, EINVAL); if (addr->sll_ifindex) { dev = netdev_get_by_index(addr->sll_ifindex); if (!dev) return sock_errno(sk, ENODEV); } return sock_errno(sk, 0); }
/* Sets the DSCP value of socket 'fd' to 'dscp', which must be 63 or less. * 'family' must indicate the socket's address family (AF_INET or AF_INET6, to * do anything useful). */ int set_dscp(int fd, int family, uint8_t dscp) { int retval; int val; #ifdef _WIN32 /* XXX: Consider using QoS2 APIs for Windows to set dscp. */ return 0; #endif if (dscp > 63) { return EINVAL; } val = dscp << 2; switch (family) { case AF_INET: retval = setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val); break; case AF_INET6: retval = setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &val, sizeof val); break; default: return ENOPROTOOPT; } return retval ? sock_errno() : 0; }
/* Converts a string containing a valid internet address using dotted-decimal notation or host name into an internet address number typed as an unsigned long value. A -1 value indicates an error. */ u_long XIOsocket::get_address(const char* hostname) { u_long address; struct hostent* entry; if (!hostname) { errno = HBASEERR + HOST_NOT_FOUND; return (u_long)-1L; } if ((address = inet_addr((char*)hostname)) == (u_long)-1L) { if ((entry = gethostbyname((char*)hostname)) != NULL) { memcpy( &address, entry->h_addr, sizeof( address )); } else { #ifdef NETDB_INTERNAL if (h_errno == NETDB_INTERNAL) errno = sock_errno(); else #endif errno = h_errno + HBASEERR; } } return address; }
static int tlso_bio_write( BIO *b, const char *buf, int len ) { struct tls_data *p; int ret; if ( buf == NULL || len <= 0 ) return 0; p = (struct tls_data *)b->ptr; if ( p == NULL || p->sbiod == NULL ) { return 0; } ret = LBER_SBIOD_WRITE_NEXT( p->sbiod, (char *)buf, len ); BIO_clear_retry_flags( b ); if ( ret < 0 ) { int err = sock_errno(); if ( err == EAGAIN || err == EWOULDBLOCK ) { BIO_set_retry_write( b ); } } return ret; }
static ber_slen_t sb_debug_write( Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len ) { ber_slen_t ret; char ebuf[128]; ret = LBER_SBIOD_WRITE_NEXT( sbiod, buf, len ); if (sbiod->sbiod_sb->sb_debug & LDAP_DEBUG_PACKETS) { int err = sock_errno(); if ( ret < 0 ) { ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug, "%swrite: want=%ld error=%s\n", (char *)sbiod->sbiod_pvt, (long)len, AC_STRERROR_R( err, ebuf, sizeof ebuf ) ); } else { ber_log_printf( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug, "%swrite: want=%ld, written=%ld\n", (char *)sbiod->sbiod_pvt, (long)len, (long)ret ); ber_log_bprint( LDAP_DEBUG_PACKETS, sbiod->sbiod_sb->sb_debug, (const char *)buf, ret ); } sock_errset(err); } return ret; }
/* Sets 'fd' to non-blocking mode. Returns 0 if successful, otherwise a * positive errno value. */ int set_nonblocking(int fd) { #ifndef _WIN32 int flags = fcntl(fd, F_GETFL, 0); if (flags != -1) { if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) != -1) { return 0; } else { VLOG_ERR("fcntl(F_SETFL) failed: %s", ovs_strerror(errno)); return errno; } } else { VLOG_ERR("fcntl(F_GETFL) failed: %s", ovs_strerror(errno)); return errno; } #else unsigned long arg = 1; if (ioctlsocket(fd, FIONBIO, &arg)) { int error = sock_errno(); VLOG_ERR("set_nonblocking failed: %s", sock_strerror(error)); return error; } return 0; #endif }
ber_slen_t ber_int_sb_write( Sockbuf *sb, void *buf, ber_len_t len ) { ber_slen_t ret; assert( buf != NULL ); assert( sb != NULL); assert( sb->sb_iod != NULL ); assert( SOCKBUF_VALID( sb ) ); for (;;) { ret = sb->sb_iod->sbiod_io->sbi_write( sb->sb_iod, buf, len ); #ifdef EINTR if ( ret < 0 ) { #ifdef HAVE_WINSOCK // on Windows, errno is NOT set by send call automatically. if ( (errno = sock_errno()) == WSAEINTR) { errno = EINTR; } #endif if( errno == EINTR ) continue; } #endif break; } return ret; }
/* Receives bytes on a socket up to the first new-line character (\n) or until the number of bytes received is equal to n-1, whichever comes first. Stores the result in string and adds a null character (\0) to the end of the string. If n is equal to 1, the string is empty. Returns a pointer to the string buffer if successful. A NULL return value indicates an error or that the connection is closed.*/ char* XIOsocket::gets(char* buffer, unsigned int size) { unsigned int done = 0; char* p = buffer; DEBUGLOG(("XIOsocket(%p{%d})::gets(%p, %d)\n", this, s_handle, buffer, size)); while (done < size - 1) { #ifdef TCPV40HDRS // Work around for missing SO_RCVTIMEO in 16 bit IP stack. struct timeval timeout = {0}; timeout.tv_sec = xio_socket_timeout(); if (timeout.tv_sec) { fd_set waitlist; FD_ZERO(&waitlist); FD_SET (s_handle, &waitlist); switch (select(s_handle+1, &waitlist, NULL, NULL, &timeout)) { case 0: // Timeout seterror(SOCETIMEDOUT); return NULL; case -1: // Error seterror(); return NULL; } } #endif int rc = recv(s_handle, p, 1, 0); if( rc == 1 ) { if (*p == '\r') continue; else if(*p == '\n') break; else { ++p; ++done; } } else { DEBUGLOG(("XIOsocket::gets: error %d\n", sock_errno())); if (!done) { if (rc == 0) eof = true; else seterror(); return NULL; } else break; } } *p = 0; DEBUGLOG(("XIOsocket::gets: %s\n", buffer)); return buffer; }
/* Translates 'host_name', which must be a host name or a string representation * of an IP address, into a numeric IP address in '*addr'. Returns 0 if * successful, otherwise a positive errno value. * * Most Open vSwitch code should not use this because it causes deadlocks: * getaddrinfo() sends out a DNS request but that starts a new flow for which * OVS must set up a flow, but it can't because it's waiting for a DNS reply. * The synchronous lookup also delays other activity. (Of course we can solve * this but it doesn't seem worthwhile quite yet.) */ int lookup_hostname(const char *host_name, struct in_addr *addr) { struct addrinfo *result; struct addrinfo hints; if (ip_parse(host_name, &addr->s_addr)) { return 0; } memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; switch (getaddrinfo(host_name, NULL, &hints, &result)) { case 0: *addr = ALIGNED_CAST(struct sockaddr_in *, result->ai_addr)->sin_addr; freeaddrinfo(result); return 0; #ifdef EAI_ADDRFAMILY case EAI_ADDRFAMILY: #endif case EAI_NONAME: case EAI_SERVICE: return ENOENT; case EAI_AGAIN: return EAGAIN; case EAI_BADFLAGS: case EAI_FAMILY: case EAI_SOCKTYPE: return EINVAL; case EAI_FAIL: return EIO; case EAI_MEMORY: return ENOMEM; #if defined (EAI_NODATA) && EAI_NODATA != EAI_NONAME case EAI_NODATA: return ENXIO; #endif #ifdef EAI_SYSTEM case EAI_SYSTEM: return sock_errno(); #endif default: return EPROTO; } }
PRStatus _MD_OS2GetHostName(char *name, PRUint32 namelen) { PRIntn rv; rv = gethostname(name, (PRInt32) namelen); if (0 == rv) { return PR_SUCCESS; } _PR_MD_MAP_GETHOSTNAME_ERROR(sock_errno()); return PR_FAILURE; }
APR_DECLARE(apr_status_t) apr_socket_send(apr_socket_t *sock, const char *buf, apr_size_t *len) { apr_ssize_t rv; int fds, err = 0; if (*len > 65536) { *len = 65536; } do { if (!sock->nonblock || err == SOCEWOULDBLOCK) { fds = sock->socketdes; rv = select(&fds, 0, 1, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); if (rv != 1) { *len = 0; err = sock_errno(); if (rv == 0) return APR_TIMEUP; if (err == SOCEINTR) continue; return APR_OS2_STATUS(err); } } rv = send(sock->socketdes, buf, (*len), 0); err = rv < 0 ? sock_errno() : 0; } while (err == SOCEINTR || err == SOCEWOULDBLOCK); if (err) { *len = 0; return APR_OS2_STATUS(err); } (*len) = rv; return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark) { int oobmark; if (ioctl(sock->socketdes, SIOCATMARK, (void*)&oobmark, sizeof(oobmark)) < 0) { return APR_OS2_STATUS(sock_errno()); } *atmark = (oobmark != 0); return APR_SUCCESS; }
void setsockopt_tcp_nodelay(int fd) { int on = 1; int retval; retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on); if (retval) { retval = sock_errno(); VLOG_ERR("setsockopt(TCP_NODELAY): %s", sock_strerror(retval)); } }
APR_DECLARE(apr_status_t) apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock, apr_int32_t flags, char *buf, apr_size_t *len) { apr_ssize_t rv; int serrno; do { rv = recvfrom(sock->socketdes, buf, (*len), flags, (struct sockaddr*)&from->sa, &from->salen); } while (rv == -1 && (serrno = sock_errno()) == EINTR); if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1); if (arv != APR_SUCCESS) { *len = 0; return arv; } else { do { rv = recvfrom(sock->socketdes, buf, *len, flags, (struct sockaddr*)&from->sa, &from->salen); } while (rv == -1 && (serrno = sock_errno()) == EINTR); } } if (rv == -1) { (*len) = 0; return APR_FROM_OS_ERROR(serrno); } (*len) = rv; if (rv == 0 && sock->type == SOCK_STREAM) return APR_EOF; return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont) { if (gethostname(buf, len) == -1) { buf[0] = '\0'; return APR_OS2_STATUS(sock_errno()); } else if (!memchr(buf, '\0', len)) { /* buffer too small */ buf[0] = '\0'; return APR_ENAMETOOLONG; } return APR_SUCCESS; }
int set_dscp(int fd, uint8_t dscp) { int val; bool success; #ifdef _WIN32 /* XXX: Consider using QoS2 APIs for Windows to set dscp. */ return 0; #endif if (dscp > 63) { return EINVAL; } /* Note: this function is used for both of IPv4 and IPv6 sockets */ success = false; val = dscp << 2; if (setsockopt(fd, IPPROTO_IP, IP_TOS, &val, sizeof val)) { if (sock_errno() != ENOPROTOOPT) { return sock_errno(); } } else { success = true; } if (setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &val, sizeof val)) { if (sock_errno() != ENOPROTOOPT) { return sock_errno(); } } else { success = true; } if (!success) { return ENOPROTOOPT; } return 0; }
APR_DECLARE(apr_status_t) apr_socket_opt_set(apr_socket_t *sock, apr_int32_t opt, apr_int32_t on) { int one; struct linger li; if (on) one = 1; else one = 0; if (opt & APR_SO_KEEPALIVE) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_KEEPALIVE, (void *)&one, sizeof(int)) == -1) { return APR_OS2_STATUS(sock_errno()); } } if (opt & APR_SO_DEBUG) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_DEBUG, (void *)&one, sizeof(int)) == -1) { return APR_OS2_STATUS(sock_errno()); } } if (opt & APR_SO_REUSEADDR) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(int)) == -1) { return APR_OS2_STATUS(sock_errno()); } } if (opt & APR_SO_SNDBUF) { if (setsockopt(sock->socketdes, SOL_SOCKET, SO_SNDBUF, (void *)&on, sizeof(int)) == -1) { return APR_OS2_STATUS(sock_errno()); } } if (opt & APR_SO_NONBLOCK) { if (ioctl(sock->socketdes, FIONBIO, (caddr_t)&one, sizeof(one)) == -1) { return APR_OS2_STATUS(sock_errno()); } else { sock->nonblock = one; } } if (opt & APR_SO_LINGER) { li.l_onoff = on; li.l_linger = APR_MAX_SECS_TO_LINGER; if (setsockopt(sock->socketdes, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(struct linger)) == -1) { return APR_OS2_STATUS(sock_errno()); } } if (opt & APR_TCP_NODELAY) { if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) { return APR_OS2_STATUS(sock_errno()); } } return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_socket_recv(apr_socket_t *sock, char *buf, apr_size_t *len) { apr_ssize_t rv; int fds, err = 0; do { if (!sock->nonblock || (err == SOCEWOULDBLOCK && sock->timeout != 0)) { fds = sock->socketdes; rv = select(&fds, 1, 0, 0, sock->timeout >= 0 ? sock->timeout/1000 : -1); if (rv != 1) { *len = 0; err = sock_errno(); if (rv == 0) return APR_TIMEUP; if (err == SOCEINTR) continue; return APR_FROM_OS_ERROR(err); } } rv = recv(sock->socketdes, buf, (*len), 0); err = rv < 0 ? sock_errno() : 0; } while (err == SOCEINTR || (err == SOCEWOULDBLOCK && sock->timeout != 0)); if (err) { *len = 0; return APR_FROM_OS_ERROR(err); } (*len) = rv; return rv == 0 ? APR_EOF : APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_socket_sendto(apr_socket_t *sock, apr_sockaddr_t *where, apr_int32_t flags, const char *buf, apr_size_t *len) { apr_ssize_t rv; int serrno; do { rv = sendto(sock->socketdes, buf, (*len), flags, (struct sockaddr*)&where->sa, where->salen); } while (rv == -1 && (serrno = sock_errno()) == EINTR); if (rv == -1 && serrno == SOCEWOULDBLOCK && sock->timeout != 0) { apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); if (arv != APR_SUCCESS) { *len = 0; return arv; } else { do { rv = sendto(sock->socketdes, buf, *len, flags, (const struct sockaddr*)&where->sa, where->salen); } while (rv == -1 && (serrno = sock_errno()) == SOCEINTR); } } if (rv == -1) { *len = 0; return APR_FROM_OS_ERROR(serrno); } *len = rv; return APR_SUCCESS; }
APR_DECLARE(apr_status_t) apr_socket_wait(apr_socket_t *sock, apr_wait_type_t direction) { int pollsocket = sock->socketdes; int wait_rc = select(&pollsocket, direction == APR_WAIT_READ, direction == APR_WAIT_WRITE, 0, sock->timeout / 1000); if (wait_rc == 0) { return APR_TIMEUP; } else if (wait_rc < 0) { return APR_FROM_OS_ERROR(sock_errno()); } return APR_SUCCESS; }
static apr_status_t socket_cleanup(void *sock) { apr_socket_t *thesocket = sock; if (thesocket->socketdes < 0) { return APR_EINVALSOCK; } if (soclose(thesocket->socketdes) == 0) { thesocket->socketdes = -1; return APR_SUCCESS; } else { return APR_OS2_STATUS(sock_errno()); } }