[Cppcms-users] exception about endpoint
Brought to you by:
artyom-beilis
|
From: bruce x. <bru...@gm...> - 2013-01-21 04:03:32
|
Hi, everyone, I set up a web service server using cppcms-1.0.2 some time
ago , outside is nginx, and it went well. A weeks ago, I removed the nginx
when I put the app to another server. And then an exception often
occured. The following is exception and trace :
-- aio::: invalid endpoint
0x7f7dc7acda18: booster::aio::endpoint::throw_invalid() const + 0xe8 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7acdc75: booster::aio::endpoint::raw(sockaddr const*, int) + 0x25 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad948b:
booster::aio::basic_socket::remote_endpoint(booster::system::error_code&) +
0xab in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7f00645:
cppcms::impl::cgi::http::process_request(booster::callback<void
(booster::system::error_code const&)> const&) + 0x3b5 in
PATH_TO_LIBS/libcppcms.so.1
0x7f7dc7f0154b:
cppcms::impl::cgi::http::some_headers_data_read(booster::system::error_code
const&, unsigned long, booster::callback<void (booster::system::error_code
const&)> const&) + 0x32b in PATH_TO_LIBS/libcppcms.so.1
0x7f7dc7ade609: ??? + 0xc7ade609 in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad0c6c: booster::callback<void ()>::callable_impl<void,
booster::aio::event_loop_impl::event_handler_dispatcher>::operator()() +
0x1c in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7ad2176:
booster::aio::event_loop_impl::run_one(booster::aio::reactor::event*,
unsigned long) + 0x106 in PATH_TO_LIBS/libbooster.so.0
0x7f7dc7acf3e8: booster::aio::io_service::run() + 0x78 in
PATH_TO_LIBS/libbooster.so.0
0x7f7dc7e18c85: cppcms::service::run() + 0x65 in PATH_TO_LIBS/libcppcms.so.1
Then I traced the exception in code, and found the function in
booster/lib/aio/src/basic_socket.cpp
86 endpoint basic_socket::remote_endpoint(system::error_code &e)
87 {
88 std::vector<char> endpoint_raw_(1000,0); // apply 1000 bytes
89 sockaddr *sa = reinterpret_cast<sockaddr *>(&endpoint_raw_.front());
90 socklen_t len = endpoint_raw_.size();
91 if(::getpeername(native(),sa,&len) < 0)
92 e=geterror();
93 endpoint ep;
94 ep.raw(sa,len); // An exception thrown
95 return ep;
96 }
in booster/lib/aio/src/endpoint.cpp
228 void endpoint::raw(sockaddr const *p,int size)
229 {
230 if(size > int(sizeof(d->sa))) // sizeof(d->sa) is 256
231 throw_invalid(); //from here
232 d->size=size;
233 memcpy(&d->sa.sa,p,size);
234 }
remote_endpoint doesn't handle this exception. I don't know the reason of
the exception exactly, I doubt that someone makes trouble deliberately.
In getpeername(), when len > 256 && len <= 1000, an exception will be
thrown, normally sockaddr won't be so long.Then I want to modify the source
in remote_endpoint
>>>std::vector<char> endpoint_raw_(1000,0)
<<<std::vector<char> endpoint_raw_(256, 0)
then getpeername will handle the exception and return -1, and geterror()
will run.
It will cause any problem?
--
ZhiXin XIU
Computer Science & Engineering Dept.,
Shanghai Jiao Tong University,
800 Dongchuan Rd., Shanghai,
CHINA
|