diff options
author | Eric Milkie <milkie@10gen.com> | 2012-02-09 14:58:55 -0500 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2012-02-09 14:58:55 -0500 |
commit | 0ada9757bd3b79c19e1d643e53c91be6f5fe2cc0 (patch) | |
tree | a02c4344b2cdbaaf5209b1900362615a14a22ef0 /src | |
parent | 0aaf41a410c1b257309dc20be058d1c8a8e33d57 (diff) | |
download | mongo-0ada9757bd3b79c19e1d643e53c91be6f5fe2cc0.tar.gz |
SERVER-4866 include the webserver in our attempt to prevent socket leaks
This fixes httpClientTest
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/util/net/miniwebserver.cpp | 16 | ||||
-rw-r--r-- | src/mongo/util/net/miniwebserver.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp index f0b58569d22..5c5d9daf471 100644 --- a/src/mongo/util/net/miniwebserver.cpp +++ b/src/mongo/util/net/miniwebserver.cpp @@ -108,18 +108,18 @@ namespace mongo { return false; } - void MiniWebServer::accepted(Socket sock) { - sock.postFork(); - sock.setTimeout(8); + void MiniWebServer::accepted(boost::shared_ptr<Socket> psock) { + psock->postFork(); + psock->setTimeout(8); char buf[4096]; int len = 0; while ( 1 ) { int left = sizeof(buf) - 1 - len; if( left == 0 ) break; - int x = sock.unsafe_recv( buf + len , left ); + int x = psock->unsafe_recv( buf + len , left ); if ( x <= 0 ) { - sock.close(); + psock->close(); return; } len += x; @@ -135,7 +135,7 @@ namespace mongo { vector<string> headers; try { - doRequest(buf, parseURL( buf ), responseMsg, responseCode, headers, sock.remoteAddr() ); + doRequest(buf, parseURL( buf ), responseMsg, responseCode, headers, psock->remoteAddr() ); } catch ( std::exception& e ) { responseCode = 500; @@ -167,8 +167,8 @@ namespace mongo { string response = ss.str(); try { - sock.send( response.c_str(), response.size() , "http response" ); - sock.close(); + psock->send( response.c_str(), response.size() , "http response" ); + psock->close(); } catch ( SocketException& e ) { log(1) << "couldn't send data to http client: " << e << endl; diff --git a/src/mongo/util/net/miniwebserver.h b/src/mongo/util/net/miniwebserver.h index 1fb6b3f2e65..2067fe2c0d4 100644 --- a/src/mongo/util/net/miniwebserver.h +++ b/src/mongo/util/net/miniwebserver.h @@ -53,7 +53,7 @@ namespace mongo { static string urlDecode(string s) {return urlDecode(s.c_str());} private: - void accepted(Socket socket); + void accepted(boost::shared_ptr<Socket> psocket); static bool fullReceive( const char *buf ); }; |