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