Overview
Comment: | Updated to ignore SIGPIPE and made several Range handling improvements |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f27754658d52ebf923b3e5ca8ed92395 |
User & Date: | rkeene on 2014-02-06 06:02:39 |
Other Links: | manifest | tags |
Context
2014-02-06
| ||
06:47 | Updated to keep track of sent bytes check-in: 5d3ae25128 user: rkeene tags: trunk | |
06:02 | Updated to ignore SIGPIPE and made several Range handling improvements check-in: f27754658d user: rkeene tags: trunk | |
04:15 | Added range support check-in: 409fc328b7 user: rkeene tags: trunk | |
Changes
Modified filed.c from [460b9a234e] to [5e37a15236].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | + | #include <sys/sendfile.h> #include <sys/socket.h> #include <sys/types.h> #include <arpa/inet.h> #include <sys/mman.h> #include <sys/stat.h> #include <pthread.h> #include <strings.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <stdio.h> #include <time.h> |
︙ | |||
41 42 43 44 45 46 47 | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | + + + + - - + + + + | /** Buffers **/ struct filed_fileinfo fileinfo; char path_b[1010]; char tmpbuf[1010]; /** HTTP Request information **/ char *path; /*** Path being requested ***/ struct { struct { int present; |
︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | + + | } filed_fileinfo_fdcache[idx].path = strdup(""); filed_fileinfo_fdcache[idx].fd = -1; filed_fileinfo_fdcache[idx].lastmod = ""; filed_fileinfo_fdcache[idx].type = ""; } signal(SIGPIPE, SIG_IGN); return(0); } /* Listen on a particular address/port */ static int filed_listen(const char *address, unsigned int port) { struct sockaddr_in6 addr; |
︙ | |||
217 218 219 220 221 222 223 | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | - + | lseek(fd, 0, SEEK_SET); cache->fd = fd; cache->len = len; cache->path = strdup(path); /* XXX:TODO: Determine */ |
︙ | |||
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | + + | /* Process an HTTP request and return the path requested */ static struct filed_http_request *filed_get_http_request(FILE *fp, struct filed_http_request *buffer_st) { char *method, *path; char *buffer, *tmpbuffer, *workbuffer, *workbuffer_next; size_t buffer_len, tmpbuffer_len; off_t range_start, range_end; ssize_t range_length; int range_request; int i; range_start = 0; range_end = 0; range_request = 0; range_length = -1; buffer = buffer_st->path_b; buffer_len = sizeof(buffer_st->path_b); tmpbuffer = buffer_st->tmpbuf; tmpbuffer_len = sizeof(buffer_st->tmpbuf); |
︙ | |||
301 302 303 304 305 306 307 | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | + + - + - + | if (strncasecmp(tmpbuffer, "Range: ", 7) == 0) { workbuffer = tmpbuffer + 7; if (strncasecmp(workbuffer, "bytes=", 6) == 0) { workbuffer += 6; range_request = 1; |
︙ | |||
338 339 340 341 342 343 344 | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | + - - + + | } range_length = range_end - range_start; } /* Fill up structure to return */ buffer_st->path = path; buffer_st->headers.range.present = range_request; |
︙ | |||
381 382 383 384 385 386 387 388 389 390 391 392 393 394 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | + + | if (fp == NULL) { close(fd); return; } request = filed_get_http_request(fp, request); fflush(fp); path = request->path; filed_log_msg("PROCESS_REPLY_START FD=... PATH=... RANGE_START=... RANGE_LENGTH=..."); if (path == NULL) { filed_error_page(fp, date_current, 500); |
︙ | |||
404 405 406 407 408 409 410 | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | - - + + - - - - - + + + + + - - - - - - - + + + + + + + + + + + - + - + - + + + + + + + + - + - - + + | fileinfo = filed_open_file(path, &request->fileinfo); if (fileinfo == NULL) { filed_error_page(fp, date_current, 404); filed_log_msg("PROCESS_REPLY_COMPLETE FD=... ERROR=404"); } else { |
︙ |