/**********************************************************************************/ /* ap_rputs("\n>", r);*/ ap_rputs("", r); ap_rputs("", r); ap_rputs(" \
", r); bytes_remaining_for_this_request = 0; ap_sync_scoreboard_image(); count_req = 0; for (i = 0; i < HARD_SERVER_LIMIT; ++i) { score_record = ap_scoreboard_image->servers[i]; lres = score_record.access_count; if (lres != 0 || (score_record.status != SERVER_READY && score_record.status != SERVER_DEAD) ) { StrLen = strlen( score_record.my_file); if ( strcmp(score_record.my_file, cgifile) != 0) { /*@@@@@@@@@@@@@ Test for directory @@@@@@@*/ if ( strstr(&score_record.my_file[StrLen-1], extension) != NULL ){ my_new_file = (char*)malloc(StrLen + strlen(my_index)+1 ); /*strncpy(my_new_file, myempty_str, strlen(myempty_str));*/ strncpy(my_new_file, score_record.my_file, StrLen); strcat(my_new_file, my_index); /*strcpy(score_record.my_file, my_new_file);*/ /*strcat(score_record.my_file, my_index);*/ stat( my_new_file, &mystatbuf); myfileSz = mystatbuf.st_size; bytes_remaining_for_this_request = myfileSz- score_record.mybytes_sent; } /*@@@@@@@@@@@@@@@@@@@@*/ else { my_new_file = (char*)malloc(StrLen +1 ); /*strncpy(my_new_file, myempty_str, strlen(myempty_str));*/ strncpy(my_new_file, score_record.my_file, StrLen); myfileSz = score_record.myfilesize; if (strstr(&score_record.my_file[StrLen-4], c_g_i_1) != NULL || strstr(&score_record.my_file[StrLen-3], c_g_i_2) != NULL ) bytes_remaining_for_this_request = 0 ; else bytes_remaining_for_this_request = myfileSz- score_record.mybytes_sent; } /*#################################################################*/ #if defined(NO_GETTIMEOFDAY) #ifndef NO_TIMES if (score_record.start_time == (clock_t) 0) #endif /* NO_TIMES */ req_time = 0L; #ifndef NO_TIMES else { req_time = score_record.stop_time - score_record.start_time; req_time = (req_time * 1000) / (int) tick; } #endif /* NO_TIMES */ #else if (score_record.start_time.tv_sec == 0L && score_record.start_time.tv_usec == 0L) req_time = 0L; else req_time = ((score_record.stop_time.tv_sec - score_record.start_time.tv_sec) * 1000) + ((score_record.stop_time.tv_usec - score_record.start_time.tv_usec) / 1000); #endif if (req_time < 0L) req_time = 0L; /*#################################################################*/ /* my_time = nowtime - score_record.start_time; my_time = (my_time * 1000) / (int) tick; */ /* if ( score_record.mybytes_sent != 0 && my_time != 0 ) myreq_B_sec = (float)( ((float)score_record.mybytes_sent)/ ((float)(my_time)) );*/ if(req_time != 0){ speed = (float) myfileSz / ((float)req_time / 100.0); Average_speed += speed ; count_speed ++; } else speed = Average; bytes_left += bytes_remaining_for_this_request; score_record.time_to_completion = ((float) bytes_left)/speed ; put_scoreboard_info(i, &score_record); ap_rprintf(r, "", my_new_file, myfileSz , score_record.mybytes_sent, req_time, bytes_remaining_for_this_request, speed, score_record.time_to_completion); /*Avg_B_sec += myreq_B_sec ;*/ count_req++; ap_rputs("\n", r); /*strcpy(score_record.my_file, myempty_str);*/ /* bytes_left += bytes_remaining_for_this_request; score_record.time_to_completion = ((float) bytes_left)/speed ; put_scoreboard_info(i, &score_record); */ mybytes_sent = + score_record.mybytes_sent; /*bytes_remaining_for_this_request = 0;*/ myreq_B_sec = 0 ; free(my_new_file); } /*end strcmp */ } ap_sync_scoreboard_image(); } ap_rputs("", r); ap_rputs("
FILENAME

File Sz

Sent

Time,ms

Bytes Left

Bytes per sec/TL

%s%8ld%lu%lu%lu%f/%f


", r); ap_rprintf(r, "TOTAL BYTES LEFT = %lu bytes

", bytes_left); if ((float)bytes_left > 500.0 ) Average_speed = (float) Average_speed/(float)count_speed ; else Average_speed = Average; TimeLeft = ((float) bytes_left)/Average_speed ; /*my_global_record = ap_scoreboard_image->global;*/ /*my_global_record.time_to_completion = time_left;*/ /*update_scoreboard_global();*/ ap_rputs("Average Processing Speed = ", r ); format_byte_out(r, Average_speed); ap_rputs("/second

", r); ap_rprintf(r, "Time left to process requests = %f seconds
\n",TimeLeft); if (sendto(my_sock, &TimeLeft, sizeof(float), 0, &to_LBA, sizeof(to_LBA))<0) perror("relay datagram message"); /*ap_rprintf(r, "Time value copied to SB = %f seconds
\n", score_record.time_to_completion);*/ /************************************************************************************* bytes_left = 0; bytes_remaining_for_this_request = 0; ap_sync_scoreboard_image(); for (i = 0; i < HARD_SERVER_LIMIT; ++i) { score_record = ap_scoreboard_image->servers[i]; lres = score_record.access_count; if (lres !=0 ||(score_record.status != SERVER_READY && score_record.status != SERVER_DEAD) ) { if ( strcmp(score_record.my_file, cgifile) != 0) { if (strstr(score_record.my_file, c_g_i_1) != NULL || strstr(score_record.my_file, c_g_i_2) != NULL ) bytes_remaining_for_this_request = 0 ; else { /* start else 1 */ /*@@@@@@@@@@@@@ Test for directory @@@@@@@* StrLen = strlen( score_record.my_file); if ( score_record.my_file[StrLen] == '/' ){ my_new_file = (char*)malloc(StrLen); strncpy(my_new_file, score_record.my_file, StrLen); strcat(my_new_file, my_index); strcpy(score_record.my_file, my_new_file); stat( score_record.my_file, &mystatbuf); free(my_new_file); myfileSz = mystatbuf.st_size; } /*end if */ /*@@@@@@@@@@@@@@@@@@@@* else /*start else 2 * myfileSz = score_record.myfilesize; bytes_remaining_for_this_request = myfileSz - score_record.mybytes_sent; } /*end else 1 * bytes_left += bytes_remaining_for_this_request; } /* end if strcmp * } /* end lres * } /* end for */ /* ap_rprintf(r, "String size = %d
\n", strlen(my_index)); ap_rprintf(r, "String 5th char is: %s
\n", my_index[5] ); ap_rprintf(r, "last char is: %s
\n", my_index[strlen(my_index)] ); */ /*******************************************************************/ /******************************************************************/ for (i = 0; i < HARD_SERVER_LIMIT; ++i) { ap_rputc(stat_buffer[i], r); if ((i % STATUS_MAXLINE == (STATUS_MAXLINE - 1)) && !short_report) ap_rputs("\n", r); } if (short_report) ap_rputs("\n", r); else { ap_rputs("\n", r); ap_rputs("Scoreboard Key:
\n", r); ap_rputs("\"_\" Waiting for Connection, \n", r); ap_rputs("\"S\" Starting up, \n", r); ap_rputs("\"R\" Reading Request,
\n", r); ap_rputs("\"W\" Sending Reply, \n", r); ap_rputs("\"K\" Keepalive (read), \n", r); ap_rputs("\"D\" DNS Lookup,
\n", r); ap_rputs("\"L\" Logging, \n", r); ap_rputs("\"G\" Gracefully finishing, \n", r); ap_rputs("\".\" Open slot with no current process

\n", r); ap_rputs("

\n", r); /*ap_rputs("Time left
\n",r); ap_rprintf(r,"Time left for req= %ld
\n", time_left);*/ if (!ap_extended_status) { int j = 0; ap_rputs("PID Key:
\n", r); ap_rputs("

\n", r);
	    for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
		if (stat_buffer[i] != '.') {
		    ap_rprintf(r, "   %d in state: %c ", pid_buffer[i],
		     stat_buffer[i]);
		    if (++j >= 3) {
		    	ap_rputs("\n", r);
			j = 0;
		    } else
		    	ap_rputs(",", r);
		}
	    }
	    ap_rputs("\n", r);
	    ap_rputs("
\n", r); } }