Check-in [16b1aecd99]
Overview
Comment:Check sendfile() output and log
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:16b1aecd995523566eda0f087a187c580db203e1
User & Date: rkeene on 2014-02-04 12:02:48
Other Links: manifest | tags
Context
2014-02-05
08:49
Updated to cache file descriptors check-in: 565d4b51c2 user: rkeene tags: trunk
2014-02-04
12:02
Check sendfile() output and log check-in: 16b1aecd99 user: rkeene tags: trunk
11:51
Added more log messages and support for error pages check-in: 70ecb45a61 user: rkeene tags: trunk
Changes

Modified filed.c from [456b09599d] to [8a849d733e].

   193    193   		error_string
   194    194   	);
   195    195   }
   196    196   
   197    197   /* Handle a single request from a client */
   198    198   static void filed_handle_client(int fd) {
   199    199   	struct filed_fileinfo *fileinfo, fileinfo_b;
          200  +	ssize_t sendfile_ret;
   200    201   	char *path, path_b[1010];
   201    202   	char *date_current, date_current_b[64];
   202    203   	FILE *fp;
   203    204   
   204    205   	/* Determine current time */
   205    206   	date_current = filed_format_time(date_current_b, sizeof(date_current_b), time(NULL));
   206    207   
................................................................................
   240    241   		);
   241    242   		fflush(fp);
   242    243   
   243    244   		filed_log_msg("PROCESS_REPLY_COMPLETE FD=... STATUS=200");
   244    245   
   245    246   		filed_log_msg("SEND_START IFD=... OFD=... BYTES=...");
   246    247   
   247         -		sendfile(fd, fileinfo->fd, NULL, fileinfo->len);
   248         -
   249         -		filed_log_msg("SEND_COMPLETE IFD=... OFD=... BYTES=...");
          248  +		sendfile_ret = sendfile(fd, fileinfo->fd, NULL, fileinfo->len);
          249  +		if (sendfile_ret < 0 || ((size_t) sendfile_ret) != fileinfo->len) {
          250  +			filed_log_msg("SEND_COMPLETE STATUS=ERROR IFD=... OFD=... BYTES=... BYTES_SENT=...");
          251  +		} else {
          252  +			filed_log_msg("SEND_COMPLETE STATUS=OK IFD=... OFD=... BYTES=...");
          253  +		}
   250    254   
   251    255   		close(fileinfo->fd);
   252    256   
   253    257   		filed_log_msg("CLOSE_FILE FD=...");
   254    258   	}
   255    259   
   256    260   	filed_log_msg("CLOSE_CONNECTION FD=...");