Check-in [5decd7a269]
Overview
Comment:Log formatting changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5decd7a2694ee6a9d7bb301d0044c154707e741e
User & Date: rkeene on 2014-02-08 08:46:21
Other Links: manifest | tags
Context
2014-02-08
08:52
Updated to log message at startup check-in: 0802341b53 user: rkeene tags: trunk
08:46
Log formatting changes check-in: 5decd7a269 user: rkeene tags: trunk
06:59
Post-release version increment check-in: 525e4358e2 user: rkeene tags: trunk
Changes

Modified filed.c from [a9d9efdd38] to [3095917664].

217
218
219
220
221
222
223

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238


239
240
241
242
243
244
245
246
247
248




249
250
251
252
253
254
255
#  define filed_log_msg_debug(x, ...) /**/
#endif

/* Initialize logging thread */
static void *filed_logging_thread(void *arg_p) {
	struct filed_logging_thread_args *arg;
	struct filed_log_entry *curr, *prev;

	FILE *fp;

	arg = arg_p;

	fp = arg->fp;

	while (1) {
		pthread_mutex_lock(&filed_log_msg_list_mutex);
		pthread_cond_wait(&filed_log_msg_list_ready, &filed_log_msg_list_mutex);

		curr = filed_log_msg_list;
		filed_log_msg_list = NULL;

		pthread_mutex_unlock(&filed_log_msg_list_mutex);



		prev = NULL;
		for (; curr; curr = curr->_next) {
			curr->_prev = prev;

			prev = curr;
		}

		curr = prev;
		while (curr) {
			fprintf(fp, "%s THREAD=%llu\n", curr->buffer, (unsigned long long) curr->thread);




			fflush(fp);

			prev = curr;
			curr = curr->_prev;

			free(prev);
		}







>















>
>









|
>
>
>
>







217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#  define filed_log_msg_debug(x, ...) /**/
#endif

/* Initialize logging thread */
static void *filed_logging_thread(void *arg_p) {
	struct filed_logging_thread_args *arg;
	struct filed_log_entry *curr, *prev;
	time_t now;
	FILE *fp;

	arg = arg_p;

	fp = arg->fp;

	while (1) {
		pthread_mutex_lock(&filed_log_msg_list_mutex);
		pthread_cond_wait(&filed_log_msg_list_ready, &filed_log_msg_list_mutex);

		curr = filed_log_msg_list;
		filed_log_msg_list = NULL;

		pthread_mutex_unlock(&filed_log_msg_list_mutex);

		now = time(NULL);

		prev = NULL;
		for (; curr; curr = curr->_next) {
			curr->_prev = prev;

			prev = curr;
		}

		curr = prev;
		while (curr) {
			fprintf(fp, "%s THREAD=%llu TIME=%llu\n",
				curr->buffer,
				(unsigned long long) curr->thread,
				(unsigned long long) now
			);
			fflush(fp);

			prev = curr;
			curr = curr->_prev;

			free(prev);
		}
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653

		fclose(fp);

		return;
	}

	if (request->headers.range.present) {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s RANGE_START=%llu RANGE_LENGTH=%llu",
			fd,
			request->path,
			(unsigned long long) request->headers.range.offset,
			(unsigned long long) request->headers.range.length
		);
	} else {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s", fd, request->path);
	}

	path = request->path;








|



|







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660

		fclose(fp);

		return;
	}

	if (request->headers.range.present) {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s RANGE_START=%llu RANGE_LENGTH=%lli",
			fd,
			request->path,
			(unsigned long long) request->headers.range.offset,
			(long long) request->headers.range.length
		);
	} else {
		filed_log_msg("PROCESS_REPLY_START FD=%i PATH=%s", fd, request->path);
	}

	path = request->path;

661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
	} else {
		if (request->headers.range.offset != 0 || request->headers.range.length >= 0) {
			if (request->headers.range.offset >= fileinfo->len) {
				filed_log_msg("PROCESS_REPLY_COMPLETE FD=%i ERROR=416", fd);

				filed_error_page(fp, date_current, 416);
			} else {
				if (request->headers.range.length < 0) {
					filed_log_msg_debug("Computing length to fit in bounds: fileinfo->len = %llu, request->headers.range.offset = %llu",
						(unsigned long long) fileinfo->len,
						(unsigned long long) request->headers.range.offset
					);

					request->headers.range.length = fileinfo->len - request->headers.range.offset;
				}

				filed_log_msg_debug("Partial request, starting at: %llu and running for %llu bytes",
					(unsigned long long) request->headers.range.offset,
					(unsigned long long) request->headers.range.length
				);

				http_code = 206;
			}
		} else {
			if (request->headers.range.present) {
				http_code = 206;







|








|

|







668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
	} else {
		if (request->headers.range.offset != 0 || request->headers.range.length >= 0) {
			if (request->headers.range.offset >= fileinfo->len) {
				filed_log_msg("PROCESS_REPLY_COMPLETE FD=%i ERROR=416", fd);

				filed_error_page(fp, date_current, 416);
			} else {
				if (request->headers.range.length == ((off_t) -1)) {
					filed_log_msg_debug("Computing length to fit in bounds: fileinfo->len = %llu, request->headers.range.offset = %llu",
						(unsigned long long) fileinfo->len,
						(unsigned long long) request->headers.range.offset
					);

					request->headers.range.length = fileinfo->len - request->headers.range.offset;
				}

				filed_log_msg_debug("Partial request, starting at: %llu and running for %lli bytes",
					(unsigned long long) request->headers.range.offset,
					(long long) request->headers.range.length
				);

				http_code = 206;
			}
		} else {
			if (request->headers.range.present) {
				http_code = 206;