Re: [Cppcms-users] exception about endpoint
Brought to you by:
artyom-beilis
|
From: bruce x. <bru...@gm...> - 2013-01-29 02:06:11
|
The problem doesn't reproduce so far. I think that it have been solved~ Thanks 2013/1/28 Artyom Beilis <art...@ya...> > Had it solved the problem? > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > > ------------------------------ > *From:* bruce xiu <bru...@gm...> > *To:* Artyom Beilis <art...@ya...>; > cpp...@li... > *Sent:* Monday, January 21, 2013 10:10 AM > *Subject:* Re: [Cppcms-users] exception about endpoint > > Thanks, > I don't known when the exception will reproduce. I'll fix it and rebuild > cppcms. No matter if the exception reproduces, I will tell you~ > > 2013/1/21 Artyom Beilis <art...@ya...> > > Ok, > > > this is incorrect code: > > > 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 } > > > > It should be > > > endpoint basic_socket::remote_endpoint(system::error_code &e) > { > std::vector<char> endpoint_raw_(1000,0); // apply 1000 bytes > sockaddr *sa = reinterpret_cast<sockaddr *>(&endpoint_raw_.front()); > socklen_t len = endpoint_raw_.size(); > endpoint ep; > if(::getpeername(native(),sa,&len) < 0) { > e=geterror(); > return ep; > } > ep.raw(sa,len); // An exception thrown > return ep; > } > > Can you please check if it helps? > > > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > > ------------------------------ > *From:* bruce xiu <bru...@gm...> > *To:* cpp...@li... > *Sent:* Monday, January 21, 2013 6:03 AM > *Subject:* [Cppcms-users] exception about endpoint > > 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: cpp > cms::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 > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET <http://asp.net/>, C# > 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122412 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET <http://asp.net/>, C# > 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122412 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > -- > ZhiXin XIU > > Computer Science & Engineering Dept., > Shanghai Jiao Tong University, > 800 Dongchuan Rd., Shanghai, > CHINA > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122412 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnnow-d2d > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > -- ZhiXin XIU Computer Science & Engineering Dept., Shanghai Jiao Tong University, 800 Dongchuan Rd., Shanghai, CHINA |