Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions webbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <time.h>
#include <signal.h>

#define MAX_SIZE 1024*1024
/* values */
volatile int timerexpired=0;
int speed=0;
Expand Down Expand Up @@ -79,6 +80,10 @@ static void alarm_handler(int signal)
timerexpired=1;
}

static void sigusr1_handler(int signal)
{
}

static void usage(void)
{
fprintf(stderr,
Expand Down Expand Up @@ -296,6 +301,9 @@ static int bench(void)
int i,j,k;
pid_t pid=0;
FILE *f;
int index=0;
struct sigaction sa;
pid_t pids[MAX_SIZE];

/* check avaibility of target server */
i=Socket(proxyhost==NULL?host:proxyhost,proxyport);
Expand Down Expand Up @@ -325,10 +333,19 @@ static int bench(void)
pid=fork();
if(pid <= (pid_t) 0)
{
/* child process or error*/
sleep(1); /* make childs faster */
break;
}
/*record child pid*/
pids[i]=pid;
sleep(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep(1) each loop in father process?

/*after fork last child, start all clients*/
if(i == clients - 1)
{
for(index = 0; index <= i; ++index)
{
kill(pids[index], SIGUSR1);
}
}
}

if( pid< (pid_t) 0)
Expand All @@ -338,9 +355,21 @@ static int bench(void)
return 3;
}


/* I am a child */
if(pid== (pid_t) 0)
{
/* I am a child */
/*setup usr1 signal handler*/
sa.sa_handler = sigusr1_handler;
sa.sa_flags = 0;
if(sigaction(SIGUSR1, &sa, NULL))
{
exit(3);
}

/*wait all clients ready*/
pause();

if(proxyhost==NULL)
benchcore(host,proxyport,request);
else
Expand Down