146 |
return 0; |
return 0; |
147 |
} |
} |
148 |
|
|
149 |
if (req->range_stop > MAX_FILE_MMAP) { |
if (req->range_stop > max_file_size_cache) { |
150 |
|
|
151 |
if ( req->range_start == 0 && req->range_stop == statbuf.st_size) |
if ( req->range_start == 0 && req->range_stop == statbuf.st_size) |
152 |
send_r_request_ok(req); /* All's well */ |
send_r_request_ok(req); /* All's well */ |
183 |
* and stopping there -- all to avoid the cost |
* and stopping there -- all to avoid the cost |
184 |
* of a mmap. Oddly, it was *slower* in benchmarks. |
* of a mmap. Oddly, it was *slower* in benchmarks. |
185 |
*/ |
*/ |
186 |
#ifdef USE_MMAP_LIST |
if (max_files_cache > 0) { |
187 |
req->mmap_entry_var = find_mmap(data_fd, &statbuf); |
req->mmap_entry_var = find_mmap(data_fd, &statbuf); |
188 |
if (req->mmap_entry_var == NULL) { |
if (req->mmap_entry_var == NULL) { |
189 |
req->buffer_end = 0; |
req->buffer_end = 0; |
190 |
if (errno == ENOENT) |
if (errno == ENOENT) |
191 |
send_r_not_found(req); |
send_r_not_found(req); |
192 |
else if (errno == EACCES) |
else if (errno == EACCES) |
193 |
send_r_forbidden(req); |
send_r_forbidden(req); |
194 |
else |
else |
195 |
send_r_bad_request(req); |
send_r_bad_request(req); |
196 |
close(data_fd); |
close(data_fd); |
197 |
return 0; |
return 0; |
198 |
|
} |
199 |
|
req->data_mem = req->mmap_entry_var->mmap; |
200 |
|
} else { /* File caching is disabled. |
201 |
|
*/ |
202 |
|
req->data_mem = mmap(0, req->range_stop, PROT_READ, MAP_OPTIONS, data_fd, 0); |
203 |
} |
} |
204 |
req->data_mem = req->mmap_entry_var->mmap; |
|
|
#else |
|
|
req->data_mem = mmap(0, req->range_stop, PROT_READ, MAP_OPTIONS, data_fd, 0); |
|
|
#endif |
|
205 |
close(data_fd); /* close data file */ |
close(data_fd); /* close data file */ |
206 |
|
|
207 |
if ( req->data_mem == MAP_FAILED) { |
if ( req->data_mem == MAP_FAILED) { |