cvs commit: apache-apr/apr/network_io/unix sendrecv.c
fielding99/04/18 19:57:49 Modified:apr/network_io/unix sendrecv.c Log: Fix the algorithm for apr_send. The same needs to be done for apr_read. Why are these functions called send and recv when they have no relation to the UNIX system functions send and recv? write_with_nonblocking_timeout is what it does. Revision ChangesPath 1.3 +27 -26apache-apr/apr/network_io/unix/sendrecv.c Index: sendrecv.c === RCS file: /home/cvs/apache-apr/apr/network_io/unix/sendrecv.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- sendrecv.c1999/04/14 15:14:03 1.2 +++ sendrecv.c1999/04/19 02:57:48 1.3 @@ -60,37 +60,38 @@ #include apr_network_io.h #include sys/time.h -apr_ssize_t apr_send(apr_socket_t *sock, const char *buf, int len, time_t sec) +apr_ssize_t apr_send(apr_socket_t *sock, const char *buf, int len, time_t sec) { -fd_set fdset; -struct timeval tv; -int err = EAGAIN; -apr_int32_t rv; +ssize_t rv; -tv.tv_sec = sec; -if (tv.tv_sec == 0) { -return (write(sock-socketdes, buf, len)); -} -rv = write(sock-socketdes, buf, len); +do { +rv = write(sock-socketdes, buf, len); +} while (rv == -1 errno == EINTR); + +if (rv == -1 errno == EAGAIN sec 0) { +struct timeval tv; +fd_set fdset; +int srv; + +do { +FD_ZERO(fdset); +FD_SET(sock-socketdes, fdset); +tv.tv_sec = sec; +tv.tv_usec = 0; + +srv = select(FD_SETSIZE, NULL, fdset, NULL, tv); +} while (srv == -1 errno == EINTR); -if (rv == -1) { -err = errno; - if (err == EAGAIN || errno == EINTR) { - FD_ZERO(fdset); - FD_SET(sock-socketdes, fdset); - tv.tv_usec = 0; +if (srv 1) { +return (apr_ssize_t) -1; +} +else { do { - rv = select(FD_SETSIZE, NULL, fdset, NULL, tv); - } while (rv == -1 errno == EINTR); -if (rv == -1 || rv == 0) { - err = errno; -return APR_FAILURE; - } - else { - return write(sock-socketdes, buf, len); - } - } +rv = write(sock-socketdes, buf, len); +} while (rv == -1 errno == EINTR); +} } +return (apr_ssize_t) rv; } apr_ssize_t apr_recv(apr_socket_t *sock, char *buf, int len, time_t sec)
cvs commit: apache-apr STATUS
manoj 99/04/18 21:49:16 Modified:.STATUS Log: I like playing Alpha Centauri. Revision ChangesPath 1.20 +7 -1 apache-apr/STATUS Index: STATUS === RCS file: /home/cvs/apache-apr/STATUS,v retrieving revision 1.19 retrieving revision 1.20 diff -u -u -r1.19 -r1.20 --- STATUS1999/04/09 02:31:21 1.19 +++ STATUS1999/04/19 04:49:15 1.20 @@ -1,5 +1,5 @@ Apache Portable Runtime STATUS: -Last modified at [$Date: 1999/04/09 02:31:21 $] +Last modified at [$Date: 1999/04/19 04:49:15 $] Release: @@ -50,6 +50,12 @@ to the parent process rapidly (but not SIGWINCHes). The suspicion is that this is either an error in how pthread calls are used in the server, or a libc bug (the last refuge of a desperate programer). + +When the server runs at a high load, and the load later drops off, +the server tries to kill off some children. The problem is that the +children selected may have threads blocked on the accept lock, so +they will never exit. This wasn't a problem with 1.3, because each +process got kicked out of the lock with a signal. Open issues:
cvs commit: apache-1.3/src/modules/proxy proxy_cache.c
martin 99/04/19 05:30:47 Modified:src/modules/proxy proxy_cache.c Log: Not every ANSI compliant compiler supports auto-arrays of dynamic size. Use defensive approach and allocate filename using ap_palloc(). Revision ChangesPath 1.58 +2 -2 apache-1.3/src/modules/proxy/proxy_cache.c Index: proxy_cache.c === RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- proxy_cache.c 1999/04/08 20:27:44 1.57 +++ proxy_cache.c 1999/04/19 12:30:46 1.58 @@ -280,7 +280,7 @@ const struct cache_conf *conf = pconf-cache; const char *cachedir = conf-root; -char filename[ strlen(cachedir) + strlen( DOT_TIME ) +1]; +char *filename = ap_palloc(r-pool, strlen(cachedir) + strlen( DOT_TIME ) +1); struct stat buf; int timefd; time_t every = conf-gcinterval; @@ -349,7 +349,7 @@ array_header *files; struct gc_ent *fent; int i; -char filename[ strlen(cachedir) + HASH_LEN + 2]; +char *filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2); cachedir = conf-root; /* configured size is given in kB. Make it bytes, convert to long61_t: */
Re: cvs commit: apache-apr/apr/network_io/unix sendrecv.c
Modified:apr/network_io/unix sendrecv.c Log: Fix the algorithm for apr_send. The same needs to be done for apr_read. Why are these functions called send and recv when they have no relation to the UNIX system functions send and recv? write_with_nonblocking_timeout is what it does. They are called apr_send and apr_recv because they implement the apr send and recv functions. On Windows, they will use send and recv. I wasn't following any real naming guidelines, except for what makes sense when writing the code. the name apr_write_with_nonblocking_timeout seemed long and unnecessary to me. This is the apr primitive to send data over a network. To me, that is sending. The original design document said we were going to use POSIX type calls, but that was decided against, so I left most of the names the same because they made sense, and changed arguments were appropriate. Ryan ___ Ryan Bloom [EMAIL PROTECTED] 4205 S Miami Blvd RTP, NC 27709 It's a beautiful sight to see good dancers doing simple steps. It's a painful sight to see beginners doing complicated patterns.
cvs commit: apache-apr/apr/network_io/unix sendrecv.c
rbb 99/04/19 06:31:39 Modified:apr/network_io/unix sendrecv.c Log: Updated receive to use the same algorithm as send. Revision ChangesPath 1.4 +27 -25apache-apr/apr/network_io/unix/sendrecv.c Index: sendrecv.c === RCS file: /home/cvs/apache-apr/apr/network_io/unix/sendrecv.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- sendrecv.c1999/04/19 02:57:48 1.3 +++ sendrecv.c1999/04/19 13:31:39 1.4 @@ -96,33 +96,35 @@ apr_ssize_t apr_recv(apr_socket_t *sock, char *buf, int len, time_t sec) { -fd_set fdset; -struct timeval tv; -int err = EAGAIN; -int rv; +ssize_t rv; + +do { +rv = read(sock-socketdes, buf, len); +} while (rv == -1 errno == EINTR); -tv.tv_sec = sec; -if (tv.tv_sec == 0) { - return (read(sock-socketdes, buf, len)); -} -rv = read(sock-socketdes, buf, len); -if (rv == -1) { - err = errno; - if (err == EAGAIN || errno == EINTR) { - FD_ZERO(fdset); - FD_SET(sock-socketdes, fdset); - tv.tv_usec = 0; - do { -rv = select(FD_SETSIZE, fdset, NULL, NULL, tv); - } while (rv == -1 errno == EINTR); -if (rv == -1 || rv == 0) { - err = errno; -return APR_FAILURE; - } - else { - return read(sock-socketdes, buf, len); - } +if (rv == -1 errno == EAGAIN sec 0) { +struct timeval tv; +fd_set fdset; +int srv; + +do { +FD_ZERO(fdset); +FD_SET(sock-socketdes, fdset); +tv.tv_sec = sec; +tv.tv_usec = 0; + +srv = select(FD_SETSIZE, fdset, NULL, NULL, tv); +} while (srv == -1 errno == EINTR); + +if (srv 1) { +return (apr_ssize_t) -1; +} +else { +do { +rv = read(sock-socketdes, buf, len); +} while (rv == -1 errno == EINTR); } } +return (apr_ssize_t) rv; }
cvs commit: apache-apr/apr/network_io/unix sockets.c
rbb 99/04/19 07:16:41 Modified:include apr_network_io.h docs networkio.txt apr/network_io/unix sockets.c Log: Initial commit of connect function. This is needed to do any sort of test program, and I have been meaning to write it. Not tested yet, but hopefully soon. Revision ChangesPath 1.9 +1 -0 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- apr_network_io.h 1999/04/15 20:08:20 1.8 +++ apr_network_io.h 1999/04/19 14:16:39 1.9 @@ -90,6 +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); char *apr_get_remote_hostname(apr_socket_t *); apr_status_t apr_gethostname(char *, int); 1.11 +9 -0 apache-apr/docs/networkio.txt Index: networkio.txt === RCS file: /home/cvs/apache-apr/docs/networkio.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- networkio.txt 1999/04/15 20:08:21 1.10 +++ networkio.txt 1999/04/19 14:16:40 1.11 @@ -130,6 +130,15 @@ return) new socket that has the accepted connection. 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) +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. char *apr_get_remote_hostname(apr_socket_t *) Get the host name for the remote machine 1.6 +33 -0 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.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- sockets.c 1999/04/15 20:08:16 1.5 +++ sockets.c 1999/04/19 14:16:41 1.6 @@ -149,4 +149,37 @@ return NULL; } +apr_socket_t * apr_connect(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; +} + +memcpy((char *)new-addr-sin_addr, hp-h_addr_list[0], hp-h_length); + +new-addr-sin_port = htons((short)port); +new-addr-sin_family = AF_INET; + +new-addr_len = sizeof(new-addr); + +if (connect(new-socketdes, new-addr, new-addr_len) 0) { +free(new-addr); +free(new); +return NULL; +} +else { +new-remote_hostname = strdup(hostname); +return new; +} +} + +
cvs commit: apache-apr/apr/time/unix - New directory
rbb 99/04/19 07:47:33 apache-apr/apr/time/unix - New directory