httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-apr/docs networkio.txt
Date Wed, 21 Apr 1999 13:56:10 GMT
rbb         99/04/21 06:56:09

  Modified:    apr/network_io/unix select.c sockets.c
               apr/test Makefile
               include  apr_network_io.h
               docs     networkio.txt
  Log:
  Fixes for network I/O logic, so it works porperly.  I'm sure there will be
  more of these.
  
  Revision  Changes    Path
  1.2       +2 -1      apache-apr/apr/network_io/unix/select.c
  
  Index: select.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/network_io/unix/select.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- select.c	1999/04/14 19:17:21	1.1
  +++ select.c	1999/04/21 13:56:06	1.2
  @@ -58,10 +58,11 @@
   #include <errno.h>
   #include <sys/time.h>
   #include <sys/types.h>
  +#include <unistd.h>
   
   void apr_sd_set(apr_socket_t *sock, apr_sd_set_t *sd_set)
   {
  -    FDSET(sock->socketdes, sd_set);
  +    FD_SET(sock->socketdes, sd_set);
   }
   
   void apr_sd_clr(apr_socket_t *sock, apr_sd_set_t *sd_set)
  
  
  
  1.7       +18 -20    apache-apr/apr/network_io/unix/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/network_io/unix/sockets.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- sockets.c	1999/04/19 14:16:41	1.6
  +++ sockets.c	1999/04/21 13:56:06	1.7
  @@ -71,9 +71,8 @@
   
       thesocket->addr = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
       thesocket->addr->sin_family = AF_INET;
  -    thesocket->addr->sin_addr.s_addr = INADDR_ANY;
   
  -    thesocket->addr_len = sizeof(thesocket->addr);
  +    thesocket->addr_len = sizeof(*thesocket->addr);
       
       if (thesocket->socketdes < 0) {
           free(thesocket->addr);
  @@ -116,6 +115,7 @@
   
   apr_status_t apr_bind(apr_socket_t *sock)
   {
  +    sock->addr->sin_addr.s_addr = INADDR_ANY;
       if (bind(sock->socketdes, (struct sockaddr *)sock->addr, sock->addr_len) ==
-1)
           return APR_FAILURE;
       else
  @@ -149,36 +149,34 @@
       return NULL;
   }
   
  -apr_socket_t * apr_connect(char *hostname, unsigned short port)
  +apr_status_t apr_connect(apr_socket_t *sock, char *hostname, unsigned short port)
   {
  -    apr_socket_t *new = (apr_socket_t *)malloc(sizeof(apr_socket_t));
       struct hostent *hp;
   
       hp = gethostbyname(hostname);
  -    new->socketdes = socket(AF_INET, SOCK_STREAM, 0);
  -    new->addr = (struct sockaddr_in *)malloc (sizeof (struct sockaddr_in));
   
  -    if ((new->socketdes < 0) || (!hp) || (!new->addr)) {
  -        free(new->addr); 
  -        free(new);
  -        return NULL;
  +    if ((sock->socketdes < 0) || (!hp) || (!sock->addr)) {
  +        free(sock->addr); 
  +        free(sock);
  +        return APR_FAILURE;
       }
       
  -    memcpy((char *)&new->addr->sin_addr, hp->h_addr_list[0], hp->h_length);
  +    memcpy((char *)&sock->addr->sin_addr, hp->h_addr_list[0], hp->h_length);
   
  -    new->addr->sin_port = htons((short)port);
  -    new->addr->sin_family = AF_INET;
  +    sock->addr->sin_port = htons((short)port);
  +    sock->addr->sin_family = AF_INET;
      
  -    new->addr_len = sizeof(new->addr);
  +    sock->addr_len = sizeof(*sock->addr);
   
  -    if (connect(new->socketdes, new->addr, new->addr_len) < 0) {
  -        free(new->addr);
  -        free(new);
  -        return NULL;
  +    if ((connect(sock->socketdes, sock->addr, sock->addr_len) < 0) &&
  +        (errno != EINPROGRESS)) {
  +        free(sock->addr);
  +        free(sock);
  +        return APR_FAILURE;
       }
       else {
  -        new->remote_hostname = strdup(hostname);
  -        return new;
  +        sock->remote_hostname = strdup(hostname);
  +        return APR_SUCCESS;
       }
   }
   
  
  
  
  1.3       +8 -4      apache-apr/apr/test/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/Makefile,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile	1999/04/12 17:54:11	1.2
  +++ Makefile	1999/04/21 13:56:07	1.3
  @@ -12,12 +12,12 @@
   SRCDIR=..
   EXTRA_CFLAGS=-g 
   EXTRA_LDFLAGS=
  -EXTRA_LIBS= -L../file_io -lfile
  +EXTRA_LIBS= -L../file_io -lfile -L../network_io -lnetwork
   EXTRA_INCLUDES=
   EXTRA_DEPS=
   OSDIR=
   INCDIR=../../include
  -INCLUDES0=-I ../file_io/unix -I $(INCDIR)
  +INCLUDES0=-I ../file_io/unix -I ../network_io/unix -I $(INCDIR)
   SHELL=/bin/sh
   CC=gcc
   CPP=gcc -E
  @@ -45,14 +45,19 @@
   INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
   LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
   
  -OBJS= testfile.o \
  +OBJS= testfile.o ab_apr.o\
   
   .c.o:
   	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBS) $<
   
  +all:
  +	testfile ab_apr
  +
   testfile:
   	$(CC) testfile.c $(INCLUDES) $(CFLAGS) $(LIBS) $<
   
  +ab_apr:
  +	$(CC) ab_apr.c $(INCLUDES) $(CFLAGS) $(LIBS) -o ab_apr $<
   
   clean:
   	rm -f *.o $(LIB)
  @@ -77,4 +82,3 @@
   $(OBJS): Makefile
   
   # DO NOT REMOVE
  -alloc.o: open.c 
  
  
  
  1.10      +1 -1      apache-apr/include/apr_network_io.h
  
  Index: apr_network_io.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_network_io.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apr_network_io.h	1999/04/19 14:16:39	1.9
  +++ apr_network_io.h	1999/04/21 13:56:08	1.10
  @@ -90,7 +90,7 @@
   apr_status_t apr_bind(apr_socket_t *);
   apr_status_t apr_listen(apr_socket_t *, apr_int32_t);
   apr_socket_t *apr_accept(const apr_socket_t *);
  -apr_socket_t *apr_connect(char *, unsigned short);
  +apr_status_t apr_connect(apr_socket_t *, char *, unsigned short);
   
   char *apr_get_remote_hostname(apr_socket_t *);
   apr_status_t apr_gethostname(char *, int);
  
  
  
  1.12      +7 -6      apache-apr/docs/networkio.txt
  
  Index: networkio.txt
  ===================================================================
  RCS file: /home/cvs/apache-apr/docs/networkio.txt,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- networkio.txt	1999/04/19 14:16:40	1.11
  +++ networkio.txt	1999/04/21 13:56:09	1.12
  @@ -131,14 +131,15 @@
   NOTE:  accepted socket can not accept more connections.  Original socket
          remains open, and can accept more connections.
   
  - apr_socket_t *apr_connect(char *, unisigned short)
  + apr_status_t apr_connect(apr_socket_t *, char *, unisigned short)
           Connect to a listening socket.
  -
         Arguments:
  -        arg 1)  hostname of the machine to connect to.
  -        arg 2)  port to connect to.
  -        return) socket which is connected to server machine.  NULL on failure.
  -NOTE:  On failure, socket is closed, and memory is free'd on failure.
  +        arg 1)  Socket to use to connect.
  +        arg 2)  hostname of the machine to connect to.
  +        arg 3)  port to connect to.
  +        return) APR_SUCCESS or APR_FAILURE. 
  +NOTE:  On failure, socket is closed, and memory is free'd on failure.  ALWAYS
  +       create the socket in apr_create_tcp_socket before calling this function.
    
   char *apr_get_remote_hostname(apr_socket_t *)
           Get the host name for the remote machine
  
  
  

Mime
View raw message