同时访问时,停在防火墙处。 :安全:Symfony2

When accessing at the same time, it stops at a fire wall. : Security : Symfony2

environment, precondition


有简单的动作。

路由:demo_home_index

indexAction()
{
    sleep(60);

    return // ...
}

并且,有一个读取文件的操作。

路由:demo_home_read

public function readAction()
{
    $file       = "/path/to/file/read.txt";
    $contents   = false;

    if (file_exists($file)) {
        $fp = fopen($file, 'r');
        $contents = fgets($fp);
        fclose($fp);
    }

    return new Response(json_encode(array(
        'contents' => $contents,
    )));
}

所以,首先从UI,异步,我访问一个indexAction。 同时在处理什么是读文件的区间函数。

$.ajax({
    url         : Routing.generate("demo_home_index"),
    type        : "GET",
    dataType    : 'json'
})
.done(function(response){
    // This isn't returning for 60 seconds for a sleep.
    console.log(response);
});

var timer = setInterval(function(){
    $.ajax({
        url         : Routing.generate("demo_home_read"),
        type        : "GET",
        dataType    : 'json'
    })
    .done(function(response){
        console.log(response);
    });
}, 3000);

这一次,间隔访问在第一次访问完成时暂停。 所以,当第一个访问完成后,其他访问也依次完成。

这在正常访问中也会发生。 (非异步) 在处理 indexAction(睡眠)时,即使我在选项卡浏览器上访问其他操作(其他页面),它也会停止。 (浏览器会处于loading状态)

不停止,是否可以同时处理?

是否可以更改 Symfony2 的防火墙设置?

或者,是否可以更改 FOSUserBundle 的设置?

我现在处于不知道原因的状态

谢谢。

这可能是基于文件的会话文件的问题。基本上,PHP 会话管理锁定会话文件,下一个请求(在同一会话上)必须等到锁被释放。

Symfony 2 blocked concurrency