GithubHelp home page GithubHelp logo

artyom-beilis / cppcms Goto Github PK

View Code? Open in Web Editor NEW
434.0 55.0 105.0 13.14 MB

CppCMS Framework

License: Other

CMake 1.53% Shell 1.46% Python 4.93% C++ 82.03% C 6.76% JavaScript 0.97% C# 0.62% Java 0.57% PHP 0.85% Makefile 0.01% HTML 0.12% Batchfile 0.04% SWIG 0.10% ASP.NET 0.01%

cppcms's People

Contributors

artyom-beilis avatar luav avatar mtonkik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cppcms's Issues

suggestion: add move operations for cppcms::json::value

Hi,thank you for your amazing library!

We have been using cppcms framework for a restful server lately。
As it is very often for us to dynamically generate JSON object,json::value generation speed is very important. We have add move constructor and move assignment operator for json::value, turns out it speed up about 30-60% in a large JSON object generation.
So, why not add the move operations when the compiler have move operation support?

Thank you again for your brilliant library!

1.2.1 compile error in windows

cppcms\locale_fwd.h(11): fatal error C1083: can not open include file: “cppcms/config.h”: No such file or directory

\booster\cstdint.h(11): fatal error C1083: can not open include file: “booster/build_config.h”: No such file or directory

Looping over a temporary vector leads to error.

Problem

The generated style of the foreach loop is not a good design choice. It breaks when looping over temporaries.

Insights

Let's say we are in this situation:

struct Object {
    std::vector<T> allTs();
};
struct message {
    Object o;
};

And the view is trying something like:

<% foreach t in o.allTs() %>
  <ul>
  <% item %>
    <li><%= t.name() %></li>
  <% end %>
  </ul>
<% end %>

Consider now that the function signature may look like std::string_view T::name() const; and that Object::allTs() is constructing a new std::vector every time it is invoked.

When we look at the C++ Code for the view it looks somewhat like:

for(
            auto t_ptr = (content.o.allTs()).begin(),
                t_ptr_end = (content.o.allTs()).end();
            t_ptr != t_ptr_end;  ++t_ptr) {
    auto& t = *t_ptr;

With this setup t_ptr is a iterator value of a temporary object (which might be already gone) and t_ptr_end is a iterator value of a second temporary object (which might also be gone).
So any call to t is basically broken. So if t.name() now returns a string_view then we can be pretty sure (and that's precisely the problem I currently have) that the viewed memory section is not valid.

Solution

Change the generator to produce code that looks like:

{
  decltype(content.o.allTs()) t_iterable = content.o.allTs();
  // I dropped the if condition for simplicity
  for (auto t_ptr = t_iterable.begin(), t_ptr_end = t_iterable.end(); 
        t_ptr != t_ptr_end; ++t_ptr) {
    auto& t = *t_ptr;
    // Stuff
  }
}

BUT PAY ATTENTION to the use of auto vs decltype. Every auto keyword in this code is the expansion of the CPPCMS_TYPEOF macro. But when you use auto in the case above you may introduce unnecessary copies. That is because auto won't deduce to a reference-type. So if allTs() returnes a std::vector<T>& auto will deduce to std::vector<T> and you will copy the whole vector. decltype on the other hand will deduce to std::vector<T>&.

whether the json object is iterable ?

cppcms::json::value my_object;

my_object["name"]    = "Moshe";
my_object["salary"]  = 1000.0;
my_object["retired"] = false;

for (/* iterate the json object */)
{
  std::cout << "key: " << it.key() << " value: " << it.value() <<std::endl;
}

I just want to get the output like this, do you have any idea to do this ?

key: name value: Moshe
key: salary value: 1000.0
key: retired value: false

I'll apperciate your reply.

Request method PATCH does can not load(context()) to form elements

I'm trying to write Rest APT, that uses PATCH and more another method.
But it can not load(context()) to the cppcms::form. When I change Route form PATCH -> POST, it working successfully.

After read documentations, I heard that now load(context()) only extract data from POST/GET

What should I do to implement full Rest API style?

Twice rendering in main?

I 've test add #include <stdio.h> to hello.cpp file and do a printf and this is result:

Code:

void hello::main(std::string /*url*/)
{
  response().out() <<
  "<html>\n"
  "<body>\n"
  "  <h1>Hello World</h1>\n"
  "</body>\n"
  "</html>\n";
  printf ("Characters: %c %c \n", 'a', 65);
}

Then i open browser once, but result is print twice:
Result:

Characters: a A 
Characters: a A

Is it run twice in code?

cppcms::json crashes

file t.cpp which is compilable and executable:

#include <cppcms/json.h>
#include <iostream>

typedef std::map<std::string,std::string> bts;

int main(int argc,char **argv)
{
	std::map<int,std::pair<cppcms::json::array,bts> > ss;
	for(int i=1;i <= 5;++i){
		auto ret=ss.emplace(std::make_pair(5,std::make_pair(cppcms::json::array(),bts())));
		auto &ps=ret.first->second.first;
		if(ret.second){ //Insert succeeded.
			ps.resize(2);
			ps[0]=cppcms::json::array();
			auto &sp=ps[0].array();
			sp.resize(6);
			sp[0]=std::string("a");
			sp[1]="b";
			sp[2]=true;
			sp[3]=0;
			sp[4]=12;
			//sp[5]=false; //TODO:Why does not crash here?
			ps[1]=cppcms::json::array();
			cppcms::json::array ts;
			ts.push_back(std::string("a"));
			ts.push_back(14);
			cppcms::json::array params;
			for(int j=1;j <= 2;++j){
				cppcms::json::array pi;
				pi.push_back(std::string("c"));
				pi.push_back(1);
				params.push_back(pi);
			}
			if(!params.empty())
				ts.push_back(params);
			ps.push_back(ts);
			sp[5]=false; //TODO:Why crashes here?
		}
		ps[1].array().push_back(cppcms::json::array());
		auto &tb=ps[1].array().back().array();
		tb.resize(8);
		tb[0]=std::string("a");
		tb[1]="a";
		tb[2]=30;
		tb[3]=cppcms::json::null();
		tb[4]="b";
		tb[5]="c";
		tb[6]=cppcms::json::null();
		tb[7]=cppcms::json::null();
	}
	std::cerr << "done" << std::endl;
	return 0;
}

gdb output:

Starting program: /home/u2/tmp/cppcms_json/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.

===backtrack===

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6e1242a in __GI_abort () at abort.c:89
#2  0x00007ffff6e4ec00 in __libc_message (do_abort=do_abort@entry=2, 
    fmt=fmt@entry=0x7ffff6f43d98 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff6e54fc6 in malloc_printerr (action=3, 
    str=0x7ffff6f441a0 "malloc(): memory corruption (fast)", ptr=<optimized out>, 
    ar_ptr=<optimized out>) at malloc.c:5049
#4  0x00007ffff6e57491 in _int_malloc (av=av@entry=0x7ffff7177b00 <main_arena>, 
    bytes=bytes@entry=56) at malloc.c:3424
#5  0x00007ffff6e58f64 in __GI___libc_malloc (bytes=56) at malloc.c:2928
#6  0x00007ffff77277a8 in operator new(unsigned long) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7b01b76 in booster::copy_ptr<cppcms::json::value::_data>::copy_ptr (
    other=..., this=0x5555557724b8)
    at /home/u2/www/resource/src/cppcms/booster/booster/copy_ptr.h:28
#8  cppcms::json::value::copyable::copyable (this=0x5555557724b8, r=...)
    at /home/u2/www/resource/src/cppcms/src/json.cpp:311
#9  0x00007ffff7b01c88 in cppcms::json::value::value (other=..., 
    this=<optimized out>) at /home/u2/www/resource/src/cppcms/cppcms/json.h:515
#10 std::_Construct<cppcms::json::value, cppcms::json::value const&> (
    __p=<optimized out>) at /usr/include/c++/6/bits/stl_construct.h:75
#11 std::__uninitialized_copy<false>::__uninit_copy<__gnu_cxx::__normal_iterator<cppcms::json::value const*, std::vector<cppcms::json::value, std::allocator<cppcms::json::value> > >, cppcms::json::value*> (__result=0x5555557724b0, __last=..., 
    __first=...) at /usr/include/c++/6/bits/stl_uninitialized.h:75
#12 std::uninitialized_copy<__gnu_cxx::__normal_iterator<cppcms::json::value const*, std::vector<cppcms::json::value, std::allocator<cppcms::json::value> > >, cppcms::json::value*> (__result=<optimized out>, __last=..., __first=...)
    at /usr/include/c++/6/bits/stl_uninitialized.h:126
#13 std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<cppcms::json::value const*, std::vector<cppcms::json::value, std::allocator<cppcms::json::value> > >, cppcms::json::value*, cppcms::json::value> (__result=<optimized out>, __last=..., 
    __first=...) at /usr/include/c++/6/bits/stl_uninitialized.h:281
#14 std::vector<cppcms::json::value, std::allocator<cppcms::json::value> >::vector (
    __x=..., this=0x555555771560) at /usr/include/c++/6/bits/stl_vector.h:324
#15 cppcms::json::variant::create (other=..., t=<optimized out>, 
    this=0x555555771560) at /home/u2/www/resource/src/cppcms/src/json.cpp:257
#16 cppcms::json::variant::variant (other=..., this=0x555555771560)
    at /home/u2/www/resource/src/cppcms/src/json.cpp:140
#17 cppcms::json::value::_data::_data (this=0x555555771560)
    at /home/u2/www/resource/src/cppcms/src/json.cpp:286
#18 booster::copy_ptr<cppcms::json::value::_data>::copy_ptr (other=..., 
    this=0x555555771b28)
    at /home/u2/www/resource/src/cppcms/booster/booster/copy_ptr.h:28
#19 cppcms::json::value::copyable::copyable (this=0x555555771b28, r=...)
    at /home/u2/www/resource/src/cppcms/src/json.cpp:311
#20 0x000055555555653d in cppcms::json::value::value (this=0x555555771b28, 
    other=...) at /usr/local/include/cppcms/json.h:515
#21 0x0000555555558bd3 in std::_Construct<cppcms::json::value, cppcms::json::value const&> (__p=0x555555771b28, __args#0=...)
    at /usr/include/c++/6/bits/stl_construct.h:75
#22 0x0000555555559189 in std::__uninitialized_copy<false>::__uninit_copy<cppcms::json::value const*, cppcms::json::value*> (__first=0x555555771c78, 
    __last=0x555555771c80, __result=0x555555771b20)
    at /usr/include/c++/6/bits/stl_uninitialized.h:75
#23 0x0000555555558ec3 in std::uninitialized_copy<cppcms::json::value const*, cppcms::json::value*> (__first=0x555555771c70, __last=0x555555771c80, 
    __result=0x555555771b20) at /usr/include/c++/6/bits/stl_uninitialized.h:126
#24 0x0000555555558aaf in std::__uninitialized_copy_a<cppcms::json::value const*, cppcms::json::value*, cppcms::json::value> (__first=0x555555771c70, 
    __last=0x555555771c80, __result=0x555555771b20)
    at /usr/include/c++/6/bits/stl_uninitialized.h:281
#25 0x0000555555558212 in std::__uninitialized_move_if_noexcept_a<cppcms::json::value*, cppcms::json::value*, std::allocator<cppcms::json::value> > (
    __first=0x555555771c70, __last=0x555555771c80, __result=0x555555771b20, 
    __alloc=...) at /usr/include/c++/6/bits/stl_uninitialized.h:304
#26 0x00005555555583a1 in std::vector<cppcms::json::value, std::allocator<cppcms::json::value> >::_M_emplace_back_aux<cppcms::json::value>(cppcms::json::value&&) (
    this=0x555555772300, 
    __args#0=<unknown type in /home/u2/tmp/cppcms_json/a.out, CU 0x0, DIE 0xee5e>) at /usr/include/c++/6/bits/vector.tcc:420
#27 0x0000555555557723 in std::vector<cppcms::json::value, std::allocator<cppcms::json::value> >::emplace_back<cppcms::json::value>(cppcms::json::value&&) (
    this=0x555555772300, 
    __args#0=<unknown type in /home/u2/tmp/cppcms_json/a.out, CU 0x0, DIE 0xee5e>) at /usr/include/c++/6/bits/vector.tcc:101
#28 0x0000555555556d54 in std::vector<cppcms::json::value, std::allocator<cppcms::json::value> >::push_back(cppcms::json::value&&) (this=0x555555772300, 
    __x=<unknown type in /home/u2/tmp/cppcms_json/a.out, CU 0x0, DIE 0xe953>)
    at /usr/include/c++/6/bits/stl_vector.h:933
#29 0x0000555555555e0a in main (argc=1, argv=0x7fffffffe398) at t.cpp:39

Failing unittest

./test_locale_formatting

Testing char, UTF-8
----[1.31E1]!=
----[1.310E1] in 273
Error in line:273 (ss.str())==(to_correct_string("1.310E1",loc))
----[3:33:13 PM Greenwich Mean Time]!=
----[3:33:13 PM GMT] in 325
Error in line:325 (ss.str())==(to_correct_string("3:33:13 PM GMT",loc))
----[Thursday, February 5, 1970 at 3:33:13 PM Greenwich Mean Time]!=
----[Thursday, February 5, 1970 at 3:33:13 PM GMT] in 366
Error in line:366 (ss.str())==(to_correct_string("Thursday, February 5, 1970" " at" " 3:33:13 PM GMT",loc))
----[Thursday, February 5, 1970 at 3:33:13 PM Greenwich Mean Time]!=
----[Thursday, February 5, 1970 at 3:33:13 PM GMT] in 414
Error in line:414 (ss.str())==(to_correct_string(result[i],loc))
----[Greenwich Mean Time]!=
----[GMT] in 414
Error in line:414 (ss.str())==(to_correct_string(result[i],loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 ((booster::locale::basic_format(fmt) % 13.1).str(loc))==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 ((booster::locale::basic_format(fmt) % 13.1).str(loc))==(to_correct_string("1.310E1",loc))
Testing char, ISO8859-1
----[1.31E1]!=
----[1.310E1] in 273
Error in line:273 (ss.str())==(to_correct_string("1.310E1",loc))
----[3:33:13 PM Greenwich Mean Time]!=
----[3:33:13 PM GMT] in 325
Error in line:325 (ss.str())==(to_correct_string("3:33:13 PM GMT",loc))
----[Thursday, February 5, 1970 at 3:33:13 PM Greenwich Mean Time]!=
----[Thursday, February 5, 1970 at 3:33:13 PM GMT] in 366
Error in line:366 (ss.str())==(to_correct_string("Thursday, February 5, 1970" " at" " 3:33:13 PM GMT",loc))
----[Thursday, February 5, 1970 at 3:33:13 PM Greenwich Mean Time]!=
----[Thursday, February 5, 1970 at 3:33:13 PM GMT] in 414
Error in line:414 (ss.str())==(to_correct_string(result[i],loc))
----[Greenwich Mean Time]!=
----[GMT] in 414
Error in line:414 (ss.str())==(to_correct_string(result[i],loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 448
Error in line:448 ((booster::locale::basic_format(fmt) % 13.1).str(loc))==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 (ss.str())==(to_correct_string("1.310E1",loc))
----[1.31E1]!=
----[1.310E1] in 449
Error in line:449 ((booster::locale::basic_format(fmt) % 13.1).str(loc))==(to_correct_string("1.310E1",loc))
Failed Error limits reached, stopping unit test

OpenSuse 42.3 - test_locale_formatting failed

Hello Artyom,
I've just cloned the master branche. The tests of test_locale_formatting failed.

output

Testing char, UTF-8
TEST_THROW - Error in line:235 ss >> v
TEST_THROW - Error in line:237 ss >> v
TEST_THROW - Error in line:244 ss >> v
TEST_THROW - Error in line:245 ss >> v
TEST_THROW - Error in line:256 ss >> v
TEST_THROW - Error in line:265 ss >> v
TEST_THROW - Error in line:279 ss >> v
TEST_THROW - Error in line:280 ss >> v
TEST_THROW - Error in line:281 ss >> v
TEST_THROW - Error in line:286 ss >> v
TEST_THROW - Error in line:291 ss >> v
TEST_THROW - Error in line:320 ss >> v
TEST_THROW - Error in line:342 ss >> v
Testing char, ISO8859-1
TEST_THROW - Error in line:235 ss >> v
TEST_THROW - Error in line:237 ss >> v
TEST_THROW - Error in line:244 ss >> v
TEST_THROW - Error in line:245 ss >> v
TEST_THROW - Error in line:256 ss >> v
TEST_THROW - Error in line:265 ss >> v
TEST_THROW - Error in line:279 ss >> v
TEST_THROW - Error in line:280 ss >> v
TEST_THROW - Error in line:281 ss >> v
Failed Error limits reached, stopping unit test

The test failed using gcc-4.8 and gcc-7. The error came from the makro TEST_NOPAR and the ABI change.

--- a/booster/lib/locale/test/test_formatting.cpp
+++ b/booster/lib/locale/test/test_formatting.cpp
@@ -118,7 +118,7 @@ do{
ss.str(act);
ss.exceptions(std::ios_base::failbit);
ss >> manip; \

  •    TEST_THROWS(ss >> v,std::ios_base::failure);            \
    
  •    TEST_THROWS(ss >> v,std::exception);                    \
    
    }
    }while(0)

applications_pool_size

Hello.

  1. Can't find applications_pool_size within sources any more. What is the way to manage sync applications pool size (and thread pool size)?
  2. In my typical case I process a request by async app and find out that long-running job is needed, so I want to pass the job (partially done) to different thread to continue processing. Now we have submit_to_asynchronous_application and submit_to_pool now. Whether the only way to link these two parts of code is to pass a key via url (to search for the job in some custom storage)? I suspect that thread_pool could be useful in job-centralized processing, but it's hard to get the way it works in conjunction with applications. As a result: custom queues and custom adjustable thread pools. Please, direct me how to use cppcms natively for such a task.

Failed to read /dev/urandom

Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux

cppcms, http_context.cpp, row 336
*** E [2018-07-18 09:25:26.570] Caught exception [Failed to read /dev/urandom]
0x7f42a85f0c41: booster::runtime_error::runtime_error(std::string const&) + 0x61 in /usr/local/lib/libcppcms.so.1
0x7f42a868bad4: cppcms::urandom_device::generate(void*, unsigned int) + 0xa4 in /usr/local/lib/libcppcms.so.1
...

What could be the problem? It looks like the problem is not exactly related to cppcms..

cppdb: show tables like query arguments not bound

The following:

#include <iostream>
#include <cppdb/frontend.h>

int main() {
        std::string dbcs ="mysql:database=mydb;user=myuser;password=mypassword;@pool_size=10;set_charset_name=utf8";
        auto sql = cppdb::session(dbcs);
        cppdb::result res;
        std::string table("my_table");
        res = sql << "SHOW TABLES LIKE ?" << table;
        res.next();
}

produces:

terminate called after throwing an instance of 'cppdb::mysql_backend::cppdb_myerror'
what(): cppdb::mysql::You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
Aborted

The same code but with a different query (e.g. a SELECT query) can properly bind the arguments, but for some reason, the 'show tables' query above does not work with bound arguments.

Also, could cppdb_myerror output the full query? I checked the cppdb source code and I couldn't see any obvious way to have a more detailed error message being thrown. However, when developing an application, it is sometimes hard to debug code and queries because the exact query which causes to throw is not displayed. Above is a good example of that: the error thrown tell about "the right syntax to use near '?' ", but it does not show the actually query "SHOW TABLES LIKE ?".
How hard would it be for the full query to be thrown together with the error?

Build fails on Ubuntu 16.04 LTS (undefined reference to session_file_storage_factory)

Build fails on Linux Ubuntu 16.04 LTS x64 for the latest master (9fff4f7):

cppcms/build$ cmake -DDISABLE_SCGI=ON -DDISABLE_GZIP=ON ..
$ make

yields the following error:

...
[ 29%] Built target loadable_storage
Scanning dependencies of target cache_frontend_test
[ 29%] Building CXX object CMakeFiles/cache_frontend_test.dir/tests/cache_frontend_test.cpp.o
[ 30%] Linking CXX executable cache_frontend_test
libcppcms.so.1.2.0: undefined reference to `cppcms::sessions::session_file_storage_factory::session_file_storage_factory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, bool)'
collect2: error: ld returned 1 exit status
CMakeFiles/cache_frontend_test.dir/build.make:103: recipe for target 'cache_frontend_test' failed
make[2]: *** [cache_frontend_test] Error 1
CMakeFiles/Makefile2:106: recipe for target 'CMakeFiles/cache_frontend_test.dir/all' failed
make[1]: *** [CMakeFiles/cache_frontend_test.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

The same issue occurs for the release v1.2.0 built with

cppcms-1.2.0/build$ cmake -DDISABLE_GZIP=ON ..

Build Environment:

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
$ cmake --version
cmake version 3.5.1

UDS permissions (feature request)

When using unix sockets to run a service, they are created with default user/group/permissions on the location specified in config.js. It would be nice to have some possibility to setup the permissions in the config.js, so that e.g. the service may be started as a user, but still allow to communicate with, say, nginx server using a socket with permissions for some common group.

Some ugly proof of concept to show what I mean (config.js contains "user" "group" "perms" in the "service" section along with socket):

diff --git a/src/service.cpp b/src/service.cpp
index 8124ec4..6d81831 100644
--- a/src/service.cpp
+++ b/src/service.cpp
@@ -90,6 +90,11 @@
 #include <booster/aio/buffer.h>
 #include <booster/aio/reactor.h>

+
+
+#include <unistd.h>
+#include <sstream>
+
 namespace cppcms {

 service::service(json::value const &v) :
@@ -823,8 +828,23 @@ std::auto_ptr<cppcms::impl::cgi::acceptor> service::setup_acceptor(json::value c
    if(api=="fastcgi") {
      if(socket=="stdin")
        a = fastcgi_api_unix_socket_factory(*this,backlog);
-     else
+     else {
        a = fastcgi_api_unix_socket_factory(*this,socket,backlog);
+        // PATCH
+        std::string sock = settings()["service"]["socket"].str();
+        std::string user = settings()["service"]["user"].str();
+        std::string group = settings()["service"]["group"].str();
+        std::string perms = settings()["service"]["perms"].str();
+        
+        std::stringstream ss;
+        ss << "chown "<<user<<":"<<group<<"  "<<sock;
+        system(ss.str().data());
+        ss.str("");
+        ss << "chmod "<<perms<<" "<<sock;
+        system(ss.str().data());
+        // END PATCH
+      }
+      
    }
    #endif

PS: Thanks for a nice project.

Deprecated warning

/tmp/cppcms-1.1.0/src/aes.cpp:103:4: warning: 'gcry_thread_cbs' is deprecated [-Wdeprecated-declarations]
GCRY_THREAD_OPTION_PTHREAD_IMPL;

/usr/include/gcrypt.h:225:17: note: expanded from macro 'GCRY_THREAD_OPTION_PTHREAD_IMPL'
static struct gcry_thread_cbs gcry_threads_pthread = { \

/usr/include/gcrypt.h:211:8: note: 'gcry_thread_cbs' has been explicitly marked deprecated here
struct gcry_thread_cbs

1 warning generated.

Can't use dispatcher url

I'm trying to make an dispatcher like this but it does not work when build:

dispatcher().assign("/", &app::http::controllers::HomeController::index);

Logs:

In file included from /usr/local/include/booster/locale/gnu_gettext.h:12:0,
                 from /usr/local/include/booster/locale.h:20,
                 from /usr/local/include/cppcms/localization.h:12,
                 from /usr/local/include/cppcms/filters.h:20,
                 from /usr/local/include/cppcms/url_mapper.h:15,
                 from /home/darkhades/GitHub/web/routes/web.cpp:1:
/usr/local/include/booster/function.h: In instantiation of ‘void booster::function<Result()>::callable_impl<void, F>::call() [with F = void (app::http::controllers::HomeController::*)(const std::__cxx11::basic_string<char>&); Result = void]’:
/home/darkhades/GitHub/web/routes/web.cpp:32:1:   required from here
/usr/local/include/booster/function.h:168:2: error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((booster::function<void()>::callable_impl<void, void (app::http::controllers::HomeController::*)(const std::__cxx11::basic_string<char>&)>*)this)->booster::function<void()>::callable_impl<void, void (app::http::controllers::HomeController::*)(const std::__cxx11::basic_string<char>&)>::func (...)’, e.g. ‘(... ->* ((booster::function<void()>::callable_impl<void, void (app::http::controllers::HomeController::*)(const std::__cxx11::basic_string<char>&)>*)this)->booster::function<void()>::callable_impl<void, void (app::http::controllers::HomeController::*)(const std::__cxx11::basic_string<char>&)>::func) (...)’
  BOOSTER_FUNCTION
  ^

What is the recommanded way of testing a cppcms::application?

Hello,

I have a REST server implemented as a cppcms::application.
I would like to add some tests for it. I don't really want to do a network request, but only set the application context, call the main method and check the response. Is it possible? What would you recommand?

What I have tried so far:

  1. Create a new cppcms::service.
  2. Create a new cppcms::application <-- my REST server
  3. Call application.main("url_path")
  4. Check application.response()

Between 2) and 3) I probably need to call cppcms::application::assign_context(). But there is no way to create one as its constructor depends on impl::cgi::connection.

cppcms_tmpl_cc gives traceback issue

I am following this tutorial. The project was built successfully up to the end of Static Linking.

Then I want to make a custom makefile to use it with Eclipse CDT. After much tinkering makefile and many build cycles, cppcms_tmpl_cc gives me a traceback issue as follow:

$cppcms_tmpl_cc my_skin.tmpl -o my_skin.cpp
Traceback (most recent call last):
  File "/usr/local/bin/cppcms_tmpl_cc", line 1257, in <module>
    main()
  File "/usr/local/bin/cppcms_tmpl_cc", line 1160, in main
    output_fd=open(output_file,"w")
IOError: [Errno 2] No such file or directory: 'my_skin.cpp'

Does anyone have a way to fix this? I plan to rebuild CppCMS as no solution has been found.

cppdb and JSON data type

MySQL 5.7 introduced a new JSON data type.
cppcms also has a JSON class.

The cppdb documentation apparently says nothing about supporting JSON. Can we use operator>> and operator<< with a cppcms::json object to directly get or save JSON data into a MySQL JSON field?

If not, what would be required to get cppdb to conveniently bind MySQL JSON data to a cppcms JSON object?

Synchronous applications being deleted during heavy load

During heavy loads (ie DDOS, brute force password attempts), it is common to see constructors and destructors of my application being called rapidly.

This has the side effect of abruptly terminating existing requests which are still running.

I've looked at the application_pool.cpp file and the policies seem to imply that delete app should never be called?

I am using cppcms 1.04

what is Number of concurrent of cppcms

i use cppcms version 1.2.1 on windows as a web application, test http post max concurrent number.
after the server receive a request , then post request to the threadpool , the workthread fetch the request and send reponse to client .
i use the third http client tool "ab" test the concurrent number of all request and response, the max number is about 4000 per second.
how to use cppcms to achieve larger concurrent number? is there a example?

Load json::value from file

I have a manifest.json file like this:

{
  "js/app.js": "js/app.112sf342isw1.js"
}

I'm trying to read it by ostream in cppcms::json::value but it not work:

const std::string urlPath = "js/app.js";
std::ifstream f("manifest.json");
cppcms::json::value v;
v.load(f);
std::cout << v[urlPath].str() << std::endl; // It throw exception not found the key
std::cout << v.at(urlPath).str() << std::endl; // also not found exception

I think the json file has a . in key string, so it can not parse correctly. But i don't know how to solve this issue.

Error build view.cpp in Mac

In Ubuntu 16.04, it built correctly, but in Mac it show error like this:

Undefined symbols for architecture x86_64:
  "cppcms::url_mapper::map(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*)", referenced from:
      bootstrap_skin::layouts_app_dashboard::wrapper_content() in view.cpp.o
  .........
typeinfo for app::core::View in view.cpp.o
  "typeinfo for cppcms::base_view", referenced from:
      typeinfo for bootstrap_skin::layouts_app in view.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My view code:

<% c++ #include "app/views/layouts/app/dashboard.h" %>                              
<% skin bootstrap_skin %>                                                           
<% view layouts_app_dashboard uses views::layouts::app::Dashboard extends layouts_app %>
<% template dashboard_js() %><% end %>                                              
<% template dashboard_css() %><% end %>                                             
<% template css() %>                                                                
  <link rel="stylesheet" href="<%= asset("bootstrap/css/bootstrap.min.css") %>" />
  <% include dashboard_css() %>                                                     
<% end %>                                                                           
<% template js() %>                                                                 
  <script type="text/javascript" src="<%= asset("js/jquery-3.2.1.min.js") %>"></script>
  <script type="text/javascript" src="<%= asset("tether/js/tether.min.js") %>"></script>
  <script type="text/javascript" src="<%= asset("bootstrap/js/bootstrap.min.js") %>"></script>
  <% include dashboard_js() %>                                                      
<% end %>                                                                           
<% template layouts_dashboard_content() %><% end %>                                 
<% template wrapper_content() %>                                                    
  <nav class="navbar navbar-inverse bg-inverse">                                    
    <div class="container text-right">                                              
    ¦ <a class="btn btn-sm align-middle btn-primary" href="<% url "login" %>">Đăng nhập</a>
    ¦ <a class="btn btn-sm align-middle btn-success" href="<% url "register" %>">Đăng kí</a>
    </div>                                                                          
  </nav>                                                                            
  <% include layouts_dashboard_content() %>                                         
                                                                                    
<% end template %>                                                                  
<% end view %>                                                                      
<% end skin %>  

Problem to customize a form

My form is ok with:
<form class="form-signin" method="post" action="" ><% csrf %> <% form as_p mydata %> </form>
But when I try:
<form class="form-signin" method="post" action="" ><% csrf %> <input type="email" name="<%= mydata.email()%>" > ... </form>

I get a compile error.
Is ther an exmple of this case in the documentation ? I have found none. What am I missing ?
Thank you for cppcms.
PC

booster::regex_search usage

I am trying to catch the first occurrence of characters between two slashes /. booster::regex_search yields correct result from the short string but wrong result from the long string as shown in the following code.

#include <booster/regex.h>
#include <fstream>
const char *s[]=
{
	"/a/b/c/d"
	,"/w/x/y/z/se1BoTdXG8sdR-G3or8wTOVpO2kRwNWkaG5yauoIeHqv_otH9D00i1xILrrG7lEl9HVMKA"
};
int main()
{
	std::ofstream of("/tmp/log",std::ios_base::out);
	booster::smatch match_result;
	for(int i=0;i <= 1;++i){
		if(booster::regex_search(std::string(s[i]),match_result,booster::regex("/([^/]+)"))){
			for(int j=0;j <match_result.size();++j)
				of << "|" << match_result[j].str() << "|" << std::endl;
		}
	}
	of.close();
	return 0;
}

output (the 0's denote occurrences of binary zero, \0):

|/a|
|a|
|00|
|0|

Building a multi-layered page with CppCMS

I am trying to build a multi-layered CppCMS page. I use the render() command along with the POST event from a click on a cppcms::widgets::submit object on each page. This is giving me lots of errors and I do not know how to fix them. How exactly do you do URL dispatching with a click on any cppcms::widgets::submit object? Thanks.

`cache_frontend_test` build fails on `-DDISABLE_GZIP=ON`

cppcms/build$ cmake -DDISABLE_SCGI=ON -DDISABLE_GZIP=ON ..
$ make

yields the following error:

...
[ 28%] Linking CXX shared library libloadable_storage.so
[ 28%] Built target loadable_storage
[ 28%] Linking CXX executable cache_frontend_test
libcppcms.so.1.2.0: undefined reference to `crc32'
collect2: error: ld returned 1 exit status
CMakeFiles/cache_frontend_test.dir/build.make:103: recipe for target 'cache_frontend_test' failed
make[2]: *** [cache_frontend_test] Error 1
CMakeFiles/Makefile2:106: recipe for target 'CMakeFiles/cache_frontend_test.dir/all' failed
make[1]: *** [CMakeFiles/cache_frontend_test.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

crc32() is defined in libz, which makes sense to replace with the statically linked hashing.
For example, xxHash could be statically linked (it has BSD license, which is almost the same as MIT) to avoid dependency of libz (crc32) producing fast cross-platform hashing of significantly better quality than crc32.

filter_test fails in Debian 8 BeagleBone

However it works in Debian 8 x64 (both updated the same day). It's the only test that fails.

From log:
19/104 Test: filter_test
Command: "/mnt/cppcms_git/build/filter_test" "-c" "/mnt/cppcms_git/tests/filter_test.js" "--test-exec=/usr/bin/python2 /mnt
/cppcms_git/tests/filter_test.py"
Directory: /mnt/cppcms_git/build
"filter_test" start time: Jul 03 16:08 UTC
Output:

FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
GET /upload/no_content
Got {'status': 200, 'no_content': 1, 'is_html': False}
POST /upload?l_1=10&f_1=a&l_2=20&f_2=t
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 0, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=10&f_1=a&l_2=20&f_2=t&chunks=5
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 9, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=10000&f_1=a&l_2=20000&f_2=t
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 3, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=0&setbuf=10&at=1
Got {'status': 501, 'content': '\r\n\r\n

501 Not Implemented

\r\n\r\n\r\n', 'is_html': True}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=1&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=2&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=3&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=0&setbuf=10&at=1
Got {'status': 502, 'content': '\r\n\r\n

502 Bad Gateway

\r\n\r\n\r\n', 'is_html': True}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=1&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=2&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=3&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_upload_progress&how=0&setbuf=10&at=1
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 5, 'on_new_file': 1, 'on_data_ready': 1, 'post': 0, 'total': 1, 'files': 1}
Traceback (most recent call last):
File "/mnt/cppcms_git/tests/filter_test.py", line 262, in
test_upload()
File "/mnt/cppcms_git/tests/filter_test.py", line 180, in test_upload
test(r['status']==code)
File "/mnt/cppcms_git/tests/filter_test.py", line 16, in test
raise RuntimeError("Failed")
RuntimeError: Failed
FAILED

Test time = 3.48 sec

From manual run:

/mnt/cppcms_git/build/filter_test -c /mnt/cppcms_git/tests/filter_test.js --test-exec="/usr/bin/python2 /mnt/cppcms_git/tests/filter_test.py"

GET /upload/no_content
Got {'status': 200, 'no_content': 1, 'is_html': False}
POST /upload?l_1=10&f_1=a&l_2=20&f_2=t
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 0, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=10&f_1=a&l_2=20&f_2=t&chunks=5
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 9, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=10000&f_1=a&l_2=20000&f_2=t
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 3, 'on_new_file': 2, 'on_data_ready': 2, 'post': 0, 'total': 2, 'files': 2}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=0&setbuf=10&at=1
Got {'status': 501, 'content': '\r\n\r\n

501 Not Implemented

\r\n\r\n\r\n', 'is_html': True}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=1&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=2&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_headers_ready&how=3&setbuf=10&at=1
Got {'status': 501, 'at': 'on_headers_ready', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=0&setbuf=10&at=1
Got {'status': 502, 'content': '\r\n\r\n

502 Bad Gateway

\r\n\r\n\r\n', 'is_html': True}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=1&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=2&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_new_file&how=3&setbuf=10&at=1
Got {'status': 502, 'at': 'on_new_file', 'is_html': False}
POST /upload?l_1=50&f_1=a&abort=on_upload_progress&how=0&setbuf=10&at=1
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
FAIL: size_t(input_file.size()) << ref.size() in line: 115
Got {'status': 200, 'on_end_of_content': 1, 'is_html': False, 'on_upload_progress': 5, 'on_new_file': 1, 'on_data_ready': 1, 'post': 0, 'total': 1, 'files': 1}
Traceback (most recent call last):
File "/mnt/cppcms_git/tests/filter_test.py", line 262, in
test_upload()
File "/mnt/cppcms_git/tests/filter_test.py", line 180, in test_upload
test(r['status']==code)
File "/mnt/cppcms_git/tests/filter_test.py", line 16, in test
raise RuntimeError("Failed")
RuntimeError: Failed
FAILED

Environment:

cat /etc/issue

Debian GNU/Linux 8 \n \l

BeagleBoard.org Debian Image 2016-12-09

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

The IP Address for eth0 is: 192.168.3.104
The IP Address for usb0 is: 192.168.7.2

uname -a

Linux bbb-0 4.4.36-ti-r72 #1 SMP Wed Dec 7 22:29:53 UTC 2016 armv7l GNU/Linux

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10)

test_aio_socket fails (clang-3.9, BeagleBoneBlack)

Built libraries under BBB and only one test failed: test_aio_socket. However, I tested a program I have that uses aio sockets and seems to work fine. Please see LastLog output and compilation environment in bug_report.txt. You have the full make; make test; make install output in compilation.txt
Best regards,
fquindos

bug_report.txt
compilation.txt

upstream sent unsupported FastCGI protocol version: 6 while reading upstream

Unable to send big response (~223kb) from cppcms via fastcgi to nginx
cppcms: cppcms, warning: Failed to write response:system: Connection reset by peer (http_response.cpp:305)
NGINX (1.8.1): upstream sent unsupported FastCGI protocol version: 6 while reading upstream

Changing nginx buffers does not help.

the code flow is about this:

cln_job->http_context->response().out() << body;
cln_job->http_context->async_flush_output(
                        bind(&dispatcher_app::flush_output_handler,
                             booster::intrusive_ptr<dispatcher_app>(this),
                             std::placeholders::_1,
                             cln_job));

Inside flush_output_handler() i do

    job->http_context->async_complete_response();
    job->http_context.reset();

immediately. It looks like the problem is here, but i can't find info on how to process big response.

feature: datagram_socket in booster::aio

It would be nice to see class datagram_socket, similar to stream_socket, be implemented in booster::aio.

If it is too simple to implement, a tutorial will be very good, too.

404 error for media/style.css

In the messageboard example, the css file style.css is not being read. Any suggestions? I tried placing the media folder in multiple places, but that didnt work too. Keep getting a 404 error for localhost:8080/media/style.css

translating links

In my template I had this:
Hello <a href="<% url "/user" using userId %>"><%= userId %></a>

Now, when adding translations I wanted to do something like this:
<% gt "Hello <a href=\"{1}\">{2}</a>" using ( url "/user" using userId ), userId %>
but it seems, that's impossible.

What is the proper way of handling such situations? Adding new field to the data with generated url? Translating just "Hello" is an option, but it won't work for longer texts.

Program produces 100% CPU load on one core

Hi.
I started working on a new web project and decided to check out this framework.
I have to say: It's is really nice. I like it a lot.

But here's the thing: When I start the application on my laptop everything works fine.
My process explorer says that the application is sleeping and using less than 1 MiB of RAM.
Then I load the first page => Process wakes up allocates RAM, does its thing and goes back to sleep. So far so good.
But then it randomly decides, that now is the time to do some work. The CPU usage climbs to 12% (which is 1 core on full power on an octacore system) and stays there. I have no idea what the program is doing.

Where do I start to debug?

Thanks in advance.
Martin

(P.S. I'm on Debian 9.2)

Tests fail on Lubuntu 16.04

Following is the excerpt from test:

The following tests FAILED:
	  5 - storage_test (Failed)
	 22 - status_test (Failed)
	 23 - pool_test (Failed)
	 24 - filter_test (Failed)
	 25 - async_status_test (Failed)
	 26 - form_test (Failed)
	 27 - cookie_test (Failed)
	 28 - internal_forwarder_test (Failed)
	 29 - forwarder_test (Failed)
	 30 - jsonrpc_test (Failed)
	 31 - http_timeouts_test_read (Failed)
	 32 - http_timeouts_test_write (Failed)
	 33 - file_server_test (Failed)
	 34 - file_server_test_no_links (Failed)
	 35 - file_server_with_listing_test (Failed)
	 36 - file_server_test_async (Failed)
	 37 - file_server_test_no_links_async (Failed)
	 38 - file_server_with_listing_test_async (Failed)
	 39 - disco_test_http (Failed)
	 40 - disco_test_fastcgi_tcp (Failed)
	 41 - disco_test_scgi_tcp (Failed)
	 42 - secure_post_test (Failed)
	 45 - gzip_test (Failed)
	 47 - cppcms_service_test (Failed)
	 49 - session_interface_test_client_renew (Failed)
	 50 - session_interface_test_client_browser (Failed)
	 51 - session_interface_test_client_fixed (Failed)
	 52 - session_interface_test_server_renew (Failed)
	 53 - session_interface_test_server_browser (Failed)
	 54 - session_interface_test_server_fixed (Failed)
	 55 - session_interface_test_both_renew (Failed)
	 56 - session_interface_test_both_browser (Failed)
	 57 - session_interface_test_both_fixed (Failed)
	 58 - proto_test_async_http (Failed)
	 59 - proto_test_async_scgi (Failed)
	 60 - proto_test_async_fastcgi (Failed)
	 63 - proto_test_sync_http (Failed)
	 64 - proto_test_sync_scgi (Failed)
	 65 - proto_test_sync_fastcgi (Failed)
	 68 - proto_test_nonblocking_http (Failed)
	 69 - proto_test_nonblocking_scgi (Failed)
	 70 - proto_test_nonblocking_fastcgi (Failed)
	 73 - loadable_storage_pass (Failed)
	 90 - test_aio_socket (Failed)
	 91 - test_aio_endpoint (Failed)
	 93 - test_aio_prefork (Failed)
Errors while running CTest

GCC is 5.4.0 the stock compiler and libraries are all default libraries.

How to update/upgrade app while runtime

Some time I want to edit a code in cpp file, but website is running, in PHP or NodeJS, it so easy to edit at localhost then test, then i can push to github and pull in from server and don't need reset server or turn app to "In construction" status.
How to do it in CppCMS?

valgrind: Conditional jump or move depends on uninitialised value(s)

I was testing my application with valgrind, trying to clean up warnings.
I was able to reproduce one of those in the example code distributed with cppcms:

After making the example in examples/form:
~/cppcms/examples/forms/ $ colour-valgrind ./hello -c config.js

Just after starting up, there are a few warnings:
Use of uninitialised value of size 8

And after hitting http://127.0.0.1:8080/hello , the warning that I was trying to debug appears:

==13668== Conditional jump or move depends on uninitialised value(s)
==13668==    at 0x52927D8: char const* booster::locale::gnu_gettext::runtime_conversion<char>(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (message.cpp:474)
==13668==    by 0x4F4294D: write (message.h:470)
==13668==    by 0x4F4294D: booster::locale::basic_message<char>::write(std::ostream&) const (message.h:415)
==13668==    by 0x4F471D9: cppcms::filters::escape::operator() (filters.cpp:188)
==13668==    by 0x4F3D018: operator<< (filters.h:262)
==13668==    by 0x4F3D018: cppcms::widgets::submit::render_value(cppcms::form_context&) (form.cpp:1369)
==13668==    by 0x4F3F16F: cppcms::widgets::base_widget::render(cppcms::form_context&) (form.cpp:506)
==13668==    by 0x4F35FEF: cppcms::form::render(cppcms::form_context&) (form.cpp:126)
==13668==    by 0x408D02: view::message::render() (in /home/overshoot/git/cpp/cppcms/examples/forms/hello)
==13668==    by 0x4F1A34E: cppcms::views::pool::render(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::ostream&, cppcms::base_content&) (views_pool.cpp:190)
==13668==    by 0x4F1A718: cppcms::views::manager::render(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::ostream&, cppcms::base_content&) (views_pool.cpp:427)
==13668==    by 0x4EF9490: cppcms::application::render(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, cppcms::base_content&) (application.cpp:252)
==13668==    by 0x40603B: hello::main(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/overshoot/git/cpp/cppcms/examples/forms/hello)
==13668==    by 0x4EF1394: cppcms::http::context::dispatch(booster::intrusive_ptr<cppcms::application> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) (http_context.cpp:363)

Some tests failed

Some tests failed

System: Windows 7 x64
System charset: GB2312
Platform: MSYS2 MinGW x64
Compiler: g++ 8.2.1
Dependencies: cmake-3.12.4, zlib-1.2.11, pcre-8.42, python-2.7.15
Region: China


The following tests FAILED:
93 - test_locale_boundary (Failed)
94 - test_locale_formatting (Failed)
Errors while running CTest
mingw32-make: *** [Makefile:106: test] Error 8


# ./test_locale_formatting
Testing char, UTF-8
Error in line:296 (ss.str())==(to_correct_string("USD1,345.00",loc))
Error in line:297 (ss.str())==(to_correct_string("USD1,345.34",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 ((booster::locale::basic_format(fmt) % 1234).str(loc))==(to_correct_string("USD1,234.00",loc))
Testing char, ISO8859-1
Error in line:296 (ss.str())==(to_correct_string("USD1,345.00",loc))
Error in line:297 (ss.str())==(to_correct_string("USD1,345.34",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 ((booster::locale::basic_format(fmt) % 1234).str(loc))==(to_correct_string("USD1,234.00",loc))
Testing wchar_t
Error in line:296 (ss.str())==(to_correct_string("USD1,345.00",loc))
Error in line:297 (ss.str())==(to_correct_string("USD1,345.34",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 (ss.str())==(to_correct_string("USD1,234.00",loc))
Error in line:480 ((booster::locale::basic_format(fmt) % 1234).str(loc))==(to_correct_string("USD1,234.00",loc))

Passed 1218 tests
Failed 15 tests
98.8% of tests completed sucsessefully

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.