Check-in [7a401fd8d2]
Overview
Comment:Updated to do less work if logging is disabled
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7a401fd8d2c4023da3466a49360218fd523d72f8
User & Date: rkeene on 2014-02-08 03:09:51
Other Links: manifest | tags
Context
2014-02-08
03:10
Noted that status should be reported check-in: 1127550a5c user: rkeene tags: trunk
03:09
Updated to do less work if logging is disabled check-in: 7a401fd8d2 user: rkeene tags: trunk
03:04
Updated to compile correctly with logging disabled check-in: 66d99492b4 user: rkeene tags: trunk
Changes

Modified filed.c from [1884ac0577] to [1e9ce66531].

   427    427   	size_t buffer_len, tmpbuffer_len;
   428    428   	off_t range_start, range_end, range_length;
   429    429   	int range_request;
   430    430   	int fd;
   431    431   	int i;
   432    432   
   433    433   	fd = fileno(fp);
   434         -	fd = fd;
   435    434   
   436    435   	range_start = 0;
   437    436   	range_end   = 0;
   438    437   	range_request = 0;
   439    438   	range_length = -1;
   440    439   
   441    440   	buffer = buffer_st->path_b;
................................................................................
   527    526   	/* Fill up structure to return */
   528    527   	buffer_st->path   = path;
   529    528   	buffer_st->headers.range.present = range_request;
   530    529   	buffer_st->headers.range.offset  = range_start;
   531    530   	buffer_st->headers.range.length  = range_length;
   532    531   
   533    532   	return(buffer_st);
          533  +
          534  +	/* Make compiler happy */
          535  +	fd = fd;
   534    536   }
   535    537   
   536    538   /* Return an error page */
   537    539   static void filed_error_page(FILE *fp, const char *date_current, int error_number) {
   538    540   	char *error_string = "<html><head><title>ERROR</title></head><body>Unable to process request</body></html>";
   539    541   
   540    542   	fprintf(fp, "HTTP/1.1 %i OK\r\nDate: %s\r\nServer: filed\r\nLast-Modified: %s\r\nContent-Length: %llu\r\nContent-Type: %s\r\nConnection: close\r\n\r\n%s",
................................................................................
   749    751   }
   750    752   
   751    753   /* Handle incoming connections */
   752    754   static void *filed_worker_thread(void *arg_v) {
   753    755   	struct filed_worker_thread_args *arg;
   754    756   	struct filed_http_request request;
   755    757   	struct sockaddr_in6 addr;
   756         -	char logbuf[128];
          758  +	char logbuf_ip[128];
   757    759   	socklen_t addrlen;
   758    760   	int failure_count = 0, max_failure_count = MAX_FAILURE_COUNT;
   759    761   	int master_fd, fd;
   760    762   
   761    763   	/* Read arguments */
   762    764   	arg = arg_v;
   763    765   
................................................................................
   783    785   
   784    786   			failure_count++;
   785    787   
   786    788   			continue;
   787    789   		}
   788    790   
   789    791   		/* Log the new connection */
   790         -		logbuf[0]='\0';
   791         -		inet_ntop(AF_INET6, &addr.sin6_addr, logbuf, sizeof(logbuf));
   792         -		filed_log_msg("NEW_CONNECTION SRC_ADDR=%s SRC_PORT=%lu FD=%i", logbuf, (unsigned long) addr.sin6_port, fd);
          792  +		filed_log_msg("NEW_CONNECTION SRC_ADDR=%s SRC_PORT=%lu FD=%i",
          793  +			inet_ntop(AF_INET6, &addr.sin6_addr, logbuf_ip, sizeof(logbuf_ip)) ? logbuf_ip : "<unknown>",
          794  +			(unsigned long) addr.sin6_port,
          795  +			fd
          796  +		);
   793    797   
   794    798   		/* Reset failure count*/
   795    799   		failure_count = 0;
   796    800   
   797    801   		/* Handle socket */
   798    802   		filed_handle_client(fd, &request);
   799    803   	}
   800    804   
   801    805   	/* Report error */
   802    806   	filed_log_msg("THREAD_DIED ABNORMAL");
   803    807   
   804    808   	return(NULL);
          809  +
          810  +	/* Make compiler happy */
          811  +	logbuf_ip[0] = '\0';
          812  +	logbuf_ip[0] = logbuf_ip[0];
          813  +
   805    814   }
   806    815   
   807    816   /* Create worker threads */
   808    817   static int filed_worker_threads_init(int fd, int thread_count) {
   809    818   	struct filed_worker_thread_args *arg;
   810    819   	pthread_t threadid;
   811    820   	int pthread_ret;