Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better explain how the --blocking-io option works.
[rsync/rsync.git]
/
main.c
diff --git
a/main.c
b/main.c
index
4bd721c
..
ca2b456
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-1,5
+1,6
@@
-/*
- Copyright (C) Andrew Tridgell 1996
+/* -*- c-file-style: "linux" -*-
+
+ Copyright (C) 1996-2000 by Andrew Tridgell
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
@@
-32,7
+33,7
@@
wait for a process to exit, calling io_flush while waiting
void wait_process(pid_t pid, int *status)
{
while (waitpid(pid, status, WNOHANG) == 0) {
void wait_process(pid_t pid, int *status)
{
while (waitpid(pid, status, WNOHANG) == 0) {
-
sleep(1
);
+
msleep(20
);
io_flush();
}
*status = WEXITSTATUS(*status);
io_flush();
}
*status = WEXITSTATUS(*status);
@@
-349,14
+350,13
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
close(recv_pipe[1]);
io_flush();
/* finally we go to sleep until our parent kills us
close(recv_pipe[1]);
io_flush();
/* finally we go to sleep until our parent kills us
- with a USR2 signal. We sleep
p
for a short time as on
+ with a USR2 signal. We sleep for a short time as on
some OSes a signal won't interrupt a sleep! */
some OSes a signal won't interrupt a sleep! */
- while (1)
sleep(1
);
+ while (1)
msleep(20
);
}
close(recv_pipe[1]);
close(error_pipe[1]);
}
close(recv_pipe[1]);
close(error_pipe[1]);
- io_close_input(f_in);
if (f_in != f_out) close(f_in);
io_start_buffering(f_out);
if (f_in != f_out) close(f_in);
io_start_buffering(f_out);
@@
-459,13
+459,17
@@
void start_server(int f_in, int f_out, int argc, char *argv[])
exit_cleanup(0);
}
exit_cleanup(0);
}
+
+/*
+ * This is called once the connection has been negotiated. It is used
+ * for rsyncd, remote-shell, and local connections.
+ */
int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
{
struct file_list *flist;
int status = 0, status2 = 0;
char *local_name = NULL;
extern int am_sender;
int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
{
struct file_list *flist;
int status = 0, status2 = 0;
char *local_name = NULL;
extern int am_sender;
- extern int list_only;
extern int remote_version;
set_nonblocking(f_in);
extern int remote_version;
set_nonblocking(f_in);
@@
-503,13
+507,18
@@
int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
exit_cleanup(status);
}
exit_cleanup(status);
}
- if (argc == 0) list_only = 1;
+ if (argc == 0) {
+ extern int list_only;
+ list_only = 1;
+ }
send_exclude_list(f_out);
flist = recv_file_list(f_in);
if (!flist || flist->count == 0) {
send_exclude_list(f_out);
flist = recv_file_list(f_in);
if (!flist || flist->count == 0) {
- rprintf(FINFO,"client: nothing to do\n");
+ rprintf(FINFO, "client: nothing to do: "
+ "perhaps you need to specify some filenames or "
+ "the --recursive option?\n");
exit_cleanup(0);
}
exit_cleanup(0);
}
@@
-542,6
+551,12
@@
static char *find_colon(char *s)
return p;
}
return p;
}
+
+/*
+ * Start a client for either type of remote connection. Work out
+ * whether the arguments request a remote shell or rsyncd connection,
+ * and call the appropriate connection function, then run_client.
+ */
static int start_client(int argc, char *argv[])
{
char *p;
static int start_client(int argc, char *argv[])
{
char *p;
@@
-554,11
+569,12
@@
static int start_client(int argc, char *argv[])
extern int am_sender;
extern char *shell_cmd;
extern int rsync_port;
extern int am_sender;
extern char *shell_cmd;
extern int rsync_port;
+ char *argv0 = strdup(argv[0]);
- if (strncasecmp(URL_PREFIX, argv
[0]
, strlen(URL_PREFIX)) == 0) {
+ if (strncasecmp(URL_PREFIX, argv
0
, strlen(URL_PREFIX)) == 0) {
char *host, *path;
char *host, *path;
- host = argv
[0]
+ strlen(URL_PREFIX);
+ host = argv
0
+ strlen(URL_PREFIX);
p = strchr(host,'/');
if (p) {
*p = 0;
p = strchr(host,'/');
if (p) {
*p = 0;
@@
-574,12
+590,12
@@
static int start_client(int argc, char *argv[])
return start_socket_client(host, path, argc-1, argv+1);
}
return start_socket_client(host, path, argc-1, argv+1);
}
- p = find_colon(argv
[0]
);
+ p = find_colon(argv
0
);
if (p) {
if (p[1] == ':') {
*p = 0;
if (p) {
if (p[1] == ':') {
*p = 0;
- return start_socket_client(argv
[0]
, p+2, argc-1, argv+1);
+ return start_socket_client(argv
0
, p+2, argc-1, argv+1);
}
if (argc < 1) {
}
if (argc < 1) {
@@
-589,7
+605,7
@@
static int start_client(int argc, char *argv[])
am_sender = 0;
*p = 0;
am_sender = 0;
*p = 0;
- shell_machine = argv
[0]
;
+ shell_machine = argv
0
;
shell_path = p+1;
argc--;
argv++;
shell_path = p+1;
argc--;
argv++;
@@
-641,6
+657,11
@@
static int start_client(int argc, char *argv[])
usage(FERROR);
exit_cleanup(RERR_SYNTAX);
}
usage(FERROR);
exit_cleanup(RERR_SYNTAX);
}
+
+ if (argc == 0 && !am_sender) {
+ extern int list_only;
+ list_only = 1;
+ }
pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,&f_in,&f_out);
pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,&f_in,&f_out);