ProFTPD及WU-FTP的BANDWIDTH控制
2007-12-03 16:20:31 来源:WEB开发网if(!p) { @@ -433,10 +608,53 @@ cnt espos; log_add_run(mpid,NULL,session.user,NULL,0,session.xfer.file_size, 0,NULL);
+ /* Calculate bandwidth transfer time + * + * if "BandWidth" , "MaxBandWidth" or "MinBandWidth" not be defin ed or + * be defined error. i will turn off bandwidth limit. + */ + + cur_user long)get_param_int(cmd->server->conf,"CURRENT-CLIENTS",F ALSE)+1; + cur_rate long)get_param_int(cmd->server->conf,"Bandwidth",FALSE);
+ max_rate long)get_param_int(cmd->server->conf,"MaxBandwidth",FALS E); + min_rate long)get_param_int(cmd->server->conf,"MinBandwidth",FALS E); + + cur_rate □r_rate / cur_user; + + if(max_rate <□) + max_rate □; + if(min_rate <□) + min_rate □; + if(cur_rate <□) + { + if(max_rate > 0L) + cur_rate ax_rate; + else if(min_rate > 0L) + cur_rate in_rate; + else + cur_rate □; + } + + if((cur_rate > max_rate) && (max_rate > 0L)) + cur_rate ax_rate; + if(min_rate > cur_rate) + cur_rate in_rate; + + if(cur_rate > 0L) { + opt_time.tv_sec long int) bufsize / cur_rate; + opt_time.tv_usec long int) ((float) bufsize * 1000000 / cur_rat e - opt_time.tv_sec * 1000000); + log_debug(DEBUG1, "Current Bandwidth : %ld bytes/sec",cur_rate) ; + } + while((len s_read(retr_file,retr_fd,lbuf,bufsize)) > 0) { if(XFER_ABORTED) break;
更多精彩
赞助商链接