httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@ibm.net>
Subject [PATCH] un-const-ify ap_socket_t parms to allow optimizations
Date Mon, 26 Jun 2000 02:39:48 GMT
Currently, the ap_socket_t parm is "const ap_socket_t *" in most cases
where it would be allowed by the current code.

Certain optimizations (like deferring a call to getsockname() until it
is really needed) require that the ap_socket_t parameter be modified
in most any situation.  This patch removes const from all applicable
ap_socket_t parameters.  I prefer this change to lying about it (i.e.,
using a cast).

Comments, concerns?

Separately, I have some optimizations to the Unix network_io
implementation to avoid getsockname() calls unless really, really
needed.  That code will follow if/when any concerns with these base
changes are resolved.  Those optimizations didn't require all of these
functions to be changed to non-const, but there are some situations
where APR might want to play with ap_socket_t in the remaining
functions so I went ahead and un-const-ified them.

Note for CVS newbies (like myself): the complaint about missing end of
line on a couple of BeOS files applies only to the CVS copy.  I added
a newline on the two modified parts.

Index: src/include/http_connection.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/include/http_connection.h,v
retrieving revision 1.18
diff -u -r1.18 http_connection.h
--- http_connection.h	2000/05/27 22:53:47	1.18
+++ http_connection.h	2000/06/26 02:05:07
@@ -67,7 +67,7 @@
 			    const struct sockaddr_in *remaddr,
 			    const struct sockaddr_in *saddr, long id);
 conn_rec *ap_new_apr_connection(ap_pool_t *p, server_rec *server, BUFF *inout,
-			    const ap_socket_t *conn_socket, long id);
+                                ap_socket_t *conn_socket, long id);
 CORE_EXPORT(void) ap_process_connection(conn_rec *);
 int ap_process_http_connection(conn_rec *);
 void ap_lingering_close(conn_rec *);
Index: src/lib/apr/include/apr_network_io.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/include/apr_network_io.h,v
retrieving revision 1.42
diff -u -r1.42 apr_network_io.h
--- apr_network_io.h	2000/06/22 19:09:44	1.42
+++ apr_network_io.h	2000/06/26 02:05:08
@@ -226,7 +226,7 @@
 
 =cut
  */
-ap_status_t ap_accept(ap_socket_t **new_sock, const ap_socket_t *sock, 
+ap_status_t ap_accept(ap_socket_t **new_sock, ap_socket_t *sock, 
                       ap_pool_t *connection_pool);
 
 /*
@@ -540,7 +540,7 @@
 
 /*
 
-=head1 ap_status_t ap_get_local_ipaddr(char **addr, const ap_socket_t *sock)
+=head1 ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock)
 
 B<Return the local IP address associated with an apr socket.>
 
@@ -549,11 +549,11 @@
 
 =cut
  */
-ap_status_t ap_get_local_ipaddr(char **addr, const ap_socket_t *sock);
+ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock);
 
 /*
 
-=head1 ap_status_t ap_get_remote_ipaddr(char **addr, const ap_socket_t *sock)
+=head1 ap_status_t ap_get_remote_ipaddr(char **addr, ap_socket_t *sock)
 
 B<Return the remote IP address associated with an apr socket.>
 
@@ -562,11 +562,11 @@
 
 =cut
  */
-ap_status_t ap_get_remote_ipaddr(char **addr, const ap_socket_t *sock);
+ap_status_t ap_get_remote_ipaddr(char **addr, ap_socket_t *sock);
 
 /*
 
-=head1 ap_status_t ap_get_local_name(struct sockaddr_in **name, const ap_socket_t *sock)
+=head1 ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock)
 
 B<Return the local socket name as a BSD style struct sockaddr_in.>
 
@@ -575,11 +575,11 @@
 
 =cut
  */
-ap_status_t ap_get_local_name(struct sockaddr_in **name, const ap_socket_t *sock);
+ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock);
 
 /*
 
-=head1 ap_status_t ap_get_remote_name(struct sockaddr_in **name, const ap_socket_t *sock)
+=head1 ap_status_t ap_get_remote_name(struct sockaddr_in **name, ap_socket_t *sock)
 
 B<Return the remote socket name as a BSD style struct sockaddr_in.>
 
@@ -588,7 +588,7 @@
 
 =cut
  */
-ap_status_t ap_get_remote_name(struct sockaddr_in **name, const ap_socket_t *sock);
+ap_status_t ap_get_remote_name(struct sockaddr_in **name, ap_socket_t *sock);
 
 /*
 
Index: src/lib/apr/network_io/beos/sockaddr.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/beos/sockaddr.c,v
retrieving revision 1.12
diff -u -r1.12 sockaddr.c
--- sockaddr.c	2000/06/13 16:44:29	1.12
+++ sockaddr.c	2000/06/26 02:05:09
@@ -140,7 +140,7 @@
     return APR_SUCCESS;
 }
 
-ap_status_t ap_get_local_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock)
 {
     if (!sock) {
         return APR_EBADF;
@@ -150,7 +150,7 @@
     return APR_SUCCESS;
 }
 
-ap_status_t ap_get_remote_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_remote_ipaddr(char **addr, ap_socket_t *sock)
 {
     if (!sock) {
         return APR_EBADF;
@@ -161,7 +161,7 @@
 }
 
 
-ap_status_t ap_get_local_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     if (!sock) {
         return APR_EBADF;
@@ -171,7 +171,7 @@
     return APR_SUCCESS;
 }
 
-ap_status_t ap_get_remote_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_remote_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     if (!sock) {
         return APR_EBADF;
@@ -180,4 +180,4 @@
     *name = sock->remote_addr;
     return APR_SUCCESS;
 }
-#endif
\ No newline at end of file
+#endif
Index: src/lib/apr/network_io/beos/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/beos/sockets.c,v
retrieving revision 1.28
diff -u -r1.28 sockets.c
--- sockets.c	2000/06/13 16:44:29	1.28
+++ sockets.c	2000/06/26 02:05:09
@@ -131,7 +131,7 @@
         return APR_SUCCESS; 
 } 
 
-ap_status_t ap_accept(ap_socket_t **new, const ap_socket_t *sock, ap_pool_t *connection_context)

+ap_status_t ap_accept(ap_socket_t **new, ap_socket_t *sock, ap_pool_t *connection_context)

 { 
 	(*new) = (ap_socket_t *)ap_palloc(connection_context,
 	                        sizeof(ap_socket_t)); 
@@ -235,4 +235,4 @@
     (*sock)->socketdes = *thesock;
     return APR_SUCCESS;
 }
-#endif
\ No newline at end of file
+#endif
Index: src/lib/apr/network_io/os2/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/os2/sockets.c,v
retrieving revision 1.21
diff -u -r1.21 sockets.c
--- sockets.c	2000/04/28 18:27:43	1.21
+++ sockets.c	2000/06/26 02:05:09
@@ -147,7 +147,7 @@
         return APR_SUCCESS;
 }
 
-ap_status_t ap_accept(ap_socket_t **new, const ap_socket_t *sock, ap_pool_t *connection_context)
+ap_status_t ap_accept(ap_socket_t **new, ap_socket_t *sock, ap_pool_t *connection_context)
 {
     (*new) = (ap_socket_t *)ap_palloc(connection_context, 
                             sizeof(ap_socket_t));
Index: src/lib/apr/network_io/unix/sockaddr.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/unix/sockaddr.c,v
retrieving revision 1.11
diff -u -r1.11 sockaddr.c
--- sockaddr.c	2000/06/22 00:36:05	1.11
+++ sockaddr.c	2000/06/26 02:05:10
@@ -128,7 +128,7 @@
 
 
 
-ap_status_t ap_get_local_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock)
 {
     *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->local_addr->sin_addr));
     return APR_SUCCESS;
@@ -136,7 +136,7 @@
 
 
 
-ap_status_t ap_get_remote_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_remote_ipaddr(char **addr, ap_socket_t *sock)
 {
     *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->remote_addr->sin_addr));
     return APR_SUCCESS;
@@ -145,7 +145,7 @@
 
 
 #if APR_HAVE_NETINET_IN_H
-ap_status_t ap_get_local_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     *name = sock->local_addr;
     return APR_SUCCESS;
@@ -153,7 +153,7 @@
 
 
 
-ap_status_t ap_get_remote_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_remote_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     *name = sock->remote_addr;
     return APR_SUCCESS;
Index: src/lib/apr/network_io/unix/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/unix/sockets.c,v
retrieving revision 1.48
diff -u -r1.48 sockets.c
--- sockets.c	2000/06/15 00:07:22	1.48
+++ sockets.c	2000/06/26 02:05:10
@@ -127,7 +127,7 @@
         return APR_SUCCESS;
 }
 
-ap_status_t ap_accept(ap_socket_t **new, const ap_socket_t *sock, ap_pool_t *connection_context)
+ap_status_t ap_accept(ap_socket_t **new, ap_socket_t *sock, ap_pool_t *connection_context)
 {
     (*new) = (ap_socket_t *)ap_pcalloc(connection_context, 
                             sizeof(ap_socket_t));
Index: src/lib/apr/network_io/win32/sockaddr.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/win32/sockaddr.c,v
retrieving revision 1.7
diff -u -r1.7 sockaddr.c
--- sockaddr.c	2000/04/14 01:38:46	1.7
+++ sockaddr.c	2000/06/26 02:05:11
@@ -129,7 +129,7 @@
     return APR_SUCCESS;
 }
 
-ap_status_t ap_get_local_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_local_ipaddr(char **addr, ap_socket_t *sock)
 {
     *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->local_addr->sin_addr));
     return APR_SUCCESS;
@@ -137,14 +137,14 @@
 
 
 
-ap_status_t ap_get_remote_ipaddr(char **addr, const ap_socket_t *sock)
+ap_status_t ap_get_remote_ipaddr(char **addr, ap_socket_t *sock)
 {
     *addr = ap_pstrdup(sock->cntxt, inet_ntoa(sock->remote_addr->sin_addr));
     return APR_SUCCESS;
 }
 
 
-ap_status_t ap_get_local_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_local_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     *name = sock->local_addr;
     return APR_SUCCESS;
@@ -152,7 +152,7 @@
 
 
 
-ap_status_t ap_get_remote_name(struct sockaddr_in **name, const ap_socket_t *sock)
+ap_status_t ap_get_remote_name(struct sockaddr_in **name, ap_socket_t *sock)
 {
     *name = sock->remote_addr;
     return APR_SUCCESS;
Index: src/lib/apr/network_io/win32/sockets.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/network_io/win32/sockets.c,v
retrieving revision 1.30
diff -u -r1.30 sockets.c
--- sockets.c	2000/06/14 17:16:47	1.30
+++ sockets.c	2000/06/26 02:05:11
@@ -158,7 +158,7 @@
         return APR_SUCCESS;
 }
 
-ap_status_t ap_accept(ap_socket_t **new, const ap_socket_t *sock, ap_pool_t *connection_context)
+ap_status_t ap_accept(ap_socket_t **new, ap_socket_t *sock, ap_pool_t *connection_context)
 {
     (*new) = (ap_socket_t *)ap_palloc(connection_context, 
                             sizeof(ap_socket_t));
Index: src/main/http_connection.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/main/http_connection.c,v
retrieving revision 1.40
diff -u -r1.40 http_connection.c
--- http_connection.c	2000/06/20 04:22:39	1.40
+++ http_connection.c	2000/06/26 02:11:05
@@ -280,7 +280,7 @@
 
 
 conn_rec *ap_new_apr_connection(ap_pool_t *p, server_rec *server, BUFF *inout,
-			    const ap_socket_t *conn_socket, long id)
+                                ap_socket_t *conn_socket, long id)
 {
     struct sockaddr_in *sa_local, *sa_remote;
 
 


-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Mime
View raw message