Check-in [6255e77ee6]
Overview
Comment:Removed index.html serving workaround
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6255e77ee64f06cc5f0e3a58f04fca870bbe04f4
User & Date: rkeene on 2014-02-18 20:03:33
Other Links: manifest | tags
Context
2014-02-18
20:57
Added redirect support for index pages as well as early-return paths for error pages check-in: e6e6a5a647 user: rkeene tags: trunk
20:03
Removed index.html serving workaround check-in: 6255e77ee6 user: rkeene tags: trunk
05:21
Updated to log fdopen failures instead of silently ignoring them check-in: df2de34e2e user: rkeene tags: trunk
Changes

Modified filed.c from [79c614eba1] to [02ed31827c].

559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
...
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
		(unsigned long long) random()
	);
}

/* Open a file and return file information */
static struct filed_fileinfo *filed_open_file(const char *path, struct filed_fileinfo *buffer) {
	struct filed_fileinfo *cache;
	const char *open_path;
	unsigned int cache_idx;
	off_t len;
	int fd;

	cache_idx = filed_hash((const unsigned char *) path, filed_fileinfo_fdcache_size);

	cache = &filed_fileinfo_fdcache[cache_idx];
................................................................................
	pthread_mutex_lock(&cache->mutex);

	filed_log_msg_debug("Completed locking mutex for idx: %lu", (unsigned long) cache_idx);

	if (strcmp(path, cache->path) != 0) {
		filed_log_msg_debug("Cache miss for idx: %lu: OLD \"%s\", NEW \"%s\"", (unsigned long) cache_idx, cache->path, path);

		/* For requests for the root directory, serve out index.html */
		if (path[0] == '\0' || (path[0] == '/' && path[1] == '\0')) {
			open_path = "/index.html";
		} else {
			open_path = path;
		}

		fd = open(open_path, O_RDONLY | O_LARGEFILE);
		if (fd < 0) {
			pthread_mutex_unlock(&cache->mutex);

			return(NULL);
		}

		if (cache->fd >= 0) {
................................................................................

		len = lseek(fd, 0, SEEK_END);
		lseek(fd, 0, SEEK_SET);

		cache->fd = fd;
		cache->len = len;
		strcpy(cache->path, path);
		cache->type = filed_determine_mimetype(open_path);
		filed_generate_etag(cache->etag, sizeof(cache->etag));

		/* XXX:TODO: Determine */
		cache->lastmod = filed_format_time(cache->lastmod_b, sizeof(cache->lastmod_b), time(NULL) - 30);
	} else {
		filed_log_msg_debug("Cache hit for idx: %lu: PATH \"%s\"", (unsigned long) cache_idx, path);
	}







<







 







<
<
<
<
<
<
<
|







 







|







559
560
561
562
563
564
565

566
567
568
569
570
571
572
...
576
577
578
579
580
581
582







583
584
585
586
587
588
589
590
...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
		(unsigned long long) random()
	);
}

/* Open a file and return file information */
static struct filed_fileinfo *filed_open_file(const char *path, struct filed_fileinfo *buffer) {
	struct filed_fileinfo *cache;

	unsigned int cache_idx;
	off_t len;
	int fd;

	cache_idx = filed_hash((const unsigned char *) path, filed_fileinfo_fdcache_size);

	cache = &filed_fileinfo_fdcache[cache_idx];
................................................................................
	pthread_mutex_lock(&cache->mutex);

	filed_log_msg_debug("Completed locking mutex for idx: %lu", (unsigned long) cache_idx);

	if (strcmp(path, cache->path) != 0) {
		filed_log_msg_debug("Cache miss for idx: %lu: OLD \"%s\", NEW \"%s\"", (unsigned long) cache_idx, cache->path, path);








		fd = open(path, O_RDONLY | O_LARGEFILE);
		if (fd < 0) {
			pthread_mutex_unlock(&cache->mutex);

			return(NULL);
		}

		if (cache->fd >= 0) {
................................................................................

		len = lseek(fd, 0, SEEK_END);
		lseek(fd, 0, SEEK_SET);

		cache->fd = fd;
		cache->len = len;
		strcpy(cache->path, path);
		cache->type = filed_determine_mimetype(path);
		filed_generate_etag(cache->etag, sizeof(cache->etag));

		/* XXX:TODO: Determine */
		cache->lastmod = filed_format_time(cache->lastmod_b, sizeof(cache->lastmod_b), time(NULL) - 30);
	} else {
		filed_log_msg_debug("Cache hit for idx: %lu: PATH \"%s\"", (unsigned long) cache_idx, path);
	}