Re: [Cppcms-users] Segmentation fault
Brought to you by:
artyom-beilis
|
From: Mario P. <mp...@us...> - 2010-10-21 15:24:44
|
2010-10-20 19:30 +0200, Mario Palomo wrote:
> Hello,
>
> I'm starting to use CppCMS ("cppcms-0.99.3.tar.bz2" downloaded from
> SourceForge), and noticed that when generating very long responses, the
> executable ends with a segfault. I am using the built-in server, and I reduced
> the code to the following:
>
[...]
If it helps, I have written an equivalent asynchronous application, and the
error does NOT occur:
______________________________________________________________________________
/*
bench.cpp
*/
#include <cppcms/application.h>
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
#include <iostream>
class bench : public cppcms::application
{
public:
bench(cppcms::service &srv) : cppcms::application(srv) { }
virtual void main(std::string url)
{
for (int i=0; i < 100000; ++i) {
response().out() << i << "\n";
}
release_context()->async_complete_response();
}//main
};//class bench
int main(int argc, char *argv[])
{
try {
cppcms::service srv(argc, argv);
booster::intrusive_ptr<bench> app = new bench(srv);
srv.applications_pool().mount(app);
srv.run();
}
catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}//main
______________________________________________________________________________
______________________________________________________________________________
//config.js
{
"service": {
"api": "http",
"port": 8080,
},
"http": {
"script_names": [ "/bench" ],
},
}
______________________________________________________________________________
When do you recommend using an application of one type or the other?
Best regards,
Mario
|