Fossil SCM
If autosync fails, try again to defined maximum with a 1 second sleep between failures.
Commit
fae1eca8f67e9a8623609d61fdceb47951c9eedb
Parent
8a5f192b4040174…
2 files changed
+2
-2
+24
-1
+2
-2
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -1547,11 +1547,11 @@ | ||
| 1547 | 1547 | |
| 1548 | 1548 | /* |
| 1549 | 1549 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1550 | 1550 | */ |
| 1551 | 1551 | if( !g.markPrivate ){ |
| 1552 | - if( autosync(SYNC_PULL) ){ | |
| 1552 | + if( autosync_loop(SYNC_PULL) ){ | |
| 1553 | 1553 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1554 | 1554 | cReply = blob_str(&ans)[0]; |
| 1555 | 1555 | if( cReply!='y' && cReply!='Y' ){ |
| 1556 | 1556 | fossil_exit(1); |
| 1557 | 1557 | } |
| @@ -1932,11 +1932,11 @@ | ||
| 1932 | 1932 | exit(1); |
| 1933 | 1933 | } |
| 1934 | 1934 | db_end_transaction(0); |
| 1935 | 1935 | |
| 1936 | 1936 | if( !g.markPrivate ){ |
| 1937 | - autosync(SYNC_PUSH|SYNC_PULL); | |
| 1937 | + autosync_loop(SYNC_PUSH|SYNC_PULL); | |
| 1938 | 1938 | } |
| 1939 | 1939 | if( count_nonbranch_children(vid)>1 ){ |
| 1940 | 1940 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1941 | 1941 | } |
| 1942 | 1942 | } |
| 1943 | 1943 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1547,11 +1547,11 @@ | |
| 1547 | |
| 1548 | /* |
| 1549 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1550 | */ |
| 1551 | if( !g.markPrivate ){ |
| 1552 | if( autosync(SYNC_PULL) ){ |
| 1553 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1554 | cReply = blob_str(&ans)[0]; |
| 1555 | if( cReply!='y' && cReply!='Y' ){ |
| 1556 | fossil_exit(1); |
| 1557 | } |
| @@ -1932,11 +1932,11 @@ | |
| 1932 | exit(1); |
| 1933 | } |
| 1934 | db_end_transaction(0); |
| 1935 | |
| 1936 | if( !g.markPrivate ){ |
| 1937 | autosync(SYNC_PUSH|SYNC_PULL); |
| 1938 | } |
| 1939 | if( count_nonbranch_children(vid)>1 ){ |
| 1940 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1941 | } |
| 1942 | } |
| 1943 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -1547,11 +1547,11 @@ | |
| 1547 | |
| 1548 | /* |
| 1549 | ** Autosync if autosync is enabled and this is not a private check-in. |
| 1550 | */ |
| 1551 | if( !g.markPrivate ){ |
| 1552 | if( autosync_loop(SYNC_PULL) ){ |
| 1553 | prompt_user("continue in spite of sync failure (y/N)? ", &ans); |
| 1554 | cReply = blob_str(&ans)[0]; |
| 1555 | if( cReply!='y' && cReply!='Y' ){ |
| 1556 | fossil_exit(1); |
| 1557 | } |
| @@ -1932,11 +1932,11 @@ | |
| 1932 | exit(1); |
| 1933 | } |
| 1934 | db_end_transaction(0); |
| 1935 | |
| 1936 | if( !g.markPrivate ){ |
| 1937 | autosync_loop(SYNC_PUSH|SYNC_PULL); |
| 1938 | } |
| 1939 | if( count_nonbranch_children(vid)>1 ){ |
| 1940 | fossil_print("**** warning: a fork has occurred *****\n"); |
| 1941 | } |
| 1942 | } |
| 1943 |
+24
-1
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -19,10 +19,19 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include "sync.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | +#if defined(_WIN32) | |
| 25 | +# include <windows.h> /* for Sleep */ | |
| 26 | +# if defined(__MINGW32__) || defined(_MSC_VER) | |
| 27 | +# define sleep Sleep /* windows does not have sleep, but Sleep */ | |
| 28 | +# endif | |
| 29 | +#endif | |
| 30 | + | |
| 31 | +#define AUTOSYNC_TRIES 3 | |
| 32 | + | |
| 24 | 33 | /* |
| 25 | 34 | ** If the repository is configured for autosyncing, then do an |
| 26 | 35 | ** autosync. This will be a pull if the argument is true or a push |
| 27 | 36 | ** if the argument is false. |
| 28 | 37 | ** |
| @@ -72,11 +81,25 @@ | ||
| 72 | 81 | #endif |
| 73 | 82 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 74 | 83 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 75 | 84 | url_enable_proxy("via proxy: "); |
| 76 | 85 | rc = client_sync(flags, configSync, 0); |
| 77 | - if( rc ) fossil_warning("Autosync failed"); | |
| 86 | + return rc; | |
| 87 | +} | |
| 88 | + | |
| 89 | +/* | |
| 90 | +** This routine will try a number of times to perform autosync with a | |
| 91 | +** 1 second sleep between attempts; returning the last autosync status. | |
| 92 | +*/ | |
| 93 | +int autosync_loop(int flags){ | |
| 94 | + int n = 0; | |
| 95 | + int rc = 0; | |
| 96 | + while (n++ < AUTOSYNC_TRIES && (rc = autosync(flags))){ | |
| 97 | + if( rc ) fossil_warning("Autosync failed%s", | |
| 98 | + n < AUTOSYNC_TRIES ? ", making another attempt." : "."); | |
| 99 | + sleep(1); | |
| 100 | + } | |
| 78 | 101 | return rc; |
| 79 | 102 | } |
| 80 | 103 | |
| 81 | 104 | /* |
| 82 | 105 | ** This routine processes the command-line argument for push, pull, |
| 83 | 106 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -19,10 +19,19 @@ | |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include "sync.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** If the repository is configured for autosyncing, then do an |
| 26 | ** autosync. This will be a pull if the argument is true or a push |
| 27 | ** if the argument is false. |
| 28 | ** |
| @@ -72,11 +81,25 @@ | |
| 72 | #endif |
| 73 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 74 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 75 | url_enable_proxy("via proxy: "); |
| 76 | rc = client_sync(flags, configSync, 0); |
| 77 | if( rc ) fossil_warning("Autosync failed"); |
| 78 | return rc; |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | ** This routine processes the command-line argument for push, pull, |
| 83 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -19,10 +19,19 @@ | |
| 19 | */ |
| 20 | #include "config.h" |
| 21 | #include "sync.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | #if defined(_WIN32) |
| 25 | # include <windows.h> /* for Sleep */ |
| 26 | # if defined(__MINGW32__) || defined(_MSC_VER) |
| 27 | # define sleep Sleep /* windows does not have sleep, but Sleep */ |
| 28 | # endif |
| 29 | #endif |
| 30 | |
| 31 | #define AUTOSYNC_TRIES 3 |
| 32 | |
| 33 | /* |
| 34 | ** If the repository is configured for autosyncing, then do an |
| 35 | ** autosync. This will be a pull if the argument is true or a push |
| 36 | ** if the argument is false. |
| 37 | ** |
| @@ -72,11 +81,25 @@ | |
| 81 | #endif |
| 82 | if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE; |
| 83 | fossil_print("Autosync: %s\n", g.url.canonical); |
| 84 | url_enable_proxy("via proxy: "); |
| 85 | rc = client_sync(flags, configSync, 0); |
| 86 | return rc; |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | ** This routine will try a number of times to perform autosync with a |
| 91 | ** 1 second sleep between attempts; returning the last autosync status. |
| 92 | */ |
| 93 | int autosync_loop(int flags){ |
| 94 | int n = 0; |
| 95 | int rc = 0; |
| 96 | while (n++ < AUTOSYNC_TRIES && (rc = autosync(flags))){ |
| 97 | if( rc ) fossil_warning("Autosync failed%s", |
| 98 | n < AUTOSYNC_TRIES ? ", making another attempt." : "."); |
| 99 | sleep(1); |
| 100 | } |
| 101 | return rc; |
| 102 | } |
| 103 | |
| 104 | /* |
| 105 | ** This routine processes the command-line argument for push, pull, |
| 106 |