rbb 2002/07/10 22:40:23
Modified: network_io/os2 Makefile.in
Added: poll/os2 Makefile.in poll.c
Removed: network_io/os2 poll.c
Log:
An attempt at the OS/2 implementation. I have no OS/2 box, so this
probably won't work, but at least it is a start. My only question is can
you select on a file descriptor on OS/2? If not, then we will just have
to return an error on OS/2 if somebody tries to.
Revision Changes Path
1.18 +0 -1 apr/network_io/os2/Makefile.in
Index: Makefile.in
===================================================================
RCS file: /home/cvs/apr/network_io/os2/Makefile.in,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Makefile.in 22 Apr 2002 01:24:50 -0000 1.17
+++ Makefile.in 11 Jul 2002 05:40:23 -0000 1.18
@@ -2,7 +2,6 @@
VPATH = @srcdir@
TARGETS = \
- poll.lo \
sendrecv.lo \
sendrecv_udp.lo \
sockets.lo \
1.1 apr/poll/os2/Makefile.in
Index: Makefile.in
===================================================================
srcdir = @srcdir@
VPATH = @srcdir@
TARGETS = \
poll.lo
# bring in rules.mk for standard functionality
@INCLUDE_RULES@
INCDIR=../../include
OSDIR=$(INCDIR)/arch/@OSDIR@
DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
# DO NOT REMOVE
1.1 apr/poll/os2/poll.c
Index: poll.c
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#include "networkio.h"
#include "apr_network_io.h"
#include "apr_general.h"
#include "apr_portable.h"
#include "apr_lib.h"
#include <sys/time.h>
#include <stdlib.h>
/* OS/2 doesn't have a poll function, implement using OS/2 style select */
APR_DECLARE(apr_status_t) apr_poll_setup(apr_pollfd_t **new, apr_int32_t num,
apr_pool_t *cont)
{
*new = (apr_pollfd_t *)apr_palloc(cont, sizeof(apr_pollfd_t));
if (*new == NULL) {
return APR_ENOMEM;
}
(*new)->socket_list = apr_palloc(cont, sizeof(int) * num);
if ((*new)->socket_list == NULL) {
return APR_ENOMEM;
}
(*new)->r_socket_list = apr_palloc(cont, sizeof(int) * num);
if ((*new)->r_socket_list == NULL) {
return APR_ENOMEM;
}
(*new)->cntxt = cont;
(*new)->num_total = 0;
(*new)->num_read = 0;
(*new)->num_write = 0;
(*new)->num_except = 0;
return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,
apr_socket_t *sock,
apr_int16_t events)
{
int i;
if (events & APR_POLLIN) {
for (i=aprset->num_total; i>aprset->num_read; i--)
aprset->socket_list[i] = aprset->socket_list[i-1];
aprset->socket_list[i] = sock->socketdes;
aprset->num_read++;
aprset->num_total++;
}
if (events & APR_POLLOUT) {
for (i=aprset->num_total; i>aprset->num_read + aprset->num_write; i--)
aprset->socket_list[i] = aprset->socket_list[i-1];
aprset->socket_list[i] = sock->socketdes;
aprset->num_write++;
aprset->num_total++;
}
if (events &APR_POLLPRI) {
aprset->socket_list[aprset->num_total] = sock->socketdes;
aprset->num_except++;
aprset->num_total++;
}
return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *pollfdset, int num,
apr_int32_t *nsds,
apr_interval_time_t timeout)
{
int i;
int rv = 0;
int num_read = 0, num_write = 0, num_except = 0;
int *socket_list;
for (i = 0; i < num; i++) {
int events = pollfdset[i].events;
int fd;
if (pollfdset[i].desc_type == APR_POLL_SOCKET) {
fd = pollfdset[i].desc.s->socketdes;
}
else if (pollfdset[i].desc_type == APR_POLL_FILE) {
fd = pollfdset[i].desc.f->filedes;
}
if (events & APR_POLLIN) {
socket_list[num_read] = fd;
num_read++;
}
if (events & APR_POLLOUT) {
socket_list[num_write] = fd;
num_write++;
}
if (events &APR_POLLPRI) {
socket_list[num_except] = fd;
num_except++;
}
}
rv = select(socket_list,
num_read,
num_write,
num_except,
timeout >= 0 ? timeout / 1000 : -1);
/* select() doesn't wipe the socket list in the case of a timeout or
* interrupt. This prevents false positives from revents_get
*/
if (rv == 0) {
return timeout < 0 ? APR_EINTR : APR_TIMEUP;
}
(*nsds) = rv;
return rv < 0 ? APR_OS2_STATUS(sock_errno()) : APR_SUCCESS;
}