Check-in [5d3ae25128]
Overview
Comment:Updated to keep track of sent bytes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5d3ae251283298fdc0f9b29999ecd86b364e063f
User & Date: rkeene on 2014-02-06 06:47:32
Other Links: manifest | tags
Context
2014-02-06
07:42
Updated to correctly encode range check-in: 6add2b1206 user: rkeene tags: trunk
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
Changes

Modified filed.c from [5e37a15236] to [b68d97d7c3].

    53     53   			off_t offset;   /*** Range start ***/
    54     54   			ssize_t length; /*** Range length ***/
    55     55   		} range;
    56     56   	} headers;
    57     57   };
    58     58   
    59     59   /* Global variables */
           60  +/** Open File cache **/
    60     61   struct filed_fileinfo *filed_fileinfo_fdcache;
    61     62   unsigned int filed_fileinfo_fdcache_size = CACHE_SIZE;
    62     63   
    63     64   /* Initialize process */
    64     65   static int filed_init(void) {
    65     66   	unsigned int idx;
    66     67   	int mutex_init_ret;
................................................................................
   376    377   	);
   377    378   }
   378    379   
   379    380   /* Handle a single request from a client */
   380    381   static void filed_handle_client(int fd, struct filed_http_request *request) {
   381    382   	struct filed_fileinfo *fileinfo;
   382    383   	ssize_t sendfile_ret;
   383         -	size_t sendfile_len;
          384  +	size_t sendfile_len, sendfile_sent;
   384    385   	off_t sendfile_offset;
   385    386   	char *path;
   386    387   	char *date_current, date_current_b[64];
   387    388   	int http_code;
   388    389   	FILE *fp;
   389    390   
   390    391   	/* Determine current time */
................................................................................
   396    397   		close(fd);
   397    398   
   398    399   		return;
   399    400   	}
   400    401   
   401    402   	request = filed_get_http_request(fp, request);
   402    403   
   403         -	fflush(fp);
   404         -
   405    404   	path = request->path;
   406    405   
   407    406   	filed_log_msg("PROCESS_REPLY_START FD=... PATH=... RANGE_START=... RANGE_LENGTH=...");
   408    407   
   409    408   	if (path == NULL) {
   410    409   		filed_error_page(fp, date_current, 500);
   411    410   
................................................................................
   468    467   
   469    468   			filed_log_msg("PROCESS_REPLY_COMPLETE FD=... STATUS=20X");
   470    469   
   471    470   			filed_log_msg("SEND_START IFD=... OFD=... BYTES=...");
   472    471   
   473    472   			sendfile_offset = request->headers.range.offset;
   474    473   			sendfile_len = request->headers.range.length;
          474  +			sendfile_sent = 0;
   475    475   			while (1) {
   476    476   				sendfile_ret = sendfile(fd, fileinfo->fd, &sendfile_offset, sendfile_len);
   477    477   				if (sendfile_ret <= 0) {
   478    478   					break;
   479    479   				}
   480    480   
   481    481   				sendfile_len -= sendfile_ret;
          482  +				sendfile_sent += sendfile_ret;
   482    483   				if (sendfile_len == 0) {
   483    484   					break;
   484    485   				}
   485    486   			}
   486    487   
   487    488   			filed_log_msg("SEND_COMPLETE STATUS=... IFD=... OFD=... BYTES=... BYTES_SENT=...");
   488    489   		}