Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb176285

Browse files
committed
Fixing some rookie logic bugs. Fully functional fileserver example here!
1 parent7f21db4 commitb176285

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎libs/network/example/http/fileserver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ struct file_cache {
4545

4646
booladd(std::stringconst & path) {
4747
boost::upgrade_lock<boost::shared_mutex>lock(cache_mutex);
48-
if (regions.find(doc_root_ + path) != regions.end())returntrue;
4948
std::string real_filename = doc_root_+path;
49+
if (regions.find(real_filename) != regions.end())returntrue;
5050
int fd =open(real_filename.c_str(), O_RDONLY|O_NOATIME|O_NONBLOCK);
5151
if (fd == -1)returnfalse;
5252
std::size_t size =lseek(fd,0, SEEK_END);
@@ -91,8 +91,8 @@ struct connection_handler : boost::enable_shared_from_this<connection_handler> {
9191
: file_cache_(cache) {}
9292

9393
voidoperator()(std::stringconst & path, server::connection_ptr connection,bool serve_body) {
94-
bool ok =false;
95-
if (!file_cache_.has(path)) ok = file_cache_.add(path);
94+
bool ok =file_cache_.has(path);
95+
if (!ok) ok = file_cache_.add(path);
9696
if (ok) {
9797
send_headers(file_cache_.meta(path), connection);
9898
if (serve_body)send_file(file_cache_.get(path),0, connection);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp