Re: Best way to manage open slots for download

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aras wrote:
> First of all, Happy New Year for everyone in the list. I wish 2007 brings
> all us happiness, health and peace.
> 
> I want to read your advises at a point i am stuck within, i have an
> application that serves downloads to clients. For some reason i am limiting
> total open slot for some group of users (not related to my technical
> question).
> 
> Example;
> 
> // CHECKS SLOT HERE
> 
> else {  // IF THERE ANY AVAILABLE SLOTS SEND THE FILE
> 
> // INCREMENT SLOT NUMBER BY 1
> 
> $fp = fopen($pathside,"r");
> 
> if ($fp) {
> 
> 	while (!feof($fp)) {
> 	echo fread($fp, 334);
> 
> 	$bytes_out += 334;
>  	ob_flush();
> 
> 		if ($bytes_out > $size) {
> 
> 		// DECREASE SLOT NUMBER BY 1, BECAUSE THIS DOWNLOAD IS FINISHED
> 
> 		}
> 
> 	}
> 
> }
> 
> }
> 
> 
> Slots are recorded and checked from a simple mysql table. Everything works
> in this scenario. There is no problem if a person starts a download and
> finishes it, his slots get empty upon doing so. Yet if he cancelles the
> transfer, he will never reach my control structure to empty the slot. And
> slots will be full of zombies.
> 
> I have thought of updating a mysql field for alive-connections in the while
> loop, but it will definitely add some load on my server. Updating a system
> file is not secure and good way.
> 
> What other ways can you recommend to me for the situtation?

Read through this:

http://www.php.net/manual/en/features.connection-handling.php

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux