Firewall/FirewallHandler.php
public function onKernelRequest(GetResponseEvent $event)
	{
		if (!$event->isMasterRequest()) {
			return;
		}
		
		$request = $event->getRequest();
		if ($this->reverseProxies) {
			$request->setTrustedProxies($this->reverseProxies);
		}
		if ($this->xForwardedFor) {
			$request->setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->xForwardedFor);
		}
		
		$ip = $request->getClientIp();
		$start = microtime(true);

		$this->key=$this->prefix.'_'.$ip;
		
		$this->memcache->add($this->key,0,false,$this->lockMaxWait);
		while (true) {
			$this->incremented = true;
			if ($this->memcache->increment($this->key)<=$this->concurrency) {
				break;
			}
			$this->incremented = false;
			$this->memcache->decrement($this->key);
			if (!$this->spinLockWait || microtime(true)-$start>$this->lockMaxWait) {
				throw new TooManyRequestsHttpException();
			}
			usleep($this->spinLockWait);
		}
	}
public function onKernelRequest(GetResponseEvent $event)
	{
		if (!$event->isMasterRequest()) {
			return;
		}
		
		$request = $event->getRequest();
		if ($this->reverseProxies) {
			$request->setTrustedProxies($this->reverseProxies);
		}
		if ($this->xForwardedFor) {
			$request->setTrustedHeaderName(Request::HEADER_CLIENT_IP, $this->xForwardedFor);
		}
		
		$ip = $request->getClientIp();
		$start = microtime(true);

		$this->key=$this->prefix.'_'.$ip;
		
		$this->memcache->add($this->key,0,false,$this->lockMaxWait);
		while (true) {
			$this->incremented = true;
			if ($this->memcache->increment($this->key)<=$this->concurrency) {
				break;
			}
			$this->incremented = false;
			$this->memcache->decrement($this->key);
			if (!$this->spinLockWait || microtime(true)-$start>$this->lockMaxWait) {
				throw new TooManyRequestsHttpException();
			}
			usleep($this->spinLockWait);
		}
	}
public function onKernelRequest ( GetResponseEvent $ event ) { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ request = $ event -> getRequest ( ) ; if ( $ this -> reverseProxies ) { $ request -> setTrustedProxies ( $ this -> reverseProxies ) ; } if ( $ this -> xForwardedFor ) { $ request -> setTrustedHeaderName ( Request :: HEADER_CLIENT_IP , $ this -> xForwardedFor ) ; } $ ip = $ request -> getClientIp ( ) ; $ start = microtime ( true ) ; $ this -> key = $ this -> prefix . '_' . $ ip ; $ this -> memcache -> add ( $ this -> key , 0 , false , $ this -> lockMaxWait ) ; while ( true ) { $ this -> incremented = true ; if ( $ this -> memcache -> increment ( $ this -> key ) <= $ this -> concurrency ) { break ; } $ this -> incremented = false ; $ this -> memcache -> decrement ( $ this -> key ) ; if ( ! $ this -> spinLockWait || microtime ( true ) - $ start > $ this -> lockMaxWait ) { throw new TooManyRequestsHttpException ( ) ; } usleep ( $ this -> spinLockWait ) ; } }
If the current concurrency is too high, delay or throw a TooManyRequestsHttpException

@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event Event

@throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
If the current concurrency is too high delay or throw a TooManyRequestsHttpException