httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@hyperreal.org
Subject cvs commit: apache-2.0/src/os/beos iol_socket.c iol_socket.h
Date Tue, 02 Nov 1999 12:26:43 GMT
dreid       99/11/02 04:26:43

  Modified:    src/modules/mpm/mpmt_beos mpmt_beos.c
               src/os/beos iol_socket.c iol_socket.h
  Log:
  Change the BeOS iol_socket layer to use apr.  Also update mpmt_beos.c
  to reflect this change.
  
  Revision  Changes    Path
  1.7       +2 -6      apache-2.0/src/modules/mpm/mpmt_beos/mpmt_beos.c
  
  Index: mpmt_beos.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/mpm/mpmt_beos/mpmt_beos.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- mpmt_beos.c	1999/10/28 22:14:54	1.6
  +++ mpmt_beos.c	1999/11/02 12:26:41	1.7
  @@ -643,11 +643,7 @@
       long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
       int csd;
   
  -    ap_get_os_sock(&csd, sock);
  -
  -    sock_disable_nagle(csd);
  -
  -    iol = beos_attach_socket(csd);
  +    iol = beos_attach_socket(sock);
       if (iol == NULL) {
           if (errno == EBADF) {
               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL,
  @@ -659,7 +655,7 @@
               ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
                   "error attaching to socket");
           }
  -        closesocket(csd);
  +        ap_close_socket(sock);
   	return;
       }
   
  
  
  
  1.3       +26 -110   apache-2.0/src/os/beos/iol_socket.c
  
  Index: iol_socket.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/os/beos/iol_socket.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- iol_socket.c	1999/10/22 11:25:42	1.2
  +++ iol_socket.c	1999/11/02 12:26:42	1.3
  @@ -58,19 +58,15 @@
   
   #include "httpd.h"
   #include "ap_iol.h"
  +#include "apr_network_io.h"
  +#include "apr_file_io.h"
   #include "iol_socket.h"
   
  -#include <errno.h>
  -#include <sys/types.h>
  -#include <sys/uio.h>
  -
   #define FD_NONBLOCKING_SET	(1)
   
   typedef struct {
       ap_iol iol;
  -    int fd;
  -    int flags;
  -    int timeout;
  +    ap_socket_t *sock;
   } iol_socket;
   
   static ap_status_t beos_setopt(ap_iol *viol, ap_iol_option opt,
  @@ -80,10 +76,10 @@
   
       switch (opt) {
       case AP_IOL_TIMEOUT:
  -	iol->timeout = *(const int *)value;
  -	break;
  +        ap_setsocketopt(iol->sock, APR_SO_TIMEOUT, *(const int*)value);
  +        break;
       default:
  -	return APR_EINVAL;
  +	    return APR_EINVAL;
       }
       return APR_SUCCESS;
   }
  @@ -94,116 +90,42 @@
   
       switch (opt) {
       case AP_IOL_TIMEOUT:
  -	*(int *)value = iol->timeout;
  -	break;
  +    	/* no-op */
  +	    break;
       default:
  -	return APR_EINVAL;
  +	    return APR_EINVAL;
       }
       return APR_SUCCESS;
   }
   
  -static ap_status_t set_nonblock(int fd)
  +ap_status_t beos_write(ap_iol *viol, const char* buf, ap_size_t size,
  +     ap_ssize_t *nbytes)
   {
  -    int on = 1;
  -    int rv;
  -    rv = setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));
  -    
  -    if (rv == 0)
  -        return APR_SUCCESS;
  -    return errno;
  +    *nbytes = size;
  +    return ap_send(((iol_socket *)viol)->sock, buf, nbytes);
   }
  -
  -/* the timeout code is a separate routine because it requires
  -    a stack frame... and we don't want to pay that setup cost
  -    on every call */
  -
  -/* this macro expands into the four basic i/o methods */
  -
  -#define method(name, args, syscall, selread, selwrite)	\
  -    static ap_status_t beos_##name##_timeout args \
  -    { \
  -	iol_socket *iol = (iol_socket *)viol; \
  -	fd_set fdset; \
  -	struct timeval tv; \
  -	int rv; \
  - \
  -	FD_ZERO(&fdset); \
  -	FD_SET(iol->fd, &fdset); \
  -	tv.tv_sec = iol->timeout; \
  -	tv.tv_usec = 0; \
  -	do { \
  -	    rv = select(iol->fd + 1, selread, selwrite, NULL, iol->timeout < 0 ? NULL
: &tv); \
  -	} while (rv == -1 && errno == EINTR); \
  -	if (!FD_ISSET(iol->fd, &fdset)) { \
  -	    return APR_ETIMEDOUT; \
  -	} \
  -	do { \
  -	    rv = syscall(iol->fd, arg1, arg2, 0); \
  -	} while (rv == -1 && errno == EINTR); \
  -        if (rv >= 0) { \
  -            *nbytes = rv; \
  -            return APR_SUCCESS; \
  -        } \
  -	return errno; \
  -     \
  -    } \
  - \
  -    static ap_status_t beos_##name args \
  -    { \
  -	iol_socket *iol = (iol_socket *)viol; \
  -	int rv; \
  - \
  -        /* Present to zero until some bytes are actually written */ \
  -        *nbytes = 0; \
  -	if (!(iol->flags & FD_NONBLOCKING_SET)) { \
  -	    if (iol->timeout < 0) { \
  -		rv = syscall(iol->fd, arg1, arg2, 0); \
  -                if (rv >= 0) { \
  -                    *nbytes = rv; \
  -                    return APR_SUCCESS; \
  -                } \
  -                return errno; \
  -	    } \
  -	    /* must shift descriptor to blocking mode now */ \
  -	    if ((rv = set_nonblock(iol->fd)) != APR_SUCCESS) { \
  -		return rv; \
  -	    } \
  -	    iol->flags |= FD_NONBLOCKING_SET; \
  -	} \
  - \
  -	/* try writing, ignoring EINTR, the upper layer has to handle \
  -	    partial read/writes anyhow, so we can return early */ \
  -	do { \
  -	    rv = syscall(iol->fd, arg1, arg2, 0); \
  -	} while (rv == -1 && errno == EINTR); \
  -	if ((errno == EWOULDBLOCK || errno == EAGAIN) && iol->timeout != 0) { \
  -	    return beos_##name##_timeout(viol, arg1, arg2, nbytes); \
  -	} \
  -	if (rv >= 0) { \
  -	    *nbytes = rv; \
  -            return APR_SUCCESS; \
  -	} \
  -	return errno; \
  -    }
   
  -method(write, (ap_iol *viol, const char *arg1, ap_size_t arg2, ap_ssize_t *nbytes), send,
NULL, &fdset)
  -method(read, (ap_iol *viol, char *arg1, ap_size_t arg2, ap_ssize_t *nbytes), recv, &fdset,
NULL)
  +ap_status_t beos_writev(ap_iol *viol, const struct iovec *vec, int nvec,
  +    ap_ssize_t *nbytes)
  +{
  +    return ap_send(((iol_socket *)viol)->sock, vec[0].iov_base, vec[0].iov_len);
  +}
   
  -static ap_status_t beos_writev(ap_iol *viol, const struct iovec *vec, int arg2, ap_ssize_t
*nbytes)
  +ap_status_t beos_read(ap_iol *viol, char* buf, ap_size_t size,
  +     ap_ssize_t *nbytes)
   {
  -    return beos_write(viol, vec[0].iov_base, vec[0].iov_len, nbytes);
  +    *nbytes = size;
  +    return ap_recv(((iol_socket *)viol)->sock, buf, nbytes);
   }
   
   static ap_status_t beos_close(ap_iol *viol)
   {
       iol_socket *iol = (iol_socket *)viol;
  -    int rv;
       int saved_errno;
   
  -    rv = closesocket(iol->fd);
  -    saved_errno = errno;
  +    saved_errno = ap_close_socket(iol->sock);
       free(iol);
  -    if (rv == 0) {
  +    if (saved_errno == 0) {
           return APR_SUCCESS;
       }
       return saved_errno;
  @@ -218,18 +140,12 @@
       beos_getopt
   };
   
  -ap_iol *beos_attach_socket(int fd)
  +ap_iol *beos_attach_socket(ap_socket_t *sock)
   {
       iol_socket *iol;
   
  -    if (fd >= FD_SETSIZE) {
  -	errno = EBADF;
  -	return NULL;
  -    }
       iol = malloc(sizeof(iol_socket));
       iol->iol.methods = &socket_methods;
  -    iol->fd = fd;
  -    iol->timeout = -1;
  -    iol->flags = 0;
  +    iol->sock = sock;
       return (ap_iol *)iol;
   }
  
  
  
  1.2       +1 -1      apache-2.0/src/os/beos/iol_socket.h
  
  Index: iol_socket.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/os/beos/iol_socket.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- iol_socket.h	1999/07/12 22:51:14	1.1
  +++ iol_socket.h	1999/11/02 12:26:43	1.2
  @@ -58,6 +58,6 @@
   #ifndef OS_UNIX_IOL_SOCKET_H
   #define OS_UNIX_IOL_SOCKET_H
   
  -ap_iol *beos_attach_socket(int fd);
  +ap_iol *beos_attach_socket(ap_socket_t *_sock);
   
   #endif
  
  
  

Mime
View raw message