Thread: [Cppcms-users] Q&A: async gzip and mount
Brought to you by:
artyom-beilis
|
From: Markus R. <us...@ma...> - 2013-03-09 16:50:14
Attachments:
mount.cpp
|
Hi users! Here are some questions (with answers) which could be of interest: 1.) Is it possible to use gzip compression on async connections? Artyom Beilis wrote: > No you can't, for two reasons: > > 1. You can't really do streaming with gzip compression > as the stream becomes buffered. > 2. The compression process costs a lot so it not wise > to use it in the single event-loop's thread. 2.) What is the difference between booster::intrusive_ptr<App> c=new App(service); service.applications_pool().mount(c); and: service.applications_pool().mount(cppcms::applications_factory<App>()); Artyom Beilis wrote: > in the first case you have a single application > instance that only being executed in a single thread > of the event loop, in the second case multiple applications > are created on demand and run in the thread pool. See: http://cppcms.com/cppcms_ref/1.0.2/classcppcms_1_1applications__pool.html 3.) Are there some examples how to mount multiple applications (both sync and async; with dispatcher and using main; mounting the same application twice) using mount_points? Now there is: cppcms::service app(argc,argv); app.applications_pool().mount(cppcms::applications_factory<myapp>(), cppcms::mount_point("/myapp(/(.*))?", 1)); app.applications_pool().mount(cppcms::applications_factory<numbers>(), cppcms::mount_point("/numbers(/(.*))?", 1)); app.applications_pool().mount(cppcms::applications_factory<letters>(), cppcms::mount_point("/letters(/(.*))?", 1)); booster::intrusive_ptr<async> c (new async(app)); app.applications_pool().mount(c, cppcms::mount_point("/async(/(.*))?", 1)); app.applications_pool().mount(cppcms::applications_factory<sync>(), cppcms::mount_point("/sync(/(.*))?", 1)); app.run(); See attached file for full example, there are small issues with double mounting in the example: the URL mapper does not always work correctly. See also http://cppcms.com/cppcms_ref/1.0.2/classcppcms_1_1mount__point.html Best regards Markus |
|
From: Artyom B. <art...@ya...> - 2013-03-11 08:41:36
|
> > See attached file for full example, there are small issues with double > mounting in the example: the URL mapper does not always work correctly. > Can you explain what is the problem? Artyom |
|
From: Markus R. <us...@ma...> - 2013-03-11 18:31:38
Attachments:
config.js
|
Hello! Artyom Beilis wrote: >> See attached file for full example, there are small issues with double >> mounting in the example: the URL mapper does not always work correctly. > Can you explain what is the problem? The problem is within the example mount.cpp (urls with scriptname /hello, config is attached) When you go to: http://localhost:8080/hello/myapp/numbers or http://localhost:8080/myapp/numbers the URL for odd is correct (works): http://localhost:8080/myapp/numbers/odd But when you go to: http://localhost:8080/hello/numbers or http://localhost:8080/numbers the generated URL for odd numbers is http://localhost:8080/odd which does not work (404 - Not found). best regards Markus Raab |
|
From: Markus R. <us...@ma...> - 2013-03-11 20:17:13
|
Hello!
Btw, this code (also seen in many other examples floating around):
> booster::intrusive_ptr<async> c (new async(app));
> app.applications_pool().mount(c, cppcms::mount_point("/async(/(.*))?",
> 1));
typically crashes here at shutdown because intrusive_ptr holds the async
object longer then the app itself which may lead to shutdown crashes like:
#0 0x00007f5028e9e624 in cppcms::application::root() () from
/usr/lib/libcppcms.so.1
#1 0x00007f5028e9ea93 in
booster::intrusive_ptr_release(cppcms::application*) () from
/usr/lib/libcppcms.so.1
#2 0x0000000000404a1d in booster::intrusive_ptr<async>::~intrusive_ptr() ()
#3 0x000000000040263b in main ()
or
#0 0xb7a71587 in cppcms::applications_pool::put(cppcms::application*) ()
from /usr/lib/libcppcms.so.1
#1 0xb7a73c4e in booster::intrusive_ptr_release(cppcms::application*) ()
from /usr/lib/libcppcms.so.1
#2 0x08494f40 in
booster::intrusive_ptr<LVDC_service::Scan_data_service>::~intrusive_ptr
(this=0xb4f2c21c, __in_chrg=<optimized out>) at
/home/markus/LVDC/dev/lvdc/lvdc_pp/../../libs/booster/include/booster/intrusive_ptr.h:68
also wrong would be to put above two lines in a scope, or having
booster::intrusive_ptr<async> c (new async(app));
because then the application would not be mounted correctly and it would
lead to a 404 Not found.
Intrusive ptr is hardly documented (neither in booster nor in boost),
so here would be a (imho) correct version:
145 cppcms::service app(argc,argv);
146 {
147
app.applications_pool().mount(cppcms::applications_factory<myapp>(),
cppcms::mount_point("/myapp(/(.*))?", 1));
148
app.applications_pool().mount(cppcms::applications_factory<numbers>(),
cppcms::mount_point("/numbers(/(.*))?", 1));
149
app.applications_pool().mount(cppcms::applications_factory<letters>(),
cppcms::mount_point("/letters(/(.*))?", 1));
150
151 booster::intrusive_ptr<async> c (new async(app));
152 app.applications_pool().mount(c,
cppcms::mount_point("/async(/(.*))?", 1));
153
app.applications_pool().mount(cppcms::applications_factory<sync>(),
cppcms::mount_point("/sync(/(.*))?", 1));
154 app.run();
155 }
That would terminate the async object after app.run() but before service is
deallocated. Please correct me if I am wrong.
best regards
Markus Raab
P.s. sorry for missing debug symbols, I could not find a libcppcms-dbg
debian package?
And what is http://apt.cppcms.com/dists/squeezy? Do you mean wheezy?
|