You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@hyperreal.org on 1999/06/29 04:49:30 UTC
cvs commit: apache-2.0/mpm/src/include ap_listen.h
manoj 99/06/28 19:49:30
Modified: mpm/src/main listen.c
mpm/src/modules/mpm/mpmt_pthread http_accept.c
mpm/src/include ap_listen.h
Log:
Change method of checking for active FDs after poll() in the pthread
MPM. The new method doesn't require any changes to the listen
abstraction.
Revision Changes Path
1.3 +0 -1 apache-2.0/mpm/src/main/listen.c
Index: listen.c
===================================================================
RCS file: /home/cvs/apache-2.0/mpm/src/main/listen.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -u -r1.2 -r1.3
--- listen.c 1999/06/27 03:45:14 1.2
+++ listen.c 1999/06/29 02:49:26 1.3
@@ -182,7 +182,6 @@
new = malloc(sizeof(ap_listen_rec));
new->local_addr = *local_addr;
new->fd = -1;
- new->index = -1;
new->next = ap_listeners;
ap_listeners = new;
}
1.3 +17 -21 apache-2.0/mpm/src/modules/mpm/mpmt_pthread/http_accept.c
Index: http_accept.c
===================================================================
RCS file: /home/cvs/apache-2.0/mpm/src/modules/mpm/mpmt_pthread/http_accept.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -u -r1.2 -r1.3
--- http_accept.c 1999/06/27 03:45:15 1.2
+++ http_accept.c 1999/06/29 02:49:27 1.3
@@ -303,8 +303,8 @@
* USE_MULTI_ACCEPT
* Worker threads do the accept and process the request.
*/
-static ap_listen_rec *last_lr;
static struct pollfd *listenfds;
+static int last_pollfd = 0;
void accept_parent_init(pool *pconf, int listener_count)
{
@@ -322,14 +322,12 @@
SAFE_ACCEPT(intra_mutex_init(pchild, 1));
SAFE_ACCEPT(accept_mutex_child_init(pchild));
requests_this_child = ap_max_requests_per_child;
- last_lr = ap_listeners;
listenfds = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds + 1));
listenfds[0].fd = ap_pipe_of_death[0];
listenfds[0].events = POLLIN;
listenfds[0].revents = 0;
for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i) {
- lr->index = i;
listenfds[i].fd = lr->fd;
listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/
listenfds[i].revents = 0;
@@ -347,6 +345,7 @@
int ret;
ap_listen_rec *lr;
char pipe_read_char;
+ int curr_pollfd;
size_t len = sizeof(struct sockaddr);
@@ -405,36 +404,33 @@
continue;
}
- /* This conditional is used because the single listen case is the
- * only one where the accept might not be serialized. In that
- * case, multiple threads mucking around with the last_lr
- * pointer will be harmful */
+ /* This conditional is used because the single listen case
+ * is the only one where the accept might not be serialized.
+ * In that case, multiple threads mucking around with
+ * listenfds or last_pollfd will be harmful */
if (num_listenfds == 1) {
/* only one socket, just pretend we did the other stuff */
sd = ap_listeners->fd;
}
else {
/* find a listener */
- lr = last_lr;
+ curr_pollfd = last_pollfd;
do {
- /* XXX: should we check for POLLERR? */
- if (listenfds[lr->index].revents & POLLIN) {
- last_lr = lr->next;
- if (last_lr == NULL) {
- last_lr = ap_listeners;
- }
- goto got_lr;
+ curr_pollfd++;
+ if (curr_pollfd > num_listenfds) {
+ curr_pollfd = 1;
}
- lr = lr->next;
- if (lr == NULL) {
- lr = ap_listeners;
+ /* XXX: Should we check for POLLERR? */
+ if (listenfds[curr_pollfd].revents & POLLIN) {
+ last_pollfd = curr_pollfd;
+ sd = listenfds[curr_pollfd].fd;
+ goto got_lr;
}
- } while (lr != last_lr);
+ } while (curr_pollfd != last_pollfd);
/* if we don't find anything then just start again */
continue;
- got_lr:
- sd = lr->fd;
}
+ got_lr:
csd = ap_accept(sd, sa_client, &len);
requests_this_child--;
1.3 +0 -1 apache-2.0/mpm/src/include/ap_listen.h
Index: ap_listen.h
===================================================================
RCS file: /home/cvs/apache-2.0/mpm/src/include/ap_listen.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -u -r1.2 -r1.3
--- ap_listen.h 1999/06/27 03:45:13 1.2
+++ ap_listen.h 1999/06/29 02:49:29 1.3
@@ -64,7 +64,6 @@
struct sockaddr_in local_addr; /* local IP address and port */
/* TODO: replace the fd with APR stuff */
int fd;
- int index; /* index into pollfd array */
/* more stuff here, like which protocol is bound to the port */
};