You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rob Hartill <ro...@imdb.com> on 1997/01/21 23:22:18 UTC

Load spikes (fwd)

---------- Forwarded message ----------
Date: Tue, 21 Jan 1997 16:51:55 -0500 (EST)
From: Homer W. Smith <ho...@lightlink.com>
To: apache-bugs@mail.apache.org
Subject: Load spikes


    Running Apache 1.2b4 on Sparc 20 SunOS 4.1.4
 
    Getting VERY large load spikes repeatedly, up to load 10 or more.
 
    I got this in Apache 1.1.1 with Listen 80 enabled, apparently the
code was doing a double listen on 80.  Turning off Listen 80 cleared
up the spikes.  However the code has changed in 1.2b4, and even
with Listen 80 turned off, and now getting load spikes.
 
    Can someone please help me fix this?
 
    The code segment that listen 80 affected is below from http_main.c
 
    From http_main.c Apache 1.1.1

    With listeners off, code executes else at bottom of sniplet.

...

    	if (listeners != NULL)
	{
	    fd_set fds;

	    for (;;) {
		memcpy(&fds, &listenfds, sizeof(fd_set));
#ifdef HPUX
		csd = select(listenmaxfd+1, (int*)&fds, NULL, NULL, NULL);
#else
                csd = select(listenmaxfd+1, &fds, NULL, NULL, NULL);
#endif
		if (csd == -1 && errno != EINTR)
		    log_unixerr("select",NULL,"select error", server_conf);
		if (csd <= 0) continue;
		for (sd=listenmaxfd; sd >= 0; sd--)
		    if (FD_ISSET(sd, &fds)) break;
		if (sd < 0) continue;

		clen=sizeof(sa_client);
		do csd=accept(sd, &sa_client, &clen);
		while (csd == -1 && errno == EINTR);
		if (csd != -1) break;
		log_unixerr("accept", "(client socket)", NULL, server_conf);
	    }
	} else
	    while ((csd=accept(sd, &sa_client, &clen)) == -1) 
		if (errno != EINTR) 
		    log_unixerr("accept",NULL,"socket error: accept failed", server_conf);

	accept_mutex_off(); /* unlock after "accept" */

	clen = sizeof(sa_server);
	if(getsockname(csd, &sa_server, &clen) < 0) {
	    log_unixerr("getsockname", NULL, NULL, server_conf);
	    continue;
	}

--------------------------------------------------------------------------

     http.main.c Apache 1.2

	if (listeners != NULL)
	{
	    fd_set fds;

	    for (;;) {
		memcpy(&fds, &listenfds, sizeof(fd_set));
#ifdef HPUX
		csd = select(listenmaxfd+1, (int*)&fds, NULL, NULL, NULL);
#else
                csd = select(listenmaxfd+1, &fds, NULL, NULL, NULL);
#endif
		if (csd == -1 && errno != EINTR)
		    log_unixerr("select",NULL,"select error", server_conf);

		/*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
		if(scoreboard_image->global.exit_generation >= generation)
		    exit(0);

		if (csd <= 0) continue;
		for (sd=listenmaxfd; sd >= 0; sd--)
		    if (FD_ISSET(sd, &fds)) break;
		if (sd < 0) continue;

		clen=sizeof(sa_client);
		do csd=accept(sd, &sa_client, &clen);
		while (csd == -1 && errno == EINTR);
		if (csd != -1) break;
		log_unixerr("accept", "(client socket)", NULL, server_conf);
	    }
	} else
	    {
	    fd_set fds;

	    memset(&fds,0,sizeof fds);
	    FD_SET(sd,&fds);
	    
	    do
#ifdef HPUX
		csd = select(sd+1, (int*)&fds, NULL, NULL, NULL);
#else
		csd = select(sd+1, &fds, NULL, NULL, NULL);
#endif
	    while(csd < 0 && errno == EINTR);

	    if(csd < 0)
		{
		log_unixerr("select","(listen)",NULL,server_conf);
		exit(0);
		}
	    /*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
	    sync_scoreboard_image();
	    if(scoreboard_image->global.exit_generation >= generation)
		exit(0);

	    while ((csd=accept(sd, &sa_client, &clen)) == -1) 
		if (errno != EINTR) 
		    log_unixerr("accept",NULL,"socket error: accept failed", server_conf);
	    }

	accept_mutex_off(); /* unlock after "accept" */

	clen = sizeof(sa_server);
	if(getsockname(csd, &sa_server, &clen) < 0) {
	    log_unixerr("getsockname", NULL, NULL, server_conf);
	    continue;
	}

------------------------------------------------------------------------------
Homer Wilson Smith     News, Web, Telnet      Art Matrix - Lightlink
(607) 277-0959         SunOS 4.1.4 Sparc 20   Internet Access, Ithaca NY
homer@lightlink.com    info@lightlink.com     http://www.lightlink.com