n = read(fd, buf, len);
if (n > 0) {
- stats.total_read += n;
buf += n;
len -= n;
ret += n;
ret = read_unbuffered(fd,buffer + total,N-total);
total += ret;
}
+
+ stats.total_read += total;
}
blocked = 0;
total += ret;
- stats.total_written += ret;
if (io_timeout)
last_io = time(NULL);
static void writefd(int fd,char *buf,int len)
{
+ stats.total_written += len;
+
if (!io_buffer) {
writefd_unbuffered(fd, buf, len);
return;
SIVAL(io_buffer-4, 0, ((MPLEX_BASE + f)<<24) + len);
memcpy(io_buffer, buf, len);
+ stats.total_written += (len+4);
+
writefd_unbuffered(multiplex_out_fd, io_buffer-4, len+4);
return 1;
}
/* a generic logging routine for send/recv, with parameter
substitiution */
-static void log_formatted(char *op, struct file_struct *file)
+static void log_formatted(char *op, struct file_struct *file,
+ struct stats *initial_stats)
{
extern int module_id;
extern char *auth_user;
char *p, *s, *n;
char buf2[100];
int l;
+ extern struct stats stats;
+ extern int am_sender;
+ int64 b;
strlcpy(buf, lp_log_format(module_id), sizeof(buf)-1);
case 'm': n = lp_name(module_id); break;
case 'P': n = lp_path(module_id); break;
case 'u': n = auth_user; break;
+ case 'b':
+ if (am_sender) {
+ b = stats.total_written -
+ initial_stats->total_written;
+ } else {
+ b = stats.total_read -
+ initial_stats->total_read;
+ }
+ slprintf(buf2,sizeof(buf2)-1,"%.0f", (double)b);
+ n = buf2;
+ break;
+ case 'c':
+ if (!am_sender) {
+ b = stats.total_written -
+ initial_stats->total_written;
+ } else {
+ b = stats.total_read -
+ initial_stats->total_read;
+ }
+ slprintf(buf2,sizeof(buf2)-1,"%.0f", (double)b);
+ n = buf2;
+ break;
}
if (!n) continue;
}
/* log the outgoing transfer of a file */
-void log_send(struct file_struct *file)
+void log_send(struct file_struct *file, struct stats *initial_stats)
{
extern int module_id;
if (lp_transfer_logging(module_id)) {
- log_formatted("send", file);
+ log_formatted("send", file, initial_stats);
}
}
/* log the incoming transfer of a file */
-void log_recv(struct file_struct *file)
+void log_recv(struct file_struct *file, struct stats *initial_stats)
{
extern int module_id;
if (lp_transfer_logging(module_id)) {
- log_formatted("recv", file);
+ log_formatted("recv", file, initial_stats);
}
}
struct file_struct *file;
int phase=0;
int recv_ok;
+ extern struct stats stats;
+ struct stats initial_stats;
if (verbose > 2) {
rprintf(FINFO,"recv_files(%d) starting\n",flist->count);
continue;
}
+ initial_stats = stats;
+
if (verbose > 2)
rprintf(FINFO,"recv_files(%s)\n",fname);
log_transfer(file, fname);
}
- log_recv(file);
-
/* recv file data */
recv_ok = receive_data(f_in,buf,fd2,fname,file->length);
+
+ log_recv(file, &initial_stats);
if (buf) unmap_file(buf);
if (fd1 != -1) {
it() %P for the module path
it() %m for the module name
it() %u for the authenticated username (or the null string)
+ it() %b for the number of bytes actually transferred
+ it() %c when sending files this gives the number of checksum bytes
+ received for this file
)
The default log format is "%o %h [%a] %m (%u) %f %l"
int i;
struct file_struct *file;
int phase = 0;
+ extern struct stats stats;
+ struct stats initial_stats;
if (verbose > 2)
rprintf(FINFO,"send_files starting\n");
continue;
}
+ initial_stats = stats;
+
s = receive_sums(f_in);
if (!s) {
io_error = 1;
rprintf(FINFO,"send_files mapped %s of size %d\n",
fname,(int)st.st_size);
- log_send(file);
-
write_int(f_out,i);
write_int(f_out,s->count);
}
match_sums(f_out,s,buf,st.st_size);
-
+
+ log_send(file, &initial_stats);
+
if (buf) unmap_file(buf);
close(fd);