cppcms-users Mailing List for CppCMS C++ Web Framework (Page 127)
Brought to you by:
artyom-beilis
You can subscribe to this list here.
2009 |
Jan
|
Feb
(22) |
Mar
|
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(4) |
Feb
|
Mar
(8) |
Apr
(8) |
May
(8) |
Jun
(36) |
Jul
(63) |
Aug
(126) |
Sep
(47) |
Oct
(66) |
Nov
(46) |
Dec
(42) |
2011 |
Jan
(87) |
Feb
(24) |
Mar
(54) |
Apr
(21) |
May
(22) |
Jun
(18) |
Jul
(22) |
Aug
(101) |
Sep
(57) |
Oct
(33) |
Nov
(34) |
Dec
(66) |
2012 |
Jan
(64) |
Feb
(76) |
Mar
(73) |
Apr
(105) |
May
(93) |
Jun
(83) |
Jul
(84) |
Aug
(88) |
Sep
(57) |
Oct
(59) |
Nov
(35) |
Dec
(49) |
2013 |
Jan
(67) |
Feb
(17) |
Mar
(49) |
Apr
(64) |
May
(87) |
Jun
(64) |
Jul
(93) |
Aug
(23) |
Sep
(15) |
Oct
(16) |
Nov
(62) |
Dec
(73) |
2014 |
Jan
(5) |
Feb
(23) |
Mar
(21) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(27) |
Aug
(16) |
Sep
(5) |
Oct
(37) |
Nov
(12) |
Dec
(9) |
2015 |
Jan
(7) |
Feb
(7) |
Mar
(44) |
Apr
(28) |
May
(5) |
Jun
(12) |
Jul
(8) |
Aug
|
Sep
(39) |
Oct
(34) |
Nov
(30) |
Dec
(34) |
2016 |
Jan
(66) |
Feb
(23) |
Mar
(33) |
Apr
(15) |
May
(11) |
Jun
(15) |
Jul
(26) |
Aug
(4) |
Sep
(1) |
Oct
(30) |
Nov
(10) |
Dec
|
2017 |
Jan
(52) |
Feb
(9) |
Mar
(24) |
Apr
(16) |
May
(9) |
Jun
(12) |
Jul
(33) |
Aug
(8) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(6) |
2018 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(1) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(8) |
Nov
(2) |
Dec
(2) |
2019 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(6) |
Aug
(25) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
|
2021 |
Jan
|
Feb
|
Mar
(7) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(9) |
Oct
(1) |
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Mario P. <mp...@us...> - 2010-10-20 17:40:25
|
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: ______________________________________________________________________________ /* 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"; } }//main };//class bench int main(int argc, char *argv[]) { try { cppcms::service srv(argc, argv); srv.applications_pool().mount(cppcms::applications_factory<bench>()); 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" ], }, } ______________________________________________________________________________ I start the application: $ ./bench -c config.js Then, I use "curl" to make a request: $ curl http://localhost:8080/bench And the application ("bench") terminates with a segmentation fault. A backtrace shows that the last statement that is executed is the line 476 of file "cgi_api.cpp" ('write_some()' in function 'connection::write()'), but so far I have not gotten more information. Can anyone else reproduce the problem? Can be solved if I use the latest version in SVN? (I'll try to test soon with the latest version of the code). Thank you for creating something as awesome as CppCMS. Regards, Mario |
From: Troch, J. <Joh...@ba...> - 2010-10-20 11:07:07
|
Hi all, I recently got into some trouble while cross-compiling CppCms and therefore I have written some guidelines to make it work: How to cross-build cppcms 1/ download and cross-compile at least zlib and pcre-lib 2/ download cppcms tarball 3/ untar cppcms tarball 4/ cd cppcms 5/ untar cppcms_boost.tar.bz2 6/ patch CmakeLists.txt and /booster/CMakeLists.txt if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") set(CXX_FLAGS "${CXX_FLAGS} -pthreads") else() set(CXX_FLAGS "${CXX_FLAGS} -lpthread -ldl") endif() (This patch results in some warnings during native compilation however) 7/ mkdir build cd build 8/ cmake -DCMAKE_TOOLCHAIN_FILE=ToolChain.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DDISABLE_ICU_LOCALE=ON -DDISABLE_POSIX_LOCALE=ON -DDISABLE_SCGI=ON -DDISABLE_HTTP=ON -DCMAKE_INSTALL_PREFIX="/home/jtr/NetViz/BuildCppCms/libs" -DCMAKE_INCLUDE_PATH="/home/jtr/NetViz/BuildCppCms/libs/include" -DCMAKE_LIBRARY_PATH="/home/jtr/NetViz/BuildCppCms/libs/lib" -DZLIB_INCLUDE_DIR=/home/jtr/NetViz/BuildCppCms/zlib-1.2.5 -DZLIB=/home/jtr/NetViz/BuildCppCms/zlib-1.2.5/libz.so -DPCRE_LIB=/home/jtr/NetViz/BuildCppCms/pcre-8.10/.libs/libpcre.so -DPTHREAD_INC=/home/jtr/NetViz/BuildCppCms/libs/include .. (the important parts are in bold, without these, I did not succeed in any way. The paths need to be adapted of course) 9/ make 10/ make install Regards, John DISCLAIMER: Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you. |
From: Artyom <art...@ya...> - 2010-10-19 20:51:27
|
Hello All, Daemonization is implemented in trunk. Together with: - Switching to unprivileged user and group - Chrooting to specific directry for extra paranoic users. See: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_config#daemon for detains. Of course this is relvant for Unix users and does not supported on Windows. > It is planned to be implemented > (quite soon), but not done yet. > > Artyom > > > > > > Hallo, > > > > is there an easy way to run a cppcms service as daemon > or do I have to > > implement the double-fork myself? > > > > Thanks, > > Julian > > |
From: Artyom <art...@ya...> - 2010-10-16 12:58:35
|
I've notices that when I build the CppCMS for ARM I confiure all search paths in CMAKE_FIND_ROOT_PATH in ToolChain.cmake file, try to use it instead of command line parameters. Also please post the file CMakeFiles/CMakeOutput.log to see if something suspicios there. Artyom P.S.: This is why I hate CMake sometimes :-) > >From: "Troch, John" <Joh...@ba...> >To: cpp...@li... >Sent: Fri, October 15, 2010 1:17:34 PM >Subject: [Cppcms-users] cmake crosscompilation problems > > >Hi all, > >I’m trying to cross-compile CppCms for an embedded platform. >I have first cross-compiled libz, libpcre and libpthread in a dedicated >directory: > >This is the content of my /libs/lib directory > >[jtr@bvwsrv06 ~/NetViz/BuildCppCms/libs/lib]$ ls -la total 21036 >drwxr-xr-x 3 jtr users 4096 2010-10-13 13:52 . >drwxr-xr-x 9 jtr users 4096 2010-10-09 19:44 .. >-rw-r--r-- 1 jtr users 134738 2010-10-09 20:10 libpcre.a >-rwxr-xr-x 1 jtr users 943 2010-10-09 20:10 libpcre.la >lrwxrwxrwx 1 jtr users 16 2010-10-09 20:10 libpcre.so ->libpcre.so.0.0.1 >lrwxrwxrwx 1 jtr users 16 2010-10-09 20:10 libpcre.so.0 -> libpcre.so.0.0.1 >-rwxr-xr-x 1 jtr users 108467 2010-10-09 20:10 libpcre.so.0.0.1 -rwxr-xr-x 1 >jtr users 129053 2010-10-13 13:49 libpthread-2.5.so >lrwxrwxrwx 1 jtr users 15 2010-10-13 13:52 libpthread.so -> libpthread.so.0 >lrwxrwxrwx 1 jtr users 17 2010-10-13 13:49 libpthread.so.0 -> >libpthread-2.5.so >-rw-r--r-- 1 jtr users 108678 2010-10-09 20:30 libz.a >lrwxrwxrwx 1 jtr users 13 2010-10-09 20:30 libz.so -> libz.so.1.2.5 >lrwxrwxrwx 1 jtr users 13 2010-10-09 20:30 libz.so.1 -> libz.so.1.2.5 >-rwxr-xr-x 1 jtr users 109533 2010-10-09 20:30 libz.so.1.2.5 > >This is the content of my /libs/include directory > >drwxr-xr-x 2 jtr users 4096 2010-10-13 13:58 . >drwxr-xr-x 9 jtr users 4096 2010-10-09 19:44 .. >-rw-r--r-- 1 jtr users 39517 2010-10-12 15:55 regex.h >... (a lot more files) >-rw-r--r-- 1 jtr users 13038 2010-10-12 15:55 pcre.h >-rw-r--r-- 1 jtr users 39423 2010-10-13 13:58 pthread.h >-rw-r--r-- 1 jtr users 79564 2010-10-13 13:47 zlib.h > >And I execute the following cmake command (with cross-compiler settings included >in Toolchain.cmake file): > >cmake -DCMAKE_TOOLCHAIN_FILE=ToolChain.cmake >-DCMAKE_INSTALL_PREFIX="/home/jtr/NetViz/BuildCppCms/libs" >-DCMAKE_INCLUDE_PATH="/home/jtr/NetViz/BuildCppCms/libs/include" >-DCMAKE_LIBRARY_PATH="/home/jtr/NetViz/BuildCppCms/libs/lib" .. > >cmake complains as follows: > >******************************************************************************************************************************************************** > >CMake Error: The following variables are used in this project, but they are set >to NOTFOUND. >Please set them or make sure they are set and tested correctly in the CMake >files: >PCRE_LIB > linked by target "booster" in directory >/home/jtr/NetViz/BuildCppCms/cppcms/booster > linked by target "booster-static" in directory >/home/jtr/NetViz/BuildCppCms/cppcms/booster >PTHREAD_INC > used as include directory in directory >/home/jtr/NetViz/BuildCppCms/cppcms/booster >ZLIB_INCLUDE_DIR > used as include directory in directory /home/jtr/NetViz/BuildCppCms/cppcms > >When are these variables set and by whom? >What am I doing wrong? >How can I fix this? > >Regards, >John > > > > > > > > > >DISCLAIMER: >Unless indicated otherwise, the information contained in this message is >privileged and confidential, and is intended only for the use of the >addressee(s) named above and others who have been specifically authorized to >receive it. If you are not the intended recipient, you are hereby notified that >any dissemination, distribution or copying of this message and/or attachments is >strictly prohibited. The company accepts no liability for any damage caused by >any virus transmitted by this email. Furthermore, the company does not warrant a >proper and complete transmission of this information, nor does it accept >liability for any delays. If you have received this message in error, please >contact the sender and delete the message. Thank you. > |
From: Troch, J. <Joh...@ba...> - 2010-10-15 11:44:25
|
Hi all, I'm trying to cross-compile CppCms for an embedded platform. I have first cross-compiled libz, libpcre and libpthread in a dedicated directory: This is the content of my /libs/lib directory [jtr@bvwsrv06 ~/NetViz/BuildCppCms/libs/lib]$ ls -la total 21036 drwxr-xr-x 3 jtr users 4096 2010-10-13 13:52 . drwxr-xr-x 9 jtr users 4096 2010-10-09 19:44 .. -rw-r--r-- 1 jtr users 134738 2010-10-09 20:10 libpcre.a -rwxr-xr-x 1 jtr users 943 2010-10-09 20:10 libpcre.la lrwxrwxrwx 1 jtr users 16 2010-10-09 20:10 libpcre.so ->libpcre.so.0.0.1 lrwxrwxrwx 1 jtr users 16 2010-10-09 20:10 libpcre.so.0 -> libpcre.so.0.0.1 -rwxr-xr-x 1 jtr users 108467 2010-10-09 20:10 libpcre.so.0.0.1 -rwxr-xr-x 1 jtr users 129053 2010-10-13 13:49 libpthread-2.5.so lrwxrwxrwx 1 jtr users 15 2010-10-13 13:52 libpthread.so -> libpthread.so.0 lrwxrwxrwx 1 jtr users 17 2010-10-13 13:49 libpthread.so.0 -> libpthread-2.5.so -rw-r--r-- 1 jtr users 108678 2010-10-09 20:30 libz.a lrwxrwxrwx 1 jtr users 13 2010-10-09 20:30 libz.so -> libz.so.1.2.5 lrwxrwxrwx 1 jtr users 13 2010-10-09 20:30 libz.so.1 -> libz.so.1.2.5 -rwxr-xr-x 1 jtr users 109533 2010-10-09 20:30 libz.so.1.2.5 This is the content of my /libs/include directory drwxr-xr-x 2 jtr users 4096 2010-10-13 13:58 . drwxr-xr-x 9 jtr users 4096 2010-10-09 19:44 .. -rw-r--r-- 1 jtr users 39517 2010-10-12 15:55 regex.h ... (a lot more files) -rw-r--r-- 1 jtr users 13038 2010-10-12 15:55 pcre.h -rw-r--r-- 1 jtr users 39423 2010-10-13 13:58 pthread.h -rw-r--r-- 1 jtr users 79564 2010-10-13 13:47 zlib.h And I execute the following cmake command (with cross-compiler settings included in Toolchain.cmake file): cmake -DCMAKE_TOOLCHAIN_FILE=ToolChain.cmake -DCMAKE_INSTALL_PREFIX="/home/jtr/NetViz/BuildCppCms/libs" -DCMAKE_INCLUDE_PATH="/home/jtr/NetViz/BuildCppCms/libs/include" -DCMAKE_LIBRARY_PATH="/home/jtr/NetViz/BuildCppCms/libs/lib" .. cmake complains as follows: ************************************************************************ ************************************************************************ ******** CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: PCRE_LIB linked by target "booster" in directory /home/jtr/NetViz/BuildCppCms/cppcms/booster linked by target "booster-static" in directory /home/jtr/NetViz/BuildCppCms/cppcms/booster PTHREAD_INC used as include directory in directory /home/jtr/NetViz/BuildCppCms/cppcms/booster ZLIB_INCLUDE_DIR used as include directory in directory /home/jtr/NetViz/BuildCppCms/cppcms When are these variables set and by whom? What am I doing wrong? How can I fix this? Regards, John DISCLAIMER: Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you. |
From: augustin <aug...@ov...> - 2010-10-14 13:45:17
|
On Thursday 14 October 2010 09:12:42 pm Artyom wrote: > time_t t = time(NULL); > sql << "SELECT COUNT(*) FROM table WHERE time < ?", static_cast<long > long int>(t); Thanks a lot. It works this way. If anybody is interested, here is the related ticket: https://sourceforge.net/tracker/?func=detail&aid=3087401&group_id=209965&atid=1011835 Augustin. -- Friends: http://www.reuniting.info/ http://activistsolutions.org/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom <art...@ya...> - 2010-10-14 13:12:49
|
> > I save it as an integer. > The problem is that the code won't compile: > > /usr/local/include/dbixx/dbixx.h:148: error: call of overloaded ‘bind(long > > int&, bool)’ is ambiguous. > > Augustin. > Yes, you are right, cast it to long long it and this would work. time_t t = time(NULL); sql << "SELECT COUNT(*) FROM table WHERE time < ?", static_cast<long long int>(t); You may open a bug/feature ticket to show that bind/fetch member functions require better overloading. Artyom |
From: augustin <aug...@ov...> - 2010-10-14 13:01:28
|
On Thursday 14 October 2010 08:25:41 pm Artyom wrote: > > > > What's the proper way to use Unix timestamps in dbixx queries? > > Depending on how do you save it in the DB, > if you save it as a number, then just operate over time_t as numeric value. > I save it as an integer. The problem is that the code won't compile: /usr/local/include/dbixx/dbixx.h:148: error: call of overloaded ‘bind(long int&, bool)’ is ambiguous. Augustin. -- Friends: http://www.reuniting.info/ http://activistsolutions.org/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom <art...@ya...> - 2010-10-14 12:25:48
|
> Hello, > > What's the proper way to use Unix timestamps in dbixx queries? Depending on how do you save it in the DB, if you save it as a number, then just operate over time_t as numeric value. If you save it as datatime then you should use std::tm - i.e. convert time_t to std::tm and then save it or load it from DB (see man localtime_r, mktime) Artyom |
From: augustin <aug...@ov...> - 2010-10-14 11:55:38
|
Hello, What's the proper way to use Unix timestamps in dbixx queries? I have: dbixx::session sql; // ... time_t t = time(NULL); sql << "SELECT COUNT(*) FROM table WHERE time < ?", t; dbixx::row r; sql.single(r); int count; r >> count; but it won't compile: In file included from main.cpp:3: /usr/local/include/dbixx/dbixx.h: In member function ‘dbixx::session& dbixx::session::operator,(T) [with T = long int]’: main.cpp:170: instantiated from here /usr/local/include/dbixx/dbixx.h:148: error: call of overloaded ‘bind(long int&, bool)’ is ambiguous /usr/local/include/dbixx/dbixx.h:128: note: candidates are: void dbixx::session::bind(const std::string&, bool) <near match> /usr/local/include/dbixx/dbixx.h:129: note: void dbixx::session::bind(const long long int&, bool) /usr/local/include/dbixx/dbixx.h:130: note: void dbixx::session::bind(const long long unsigned int&, bool) /usr/local/include/dbixx/dbixx.h:131: note: void dbixx::session::bind(const int&, bool) /usr/local/include/dbixx/dbixx.h:132: note: void dbixx::session::bind(const unsigned int&, bool) /usr/local/include/dbixx/dbixx.h:133: note: void dbixx::session::bind(const double&, bool) make: *** [learn] Error 1 thanks, Augustin. -- Friends: http://www.reuniting.info/ http://activistsolutions.org/ My projects: http://astralcity.org/ http://3enjeux.overshoot.tv/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom <art...@ya...> - 2010-10-14 07:56:47
|
> > Hallo, > > as the JSON RFC does not state that dots in names are forbidden, > cppcms::json::value should provide a way to request such named values, > as in: > { "dotted.key": "value" } JSON does not forbid such keys but form common knowledge of JavaScript it is not recommended as "." separates between object and its member. > > Currently, a json::value.find("dotted.key") would return an undefined > JSON value, because it would look whether "dotted" has an object as > value and this object has a name "key". Find uses "." as separator in path to the value, something like JSON XPath. If you want to access arbitrary key, you may just use operator [] or just access json::object directly that is just std::map<std::string,json::value> and search for arbitrary keys. > > If you don't want to remove the possibility to access an sub-object via > a dotted path, Of course I don't as it is very convenient way to access various members similar to XML's XPath > perhaps there would be a way to escape a path like in > std::string path = "dotted\\.key"; > And if you mean a backslash, "dotted\\\\.key" No, it is bad idea for several reasons: 1. The search by such path requires parsing it and it is not cheap, especially when users tend to use it widely, so thy notation should be as simple as possible. 2. It is bad practice to had such keys. 3. You still can access the key using operator [] or by accessing it directly via json::object. Read also this: http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1json_1_1value.html#d521e30dcb5abc912c0e4088faca2304 Artyom |
From: Julian P. <ju...@wh...> - 2010-10-13 17:24:59
|
Hallo, as the JSON RFC does not state that dots in names are forbidden, cppcms::json::value should provide a way to request such named values, as in: { "dotted.key": "value" } Currently, a json::value.find("dotted.key") would return an undefined JSON value, because it would look whether "dotted" has an object as value and this object has a name "key". If you don't want to remove the possibility to access an sub-object via a dotted path, perhaps there would be a way to escape a path like in std::string path = "dotted\\.key"; And if you mean a backslash, "dotted\\\\.key" Thanks, Julian |
From: Artyom <art...@ya...> - 2010-10-13 13:35:11
|
It is planned to be implemented (quite soon), but not done yet. Artyom ----- Original Message ---- > From: Julian Pietron <ju...@wh...> > To: cpp...@li... > Sent: Wed, October 13, 2010 3:34:58 PM > Subject: [Cppcms-users] Run cppcms service as daemon > > Hallo, > > is there an easy way to run a cppcms service as daemon or do I have to > implement the double-fork myself? > > Thanks, > Julian > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today. > http://p.sf.net/sfu/beautyoftheweb > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Julian P. <ju...@wh...> - 2010-10-13 13:32:12
|
Hallo, is there an easy way to run a cppcms service as daemon or do I have to implement the double-fork myself? Thanks, Julian |
From: Artyom <art...@ya...> - 2010-10-11 07:48:40
|
> > The problem I encounter is, that apparently my application is just > destroyed after having been constructed by the call to > factory.getApplication(), so there seems to be a problem with the > reference count of the intrusive pointer. > For writing the application I > roughly followed the chat example, which means I did add no methods or > likewise for the intrusive ptr implementation but only derived > cppcms::application and wrote some client handling methods. > I also tried returning an intrusive ptr instead of the raw pointer in > factory.getApplication(), but this did not change the behaviour. > I tried to pass the raw pointer to the mount method without wrapping it > in an intrusive pointer beforehand, but encountered same results as > before: application is immediately destroyed after having been > constructed, while the cppcms::service keeps running, including some > synchronously mounted applications(factories). > > I hope you can help me with fixing my problem, This is done by design. The applications pool **does not own** your asynchronous application, it only keeps a reference on it and when such application destroyed it is automatically unregistered in applications pool. You have two ways to keep it alive: ------------------------------------------------------------ Keep a pointer (intrusive_ptr) on it in some place you know ------------------------------------------------------------ Just create a place where you can store intrusive_ptr on your application and keep it alive, like in chat example, it was kept on stack. ------------------------------------------------------------ Make event loop to own the application by giving it some outstanding jobs, for example some timeout. ------------------------------------------------------------ By this design when the asynchronous application is not in use any more, it is automatically destroyed and unregistered. Generally if you have such asynchronous application created dynamically, they probably have some life time so they destroyed at some point, the basic case would be timeout. So just add a booster::aio::deadline_time to it and start asynchronous wait on this timer like this: class my_app: public cppcms::application { public: my_app(cppcms::service &s) : cppcms::application(s), timer_(s.get_io_service()) { } void async_start() { timer_.expires_from_now(10); // seconds booster::intrusive_ptr<my_app> self(this); timer_.async_wait(boost::bind(&my_app::on_timeout,self)); } void on_timeout() { /// done or restart by calling async_start } }; Now before you mount your application just call async_start, then the timer would pass the handler that owns the application (the self pointer we created) to the event loop and it owns the application, once all outstanding jobs are completed, it would be destroyed, it may be a timeout or may be some other source. For example in same way you may create an application that listens to plain TCP socket and HTTP requests. I may suggest to take a look on Boost.Asio and way it works, because CppCMS's and Booster's event loop is based on its ideas (actually before Booster was created CppCMS used Boost.Asio inside) Regards, Artyom P.S.: The code sample is not tested |
From: Julian P. <ju...@wh...> - 2010-10-11 00:43:39
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hallo, I currently experience a problem when mounting an asynchronous cppcms::application I wrote. I use the following code to mount the application: booster::intrusive_ptr<cppcms::application> app = factory.getApplication(srv); srv.applications_pool().mount(app,mp); Where - - factory.getApplication() would return a (raw) pointer to an instance of my application - - srv is, as you can guess, a cppcms::service instance - - mp means an instance of cppcms::mount_point indicating the mount point under which my application should be accessible The problem I encounter is, that apparently my application is just destroyed after having been constructed by the call to factory.getApplication(), so there seems to be a problem with the reference count of the intrusive pointer. For writing the application I roughly followed the chat example, which means I did add no methods or likewise for the intrusive ptr implementation but only derived cppcms::application and wrote some client handling methods. I also tried returning an intrusive ptr instead of the raw pointer in factory.getApplication(), but this did not change the behaviour. I tried to pass the raw pointer to the mount method without wrapping it in an intrusive pointer beforehand, but encountered same results as before: application is immediately destroyed after having been constructed, while the cppcms::service keeps running, including some synchronously mounted applications(factories). I hope you can help me with fixing my problem, Julian -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJMsl3nAAoJENidYKvYQHlQaO0P/3aa4IzWDAYgRXEkHoaNI1nk t2VPG4/yA0Gxzvfoj9Pzz7oGBD80vs1VFMUSfEu6AvD9slaZe2eBunV1PhvNLoeH aOpSqfVJUSOXzvrtNT+8OgsNQE4afS7Uzb5Ah4GxPckGvUgpkVdLYEZT7zp7hR77 Yi/ylp0+/zUtKkEVpUjFEbcHg8LXS1JggdTV3krfZGZasI0uBR3PqWEp09FBAb3y x3pm48hszobB9aMntwYqO8TyIsfd5x1tf+VOS4IavKhEWYw1fYhfc5AV8ZdSCrsn abM2YkkgiLHL1iy2V6Y1S45F1HWNdWdOuwGXp7jLVjBYl9K2H+Kk/r7v3FTnL6l1 1dEfSlVxRpzaK6fItT7upFuYpTf/JPoMc0AQksA4cFRd4NsJHbd7LlTxCs7WKzAg VzJCu+yIjDfC+Ct5EIKhxW+2w0Fo3grDGLLxGIF++3976hFweqHpVuoRQPsp9agu VPJps0+aDVOqjg/UdU6uL7Icftqm8Dn+LihZebBF25cErOOmbiwCA1orVhZ81Dlo f9RNCOsI0o4pMQjSUkr/7clq9RoHDOkZOH2njw1z/aVKjWh/41B1lvqORm/2k9g3 wk5CUdaZk8WtawM1WkG6EwMa0jEjUuY8uytPzFKATbHhcnUBuATNO2Evr9Vp25Jx Q3l28zh6akoeV5QlfpGv =888E -----END PGP SIGNATURE----- |
From: Artyom <art...@ya...> - 2010-10-07 08:26:57
|
> > The following simple code cause segmentation fault with both > booster::thread_specific_ptr and boost::thread_specific_ptr versions > when a client call "sum" rpc method. Before you use the pointer you need to init it for each thread on first use: if(!thread_int.get()) thread_int.reset(new int(0)) Read boost's documentation Artyom |
From: Artyom <art...@ya...> - 2010-10-07 08:24:28
|
> > Hallo, > > is it possible to add own code to cppcms's event loop? My application > shall listen on another socket than the http socket for plain JSON > messages and then let them be processed by a processor method. > Of course, I could run this server in a separate thread, but I think it > would be better to hook it into the event loop. > > Thanks, > Julian Hi, Sorry for late reply, I was on vacation. You can you booster::aio and specifically booster::aio::socket for such purpose, it is similar to Boost.Asio, but unlike most of other Booster code it has incompatible/different API. It is not fully documented yet, but you can see as examples of the code many places where socket is used and ask me. Note, it is likely that booster::aio would be changed before the stable release, mostly booster::aio::socket would be separated to acceptor/basic_socket/stream_socket etc. Artyom |
From: Artyom <art...@ya...> - 2010-10-07 08:18:11
|
Hello, 1st I'm sorry for late replay, I was on vacation. > > Do you have a model/fee structure for the alternative license? If this license > is reasonable for embedded use in consumer electronics I would like to >consider > it. > I do not have such commercial license ready yet for such purpose, as you can understand it requires some effort to prepare such license, including consulting with lawyer, etc. Please contact me privately to continue discussions of this matter. Artyom |
From: Julian P. <ju...@wh...> - 2010-10-04 17:35:41
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hallo, is it possible to add own code to cppcms's event loop? My application shall listen on another socket than the http socket for plain JSON messages and then let them be processed by a processor method. Of course, I could run this server in a separate thread, but I think it would be better to hook it into the event loop. Thanks, Julian -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIcBAEBAgAGBQJMqhBvAAoJENidYKvYQHlQtEoP/R2ykF/MoAr0dZjBuaOF15q9 jNr1bez7cXjqa1DKIaXntCztCCeHwLqi5hST1TyDM0IsQsQzB97SV5dWYdrx0M3z n+Fx/D90h3SABDMtY3uLmVOxBNaiW2VI/OKbTpCYcofNLrjOC2fZUEN3OG3JRRtX G1jKe5U9Zu0i725rpEs19QGzvk6Y2Hii8lmBgF0KkX56SLzdkEewEb0PLwye2cLi S2ftUMFQP9R8stP3XS6iUSnyc72O+0d1wLnyW1w9qH9JtH2XJ8lL64G9vwr21Iuw ip0lLyQtinwV2OskHUn3KdmSLb2YLYoWuJyw0XC0628NKonV+/KwsIIWDhqvB4Id xhHyqpHdsA2+94PxL0qKy6Cmi2+bY6cwjIXfM8HIVwyzQ5Gc6HFemA2N/S9XP5+1 QgI5+S/rKnUofIeXTsi4+qKV2NGpIMwjTitRViD0FRAIOe/temsX0lOLL0aEvQtA nBDiH3RuonMz9/9fiHZ7Q2siSRKxjgupTMEvf3J9BX9P2mFgM0HlSjkojvY7bEmI FXqxp8PPWOCukdjFqMaxfH5siohBFZdr0mLj3kztnBMYHI3970f3itSh0f6Alsdc hhYrPOyBzQWpTqRpFCItoIisaKgZ3EKRP6Y+wl3bt207Dge3UzZjTf4bpDGmGDJr ndjSQkbr/PU+bSmkQVgA =QwSc -----END PGP SIGNATURE----- |
From: Grant G. <gr...@gr...> - 2010-09-28 22:54:37
|
> >Hello, > >The cppcms FAQ suggests that the license may be changed from the current LGPL to > >something more permissive in the future. > Yes, but it is unlikely to happen. Also what would not happen is change of license to less permissive like GPL. I believe that LGPL is better license then licenses like MIT, BSD or Boost. > >I'd like to link cppcms with proprietary software targeting embedded devices. >For practical purposes LGPL is not suitable for embedded usage. > You basically have two choices: 1. Provide an ability to access to the software to upgrade the CppCMS library as LGPL requires: i.e. (a) you should like with shared version of the library (b) you should give an access to change the library for the device 2. Purchase a special license for your particular case, (i.e. dual licensing) > >Are there any plans to change the license to something more permissive in the >near future? > No I don't, however I do have plans for dual licensing of CppCMS exactly for such case. So basically you have two choices: 1. Follow LGPL restrictions. 2. Pay for alternative license. Artyom ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users Hi Artyom, Compliance with the LGPL is not possible as the firmware is fixed (read-only), and we cannot supply the toolchain required to rebuild and deploy a new firmware image to end users. Do you have a model/fee structure for the alternative license? If this license is reasonable for embedded use in consumer electronics I would like to consider it. Regards, Grant. |
From: Daniel V. <chi...@gm...> - 2010-09-28 21:53:53
|
Hello. The following simple code cause segmentation fault with both booster::thread_specific_ptr and boost::thread_specific_ptr versions when a client call "sum" rpc method. I don't know why. I missing something? Thank you. #include <cppcms/application.h> #include <cppcms/service.h> #include <cppcms/applications_pool.h> #include <cppcms/rpc_json.h> #include <booster/thread.h> booster::thread_specific_ptr<int> thread_int; class json_service : public cppcms::rpc::json_rpc_server { public: json_service(cppcms::service &srv) : cppcms::rpc::json_rpc_server(srv) { bind("sum",cppcms::rpc::json_method(&json_service::sum,this),method_role); thread_int.reset(new int(0)); } void sum(int x,int y) { // FIXME: this line cause segmentation fault std::cout << "thread_int = " << (*thread_int) << std::endl; return_result(x+y); } }; int main(int argc, char **argv) { try { cppcms::service srv(argc,argv); srv.applications_pool().mount( cppcms::applications_factory<json_service>()); srv.run(); } catch(std::exception const &e) { std::cerr << e.what() << std::endl; return 1; } return 0; } On Tue, 2010-09-28 at 14:05 -0700, Artyom wrote: > Store it as member of your applications, > application instances are cached. > > You can also use booster::thread_specific_ptr > > See as example wikipp. > Artyom > > P.S.: Soci has connection pool as well. > > > ----- Original Message ---- > > From: Daniel Vallejos <chi...@gm...> > > To: cpp...@li... > > Sent: Tue, September 28, 2010 7:44:14 PM > > Subject: [Cppcms-users] singleton per thread > > > > Hello. > > > > I use soci for database access. > > > > The soci session object is not "thread safe". > > > > AFAIK each cppcms::application object runs in a thread. > > > > Then I need a "singleton per thread" or "thread local storage". > > > > How to accomplish this with cppcms? > > > > I try to use "boost::thread_specific_ptr" with no luck (segmentation > > fault). > > > > > > Thanks. > > > > > > > > > > ------------------------------------------------------------------------------ > > Start uncovering the many advantages of virtual appliances > > and start using them to simplify application deployment and > > accelerate your shift to cloud computing. > > http://p.sf.net/sfu/novell-sfdev2dev > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Daniel V. <chi...@gm...> - 2010-09-28 21:45:22
|
Hello. The following simple code cause segmentation fault with both booster::thread_specific_ptr and boost::thread_specific_ptr versions when a client call "sum" rpc method. I don't know why. I missing something? Thank you. #include <cppcms/application.h> #include <cppcms/service.h> #include <cppcms/applications_pool.h> #include <cppcms/rpc_json.h> #include <booster/thread.h> booster::thread_specific_ptr<int> thread_int; class json_service : public cppcms::rpc::json_rpc_server { public: json_service(cppcms::service &srv) : cppcms::rpc::json_rpc_server(srv) { bind("sum",cppcms::rpc::json_method(&json_service::sum,this),method_role); thread_int.reset(new int(0)); } void sum(int x,int y) { // FIXME: this line cause segmentation fault std::cout << "thread_int = " << (*thread_int) << std::endl; return_result(x+y); } }; int main(int argc, char **argv) { try { cppcms::service srv(argc,argv); srv.applications_pool().mount( cppcms::applications_factory<json_service>()); srv.run(); } catch(std::exception const &e) { std::cerr << e.what() << std::endl; return 1; } return 0; } On Tue, 2010-09-28 at 14:05 -0700, Artyom wrote: > Store it as member of your applications, > application instances are cached. > > You can also use booster::thread_specific_ptr > > See as example wikipp. > Artyom > > P.S.: Soci has connection pool as well. > > > ----- Original Message ---- > > From: Daniel Vallejos <chi...@gm...> > > To: cpp...@li... > > Sent: Tue, September 28, 2010 7:44:14 PM > > Subject: [Cppcms-users] singleton per thread > > > > Hello. > > > > I use soci for database access. > > > > The soci session object is not "thread safe". > > > > AFAIK each cppcms::application object runs in a thread. > > > > Then I need a "singleton per thread" or "thread local storage". > > > > How to accomplish this with cppcms? > > > > I try to use "boost::thread_specific_ptr" with no luck (segmentation > > fault). > > > > > > Thanks. > > > > > > > > > > ------------------------------------------------------------------------------ > > Start uncovering the many advantages of virtual appliances > > and start using them to simplify application deployment and > > accelerate your shift to cloud computing. > > http://p.sf.net/sfu/novell-sfdev2dev > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom <art...@ya...> - 2010-09-28 21:05:45
|
Store it as member of your applications, application instances are cached. You can also use booster::thread_specific_ptr See as example wikipp. Artyom P.S.: Soci has connection pool as well. ----- Original Message ---- > From: Daniel Vallejos <chi...@gm...> > To: cpp...@li... > Sent: Tue, September 28, 2010 7:44:14 PM > Subject: [Cppcms-users] singleton per thread > > Hello. > > I use soci for database access. > > The soci session object is not "thread safe". > > AFAIK each cppcms::application object runs in a thread. > > Then I need a "singleton per thread" or "thread local storage". > > How to accomplish this with cppcms? > > I try to use "boost::thread_specific_ptr" with no luck (segmentation > fault). > > > Thanks. > > > > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Daniel V. <chi...@gm...> - 2010-09-28 17:44:29
|
Hello. I use soci for database access. The soci session object is not "thread safe". AFAIK each cppcms::application object runs in a thread. Then I need a "singleton per thread" or "thread local storage". How to accomplish this with cppcms? I try to use "boost::thread_specific_ptr" with no luck (segmentation fault). Thanks. |