Fossil SCM
Take care to close the connection to the database file before existing. This gives the database a chance to clean up (and, for example, delete WAL and shared-memory files).
Commit
932825bc6a2510ace4ba295f4f5462fe2fc054c4
Parent
f0cd78c1a3d0847…
12 files changed
+1
-1
+1
-1
+8
-8
+2
-4
+5
-2
+8
-8
+2
-2
+18
-8
+5
-5
-1
+1
-1
+1
-1
+1
-1
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -99,11 +99,11 @@ | ||
| 99 | 99 | ** have run out of memory. |
| 100 | 100 | */ |
| 101 | 101 | static void blob_panic(void){ |
| 102 | 102 | static const char zErrMsg[] = "out of memory\n"; |
| 103 | 103 | write(2, zErrMsg, sizeof(zErrMsg)-1); |
| 104 | - exit(1); | |
| 104 | + fossil_exit(1); | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /* |
| 108 | 108 | ** A reallocation function that assumes that aData came from malloc(). |
| 109 | 109 | ** This function attempts to resize the buffer of the blob to hold |
| 110 | 110 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -99,11 +99,11 @@ | |
| 99 | ** have run out of memory. |
| 100 | */ |
| 101 | static void blob_panic(void){ |
| 102 | static const char zErrMsg[] = "out of memory\n"; |
| 103 | write(2, zErrMsg, sizeof(zErrMsg)-1); |
| 104 | exit(1); |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | ** A reallocation function that assumes that aData came from malloc(). |
| 109 | ** This function attempts to resize the buffer of the blob to hold |
| 110 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -99,11 +99,11 @@ | |
| 99 | ** have run out of memory. |
| 100 | */ |
| 101 | static void blob_panic(void){ |
| 102 | static const char zErrMsg[] = "out of memory\n"; |
| 103 | write(2, zErrMsg, sizeof(zErrMsg)-1); |
| 104 | fossil_exit(1); |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | ** A reallocation function that assumes that aData came from malloc(). |
| 109 | ** This function attempts to resize the buffer of the blob to hold |
| 110 |
+1
-1
| --- src/branch.c | ||
| +++ src/branch.c | ||
| @@ -129,11 +129,11 @@ | ||
| 129 | 129 | Blob ans; |
| 130 | 130 | blob_zero(&ans); |
| 131 | 131 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 132 | 132 | if( blob_str(&ans)[0]!='y' ){ |
| 133 | 133 | db_end_transaction(1); |
| 134 | - exit(1); | |
| 134 | + fossil_exit(1); | |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | brid = content_put(&branch, 0, 0); |
| 139 | 139 | if( brid==0 ){ |
| 140 | 140 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -129,11 +129,11 @@ | |
| 129 | Blob ans; |
| 130 | blob_zero(&ans); |
| 131 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 132 | if( blob_str(&ans)[0]!='y' ){ |
| 133 | db_end_transaction(1); |
| 134 | exit(1); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | brid = content_put(&branch, 0, 0); |
| 139 | if( brid==0 ){ |
| 140 |
| --- src/branch.c | |
| +++ src/branch.c | |
| @@ -129,11 +129,11 @@ | |
| 129 | Blob ans; |
| 130 | blob_zero(&ans); |
| 131 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 132 | if( blob_str(&ans)[0]!='y' ){ |
| 133 | db_end_transaction(1); |
| 134 | fossil_exit(1); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | brid = content_put(&branch, 0, 0); |
| 139 | if( brid==0 ){ |
| 140 |
+8
-8
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -349,11 +349,11 @@ | ||
| 349 | 349 | cgi_reset_content(); |
| 350 | 350 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); |
| 351 | 351 | cgi_set_status(302, "Moved Temporarily"); |
| 352 | 352 | free(zLocation); |
| 353 | 353 | cgi_reply(); |
| 354 | - exit(0); | |
| 354 | + fossil_exit(0); | |
| 355 | 355 | } |
| 356 | 356 | void cgi_redirectf(const char *zFormat, ...){ |
| 357 | 357 | va_list ap; |
| 358 | 358 | va_start(ap, zFormat); |
| 359 | 359 | cgi_redirect(vmprintf(zFormat, ap)); |
| @@ -384,11 +384,11 @@ | ||
| 384 | 384 | */ |
| 385 | 385 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 386 | 386 | if( nAllocQP<=nUsedQP ){ |
| 387 | 387 | nAllocQP = nAllocQP*2 + 10; |
| 388 | 388 | aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); |
| 389 | - if( aParamQP==0 ) exit(1); | |
| 389 | + if( aParamQP==0 ) fossil_exit(1); | |
| 390 | 390 | } |
| 391 | 391 | aParamQP[nUsedQP].zName = zName; |
| 392 | 392 | aParamQP[nUsedQP].zValue = zValue; |
| 393 | 393 | if( g.fHttpTrace ){ |
| 394 | 394 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -678,11 +678,11 @@ | ||
| 678 | 678 | if( len>0 && zType ){ |
| 679 | 679 | blob_zero(&g.cgiIn); |
| 680 | 680 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 681 | 681 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 682 | 682 | z = malloc( len+1 ); |
| 683 | - if( z==0 ) exit(1); | |
| 683 | + if( z==0 ) fossil_exit(1); | |
| 684 | 684 | len = fread(z, 1, len, g.httpIn); |
| 685 | 685 | z[len] = 0; |
| 686 | 686 | if( zType[0]=='a' ){ |
| 687 | 687 | add_param_list(z, '&'); |
| 688 | 688 | }else{ |
| @@ -1015,11 +1015,11 @@ | ||
| 1015 | 1015 | cgi_set_status(501, "Not Implemented"); |
| 1016 | 1016 | cgi_printf( |
| 1017 | 1017 | "<html><body>Unrecognized HTTP Request</body></html>\n" |
| 1018 | 1018 | ); |
| 1019 | 1019 | cgi_reply(); |
| 1020 | - exit(0); | |
| 1020 | + fossil_exit(0); | |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | /* |
| 1024 | 1024 | ** Panic and die while processing a webpage. |
| 1025 | 1025 | */ |
| @@ -1033,11 +1033,11 @@ | ||
| 1033 | 1033 | ); |
| 1034 | 1034 | va_start(ap, zFormat); |
| 1035 | 1035 | vxprintf(pContent,zFormat,ap); |
| 1036 | 1036 | va_end(ap); |
| 1037 | 1037 | cgi_reply(); |
| 1038 | - exit(1); | |
| 1038 | + fossil_exit(1); | |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | /* |
| 1042 | 1042 | ** Remove the first space-delimited token from a string and return |
| 1043 | 1043 | ** a pointer to it. Add a NULL to the string to terminate the token. |
| @@ -1163,11 +1163,11 @@ | ||
| 1163 | 1163 | ** listening socket, return non-zero. |
| 1164 | 1164 | */ |
| 1165 | 1165 | int cgi_http_server(int mnPort, int mxPort, char *zBrowser){ |
| 1166 | 1166 | #ifdef __MINGW32__ |
| 1167 | 1167 | /* Use win32_http_server() instead */ |
| 1168 | - exit(1); | |
| 1168 | + fossil_exit(1); | |
| 1169 | 1169 | #else |
| 1170 | 1170 | int listener = -1; /* The server socket */ |
| 1171 | 1171 | int connection; /* A socket for each individual connection */ |
| 1172 | 1172 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1173 | 1173 | size_t lenaddr; /* Length of the inaddr structure */ |
| @@ -1253,11 +1253,11 @@ | ||
| 1253 | 1253 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1254 | 1254 | nchildren--; |
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | /* NOT REACHED */ |
| 1258 | - exit(1); | |
| 1258 | + fossil_exit(1); | |
| 1259 | 1259 | #endif |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | |
| 1263 | 1263 | /* |
| @@ -1356,7 +1356,7 @@ | ||
| 1356 | 1356 | if( zIf==0 ) return; |
| 1357 | 1357 | if( objectTime > cgi_rfc822_parsedate(zIf) ) return; |
| 1358 | 1358 | cgi_set_status(304,"Not Modified"); |
| 1359 | 1359 | cgi_reset_content(); |
| 1360 | 1360 | cgi_reply(); |
| 1361 | - exit(0); | |
| 1361 | + fossil_exit(0); | |
| 1362 | 1362 | } |
| 1363 | 1363 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -349,11 +349,11 @@ | |
| 349 | cgi_reset_content(); |
| 350 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); |
| 351 | cgi_set_status(302, "Moved Temporarily"); |
| 352 | free(zLocation); |
| 353 | cgi_reply(); |
| 354 | exit(0); |
| 355 | } |
| 356 | void cgi_redirectf(const char *zFormat, ...){ |
| 357 | va_list ap; |
| 358 | va_start(ap, zFormat); |
| 359 | cgi_redirect(vmprintf(zFormat, ap)); |
| @@ -384,11 +384,11 @@ | |
| 384 | */ |
| 385 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 386 | if( nAllocQP<=nUsedQP ){ |
| 387 | nAllocQP = nAllocQP*2 + 10; |
| 388 | aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); |
| 389 | if( aParamQP==0 ) exit(1); |
| 390 | } |
| 391 | aParamQP[nUsedQP].zName = zName; |
| 392 | aParamQP[nUsedQP].zValue = zValue; |
| 393 | if( g.fHttpTrace ){ |
| 394 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -678,11 +678,11 @@ | |
| 678 | if( len>0 && zType ){ |
| 679 | blob_zero(&g.cgiIn); |
| 680 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 681 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 682 | z = malloc( len+1 ); |
| 683 | if( z==0 ) exit(1); |
| 684 | len = fread(z, 1, len, g.httpIn); |
| 685 | z[len] = 0; |
| 686 | if( zType[0]=='a' ){ |
| 687 | add_param_list(z, '&'); |
| 688 | }else{ |
| @@ -1015,11 +1015,11 @@ | |
| 1015 | cgi_set_status(501, "Not Implemented"); |
| 1016 | cgi_printf( |
| 1017 | "<html><body>Unrecognized HTTP Request</body></html>\n" |
| 1018 | ); |
| 1019 | cgi_reply(); |
| 1020 | exit(0); |
| 1021 | } |
| 1022 | |
| 1023 | /* |
| 1024 | ** Panic and die while processing a webpage. |
| 1025 | */ |
| @@ -1033,11 +1033,11 @@ | |
| 1033 | ); |
| 1034 | va_start(ap, zFormat); |
| 1035 | vxprintf(pContent,zFormat,ap); |
| 1036 | va_end(ap); |
| 1037 | cgi_reply(); |
| 1038 | exit(1); |
| 1039 | } |
| 1040 | |
| 1041 | /* |
| 1042 | ** Remove the first space-delimited token from a string and return |
| 1043 | ** a pointer to it. Add a NULL to the string to terminate the token. |
| @@ -1163,11 +1163,11 @@ | |
| 1163 | ** listening socket, return non-zero. |
| 1164 | */ |
| 1165 | int cgi_http_server(int mnPort, int mxPort, char *zBrowser){ |
| 1166 | #ifdef __MINGW32__ |
| 1167 | /* Use win32_http_server() instead */ |
| 1168 | exit(1); |
| 1169 | #else |
| 1170 | int listener = -1; /* The server socket */ |
| 1171 | int connection; /* A socket for each individual connection */ |
| 1172 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1173 | size_t lenaddr; /* Length of the inaddr structure */ |
| @@ -1253,11 +1253,11 @@ | |
| 1253 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1254 | nchildren--; |
| 1255 | } |
| 1256 | } |
| 1257 | /* NOT REACHED */ |
| 1258 | exit(1); |
| 1259 | #endif |
| 1260 | } |
| 1261 | |
| 1262 | |
| 1263 | /* |
| @@ -1356,7 +1356,7 @@ | |
| 1356 | if( zIf==0 ) return; |
| 1357 | if( objectTime > cgi_rfc822_parsedate(zIf) ) return; |
| 1358 | cgi_set_status(304,"Not Modified"); |
| 1359 | cgi_reset_content(); |
| 1360 | cgi_reply(); |
| 1361 | exit(0); |
| 1362 | } |
| 1363 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -349,11 +349,11 @@ | |
| 349 | cgi_reset_content(); |
| 350 | cgi_printf("<html>\n<p>Redirect to %h</p>\n</html>\n", zURL); |
| 351 | cgi_set_status(302, "Moved Temporarily"); |
| 352 | free(zLocation); |
| 353 | cgi_reply(); |
| 354 | fossil_exit(0); |
| 355 | } |
| 356 | void cgi_redirectf(const char *zFormat, ...){ |
| 357 | va_list ap; |
| 358 | va_start(ap, zFormat); |
| 359 | cgi_redirect(vmprintf(zFormat, ap)); |
| @@ -384,11 +384,11 @@ | |
| 384 | */ |
| 385 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 386 | if( nAllocQP<=nUsedQP ){ |
| 387 | nAllocQP = nAllocQP*2 + 10; |
| 388 | aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); |
| 389 | if( aParamQP==0 ) fossil_exit(1); |
| 390 | } |
| 391 | aParamQP[nUsedQP].zName = zName; |
| 392 | aParamQP[nUsedQP].zValue = zValue; |
| 393 | if( g.fHttpTrace ){ |
| 394 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -678,11 +678,11 @@ | |
| 678 | if( len>0 && zType ){ |
| 679 | blob_zero(&g.cgiIn); |
| 680 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 681 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 682 | z = malloc( len+1 ); |
| 683 | if( z==0 ) fossil_exit(1); |
| 684 | len = fread(z, 1, len, g.httpIn); |
| 685 | z[len] = 0; |
| 686 | if( zType[0]=='a' ){ |
| 687 | add_param_list(z, '&'); |
| 688 | }else{ |
| @@ -1015,11 +1015,11 @@ | |
| 1015 | cgi_set_status(501, "Not Implemented"); |
| 1016 | cgi_printf( |
| 1017 | "<html><body>Unrecognized HTTP Request</body></html>\n" |
| 1018 | ); |
| 1019 | cgi_reply(); |
| 1020 | fossil_exit(0); |
| 1021 | } |
| 1022 | |
| 1023 | /* |
| 1024 | ** Panic and die while processing a webpage. |
| 1025 | */ |
| @@ -1033,11 +1033,11 @@ | |
| 1033 | ); |
| 1034 | va_start(ap, zFormat); |
| 1035 | vxprintf(pContent,zFormat,ap); |
| 1036 | va_end(ap); |
| 1037 | cgi_reply(); |
| 1038 | fossil_exit(1); |
| 1039 | } |
| 1040 | |
| 1041 | /* |
| 1042 | ** Remove the first space-delimited token from a string and return |
| 1043 | ** a pointer to it. Add a NULL to the string to terminate the token. |
| @@ -1163,11 +1163,11 @@ | |
| 1163 | ** listening socket, return non-zero. |
| 1164 | */ |
| 1165 | int cgi_http_server(int mnPort, int mxPort, char *zBrowser){ |
| 1166 | #ifdef __MINGW32__ |
| 1167 | /* Use win32_http_server() instead */ |
| 1168 | fossil_exit(1); |
| 1169 | #else |
| 1170 | int listener = -1; /* The server socket */ |
| 1171 | int connection; /* A socket for each individual connection */ |
| 1172 | fd_set readfds; /* Set of file descriptors for select() */ |
| 1173 | size_t lenaddr; /* Length of the inaddr structure */ |
| @@ -1253,11 +1253,11 @@ | |
| 1253 | while( waitpid(0, 0, WNOHANG)>0 ){ |
| 1254 | nchildren--; |
| 1255 | } |
| 1256 | } |
| 1257 | /* NOT REACHED */ |
| 1258 | fossil_exit(1); |
| 1259 | #endif |
| 1260 | } |
| 1261 | |
| 1262 | |
| 1263 | /* |
| @@ -1356,7 +1356,7 @@ | |
| 1356 | if( zIf==0 ) return; |
| 1357 | if( objectTime > cgi_rfc822_parsedate(zIf) ) return; |
| 1358 | cgi_set_status(304,"Not Modified"); |
| 1359 | cgi_reset_content(); |
| 1360 | cgi_reply(); |
| 1361 | fossil_exit(0); |
| 1362 | } |
| 1363 |
+2
-4
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -691,12 +691,11 @@ | ||
| 691 | 691 | if( blob_size(&comment)==0 ){ |
| 692 | 692 | Blob ans; |
| 693 | 693 | blob_zero(&ans); |
| 694 | 694 | prompt_user("empty check-in comment. continue (y/N)? ", &ans); |
| 695 | 695 | if( blob_str(&ans)[0]!='y' ){ |
| 696 | - db_end_transaction(1); | |
| 697 | - exit(1); | |
| 696 | + fossil_exit(1); | |
| 698 | 697 | } |
| 699 | 698 | }else{ |
| 700 | 699 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 701 | 700 | db_end_transaction(0); |
| 702 | 701 | db_begin_transaction(); |
| @@ -829,12 +828,11 @@ | ||
| 829 | 828 | if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){ |
| 830 | 829 | Blob ans; |
| 831 | 830 | blob_zero(&ans); |
| 832 | 831 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 833 | 832 | if( blob_str(&ans)[0]!='y' ){ |
| 834 | - db_end_transaction(1); | |
| 835 | - exit(1); | |
| 833 | + fossil_exit(1); | |
| 836 | 834 | } |
| 837 | 835 | } |
| 838 | 836 | blob_write_to_file(&manifest, zManifestFile); |
| 839 | 837 | blob_reset(&manifest); |
| 840 | 838 | blob_read_from_file(&manifest, zManifestFile); |
| 841 | 839 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -691,12 +691,11 @@ | |
| 691 | if( blob_size(&comment)==0 ){ |
| 692 | Blob ans; |
| 693 | blob_zero(&ans); |
| 694 | prompt_user("empty check-in comment. continue (y/N)? ", &ans); |
| 695 | if( blob_str(&ans)[0]!='y' ){ |
| 696 | db_end_transaction(1); |
| 697 | exit(1); |
| 698 | } |
| 699 | }else{ |
| 700 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 701 | db_end_transaction(0); |
| 702 | db_begin_transaction(); |
| @@ -829,12 +828,11 @@ | |
| 829 | if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){ |
| 830 | Blob ans; |
| 831 | blob_zero(&ans); |
| 832 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 833 | if( blob_str(&ans)[0]!='y' ){ |
| 834 | db_end_transaction(1); |
| 835 | exit(1); |
| 836 | } |
| 837 | } |
| 838 | blob_write_to_file(&manifest, zManifestFile); |
| 839 | blob_reset(&manifest); |
| 840 | blob_read_from_file(&manifest, zManifestFile); |
| 841 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -691,12 +691,11 @@ | |
| 691 | if( blob_size(&comment)==0 ){ |
| 692 | Blob ans; |
| 693 | blob_zero(&ans); |
| 694 | prompt_user("empty check-in comment. continue (y/N)? ", &ans); |
| 695 | if( blob_str(&ans)[0]!='y' ){ |
| 696 | fossil_exit(1); |
| 697 | } |
| 698 | }else{ |
| 699 | db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment); |
| 700 | db_end_transaction(0); |
| 701 | db_begin_transaction(); |
| @@ -829,12 +828,11 @@ | |
| 828 | if( !noSign && !g.markPrivate && clearsign(&manifest, &manifest) ){ |
| 829 | Blob ans; |
| 830 | blob_zero(&ans); |
| 831 | prompt_user("unable to sign manifest. continue (y/N)? ", &ans); |
| 832 | if( blob_str(&ans)[0]!='y' ){ |
| 833 | fossil_exit(1); |
| 834 | } |
| 835 | } |
| 836 | blob_write_to_file(&manifest, zManifestFile); |
| 837 | blob_reset(&manifest); |
| 838 | blob_read_from_file(&manifest, zManifestFile); |
| 839 |
M
src/db.c
+5
-2
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -73,11 +73,11 @@ | ||
| 73 | 73 | cgi_reply(); |
| 74 | 74 | }else{ |
| 75 | 75 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 76 | 76 | } |
| 77 | 77 | db_force_rollback(); |
| 78 | - exit(1); | |
| 78 | + fossil_exit(1); | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | static int nBegin = 0; /* Nesting depth of BEGIN */ |
| 82 | 82 | static int isNewRepo = 0; /* True if the repository is newly created */ |
| 83 | 83 | static int doRollback = 0; /* True to force a rollback */ |
| @@ -114,10 +114,11 @@ | ||
| 114 | 114 | sqlite3_commit_hook(g.db, db_verify_at_commit, 0); |
| 115 | 115 | } |
| 116 | 116 | nBegin++; |
| 117 | 117 | } |
| 118 | 118 | void db_end_transaction(int rollbackFlag){ |
| 119 | + if( g.db==0 ) return; | |
| 119 | 120 | if( nBegin<=0 ) return; |
| 120 | 121 | if( rollbackFlag ) doRollback = 1; |
| 121 | 122 | nBegin--; |
| 122 | 123 | if( nBegin==0 ){ |
| 123 | 124 | int i; |
| @@ -128,11 +129,11 @@ | ||
| 128 | 129 | doRollback = 0; |
| 129 | 130 | } |
| 130 | 131 | } |
| 131 | 132 | void db_force_rollback(void){ |
| 132 | 133 | static int busy = 0; |
| 133 | - if( busy ) return; | |
| 134 | + if( busy || g.db==0 ) return; | |
| 134 | 135 | busy = 1; |
| 135 | 136 | undo_rollback(); |
| 136 | 137 | if( nBegin ){ |
| 137 | 138 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 138 | 139 | if( isNewRepo ){ |
| @@ -598,10 +599,11 @@ | ||
| 598 | 599 | ); |
| 599 | 600 | if( rc!=SQLITE_OK ){ |
| 600 | 601 | db_err(sqlite3_errmsg(db)); |
| 601 | 602 | } |
| 602 | 603 | sqlite3_busy_timeout(db, 5000); |
| 604 | + sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */ | |
| 603 | 605 | return db; |
| 604 | 606 | } |
| 605 | 607 | |
| 606 | 608 | |
| 607 | 609 | /* |
| @@ -896,10 +898,11 @@ | ||
| 896 | 898 | void db_close(void){ |
| 897 | 899 | if( g.db==0 ) return; |
| 898 | 900 | while( pAllStmt ){ |
| 899 | 901 | db_finalize(pAllStmt); |
| 900 | 902 | } |
| 903 | + db_end_transaction(1); | |
| 901 | 904 | g.repositoryOpen = 0; |
| 902 | 905 | g.localOpen = 0; |
| 903 | 906 | g.configOpen = 0; |
| 904 | 907 | sqlite3_close(g.db); |
| 905 | 908 | g.db = 0; |
| 906 | 909 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | cgi_reply(); |
| 74 | }else{ |
| 75 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 76 | } |
| 77 | db_force_rollback(); |
| 78 | exit(1); |
| 79 | } |
| 80 | |
| 81 | static int nBegin = 0; /* Nesting depth of BEGIN */ |
| 82 | static int isNewRepo = 0; /* True if the repository is newly created */ |
| 83 | static int doRollback = 0; /* True to force a rollback */ |
| @@ -114,10 +114,11 @@ | |
| 114 | sqlite3_commit_hook(g.db, db_verify_at_commit, 0); |
| 115 | } |
| 116 | nBegin++; |
| 117 | } |
| 118 | void db_end_transaction(int rollbackFlag){ |
| 119 | if( nBegin<=0 ) return; |
| 120 | if( rollbackFlag ) doRollback = 1; |
| 121 | nBegin--; |
| 122 | if( nBegin==0 ){ |
| 123 | int i; |
| @@ -128,11 +129,11 @@ | |
| 128 | doRollback = 0; |
| 129 | } |
| 130 | } |
| 131 | void db_force_rollback(void){ |
| 132 | static int busy = 0; |
| 133 | if( busy ) return; |
| 134 | busy = 1; |
| 135 | undo_rollback(); |
| 136 | if( nBegin ){ |
| 137 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 138 | if( isNewRepo ){ |
| @@ -598,10 +599,11 @@ | |
| 598 | ); |
| 599 | if( rc!=SQLITE_OK ){ |
| 600 | db_err(sqlite3_errmsg(db)); |
| 601 | } |
| 602 | sqlite3_busy_timeout(db, 5000); |
| 603 | return db; |
| 604 | } |
| 605 | |
| 606 | |
| 607 | /* |
| @@ -896,10 +898,11 @@ | |
| 896 | void db_close(void){ |
| 897 | if( g.db==0 ) return; |
| 898 | while( pAllStmt ){ |
| 899 | db_finalize(pAllStmt); |
| 900 | } |
| 901 | g.repositoryOpen = 0; |
| 902 | g.localOpen = 0; |
| 903 | g.configOpen = 0; |
| 904 | sqlite3_close(g.db); |
| 905 | g.db = 0; |
| 906 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -73,11 +73,11 @@ | |
| 73 | cgi_reply(); |
| 74 | }else{ |
| 75 | fprintf(stderr, "%s: %s\n\n%s", g.argv[0], z, zRebuildMsg); |
| 76 | } |
| 77 | db_force_rollback(); |
| 78 | fossil_exit(1); |
| 79 | } |
| 80 | |
| 81 | static int nBegin = 0; /* Nesting depth of BEGIN */ |
| 82 | static int isNewRepo = 0; /* True if the repository is newly created */ |
| 83 | static int doRollback = 0; /* True to force a rollback */ |
| @@ -114,10 +114,11 @@ | |
| 114 | sqlite3_commit_hook(g.db, db_verify_at_commit, 0); |
| 115 | } |
| 116 | nBegin++; |
| 117 | } |
| 118 | void db_end_transaction(int rollbackFlag){ |
| 119 | if( g.db==0 ) return; |
| 120 | if( nBegin<=0 ) return; |
| 121 | if( rollbackFlag ) doRollback = 1; |
| 122 | nBegin--; |
| 123 | if( nBegin==0 ){ |
| 124 | int i; |
| @@ -128,11 +129,11 @@ | |
| 129 | doRollback = 0; |
| 130 | } |
| 131 | } |
| 132 | void db_force_rollback(void){ |
| 133 | static int busy = 0; |
| 134 | if( busy || g.db==0 ) return; |
| 135 | busy = 1; |
| 136 | undo_rollback(); |
| 137 | if( nBegin ){ |
| 138 | sqlite3_exec(g.db, "ROLLBACK", 0, 0, 0); |
| 139 | if( isNewRepo ){ |
| @@ -598,10 +599,11 @@ | |
| 599 | ); |
| 600 | if( rc!=SQLITE_OK ){ |
| 601 | db_err(sqlite3_errmsg(db)); |
| 602 | } |
| 603 | sqlite3_busy_timeout(db, 5000); |
| 604 | sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */ |
| 605 | return db; |
| 606 | } |
| 607 | |
| 608 | |
| 609 | /* |
| @@ -896,10 +898,11 @@ | |
| 898 | void db_close(void){ |
| 899 | if( g.db==0 ) return; |
| 900 | while( pAllStmt ){ |
| 901 | db_finalize(pAllStmt); |
| 902 | } |
| 903 | db_end_transaction(1); |
| 904 | g.repositoryOpen = 0; |
| 905 | g.localOpen = 0; |
| 906 | g.configOpen = 0; |
| 907 | sqlite3_close(g.db); |
| 908 | g.db = 0; |
| 909 |
+8
-8
| --- src/deltacmd.c | ||
| +++ src/deltacmd.c | ||
| @@ -50,24 +50,24 @@ | ||
| 50 | 50 | */ |
| 51 | 51 | void delta_create_cmd(void){ |
| 52 | 52 | Blob orig, target, delta; |
| 53 | 53 | if( g.argc!=5 ){ |
| 54 | 54 | fprintf(stderr,"Usage: %s %s ORIGIN TARGET DELTA\n", g.argv[0], g.argv[1]); |
| 55 | - exit(1); | |
| 55 | + fossil_exit(1); | |
| 56 | 56 | } |
| 57 | 57 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 58 | 58 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 59 | - exit(1); | |
| 59 | + fossil_exit(1); | |
| 60 | 60 | } |
| 61 | 61 | if( blob_read_from_file(&target, g.argv[3])<0 ){ |
| 62 | 62 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 63 | - exit(1); | |
| 63 | + fossil_exit(1); | |
| 64 | 64 | } |
| 65 | 65 | blob_delta_create(&orig, &target, &delta); |
| 66 | 66 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 67 | 67 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 68 | - exit(1); | |
| 68 | + fossil_exit(1); | |
| 69 | 69 | } |
| 70 | 70 | blob_reset(&orig); |
| 71 | 71 | blob_reset(&target); |
| 72 | 72 | blob_reset(&delta); |
| 73 | 73 | } |
| @@ -113,24 +113,24 @@ | ||
| 113 | 113 | */ |
| 114 | 114 | void delta_apply_cmd(void){ |
| 115 | 115 | Blob orig, target, delta; |
| 116 | 116 | if( g.argc!=5 ){ |
| 117 | 117 | fprintf(stderr,"Usage: %s %s ORIGIN DELTA TARGET\n", g.argv[0], g.argv[1]); |
| 118 | - exit(1); | |
| 118 | + fossil_exit(1); | |
| 119 | 119 | } |
| 120 | 120 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 121 | 121 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 122 | - exit(1); | |
| 122 | + fossil_exit(1); | |
| 123 | 123 | } |
| 124 | 124 | if( blob_read_from_file(&delta, g.argv[3])<0 ){ |
| 125 | 125 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 126 | - exit(1); | |
| 126 | + fossil_exit(1); | |
| 127 | 127 | } |
| 128 | 128 | blob_delta_apply(&orig, &delta, &target); |
| 129 | 129 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 130 | 130 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 131 | - exit(1); | |
| 131 | + fossil_exit(1); | |
| 132 | 132 | } |
| 133 | 133 | blob_reset(&orig); |
| 134 | 134 | blob_reset(&target); |
| 135 | 135 | blob_reset(&delta); |
| 136 | 136 | } |
| 137 | 137 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -50,24 +50,24 @@ | |
| 50 | */ |
| 51 | void delta_create_cmd(void){ |
| 52 | Blob orig, target, delta; |
| 53 | if( g.argc!=5 ){ |
| 54 | fprintf(stderr,"Usage: %s %s ORIGIN TARGET DELTA\n", g.argv[0], g.argv[1]); |
| 55 | exit(1); |
| 56 | } |
| 57 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 58 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 59 | exit(1); |
| 60 | } |
| 61 | if( blob_read_from_file(&target, g.argv[3])<0 ){ |
| 62 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 63 | exit(1); |
| 64 | } |
| 65 | blob_delta_create(&orig, &target, &delta); |
| 66 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 67 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 68 | exit(1); |
| 69 | } |
| 70 | blob_reset(&orig); |
| 71 | blob_reset(&target); |
| 72 | blob_reset(&delta); |
| 73 | } |
| @@ -113,24 +113,24 @@ | |
| 113 | */ |
| 114 | void delta_apply_cmd(void){ |
| 115 | Blob orig, target, delta; |
| 116 | if( g.argc!=5 ){ |
| 117 | fprintf(stderr,"Usage: %s %s ORIGIN DELTA TARGET\n", g.argv[0], g.argv[1]); |
| 118 | exit(1); |
| 119 | } |
| 120 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 121 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 122 | exit(1); |
| 123 | } |
| 124 | if( blob_read_from_file(&delta, g.argv[3])<0 ){ |
| 125 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 126 | exit(1); |
| 127 | } |
| 128 | blob_delta_apply(&orig, &delta, &target); |
| 129 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 130 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 131 | exit(1); |
| 132 | } |
| 133 | blob_reset(&orig); |
| 134 | blob_reset(&target); |
| 135 | blob_reset(&delta); |
| 136 | } |
| 137 |
| --- src/deltacmd.c | |
| +++ src/deltacmd.c | |
| @@ -50,24 +50,24 @@ | |
| 50 | */ |
| 51 | void delta_create_cmd(void){ |
| 52 | Blob orig, target, delta; |
| 53 | if( g.argc!=5 ){ |
| 54 | fprintf(stderr,"Usage: %s %s ORIGIN TARGET DELTA\n", g.argv[0], g.argv[1]); |
| 55 | fossil_exit(1); |
| 56 | } |
| 57 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 58 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 59 | fossil_exit(1); |
| 60 | } |
| 61 | if( blob_read_from_file(&target, g.argv[3])<0 ){ |
| 62 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 63 | fossil_exit(1); |
| 64 | } |
| 65 | blob_delta_create(&orig, &target, &delta); |
| 66 | if( blob_write_to_file(&delta, g.argv[4])<blob_size(&delta) ){ |
| 67 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 68 | fossil_exit(1); |
| 69 | } |
| 70 | blob_reset(&orig); |
| 71 | blob_reset(&target); |
| 72 | blob_reset(&delta); |
| 73 | } |
| @@ -113,24 +113,24 @@ | |
| 113 | */ |
| 114 | void delta_apply_cmd(void){ |
| 115 | Blob orig, target, delta; |
| 116 | if( g.argc!=5 ){ |
| 117 | fprintf(stderr,"Usage: %s %s ORIGIN DELTA TARGET\n", g.argv[0], g.argv[1]); |
| 118 | fossil_exit(1); |
| 119 | } |
| 120 | if( blob_read_from_file(&orig, g.argv[2])<0 ){ |
| 121 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 122 | fossil_exit(1); |
| 123 | } |
| 124 | if( blob_read_from_file(&delta, g.argv[3])<0 ){ |
| 125 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 126 | fossil_exit(1); |
| 127 | } |
| 128 | blob_delta_apply(&orig, &delta, &target); |
| 129 | if( blob_write_to_file(&target, g.argv[4])<blob_size(&target) ){ |
| 130 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 131 | fossil_exit(1); |
| 132 | } |
| 133 | blob_reset(&orig); |
| 134 | blob_reset(&target); |
| 135 | blob_reset(&delta); |
| 136 | } |
| 137 |
+2
-2
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -278,11 +278,11 @@ | ||
| 278 | 278 | blob_materialize(pOut); |
| 279 | 279 | }else{ |
| 280 | 280 | char zPwd[2000]; |
| 281 | 281 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 282 | 282 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 283 | - exit(1); | |
| 283 | + fossil_exit(1); | |
| 284 | 284 | } |
| 285 | 285 | blob_zero(pOut); |
| 286 | 286 | blob_appendf(pOut, "%//%/", zPwd, zOrigName); |
| 287 | 287 | } |
| 288 | 288 | blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); |
| @@ -343,11 +343,11 @@ | ||
| 343 | 343 | int i, j; |
| 344 | 344 | Blob tmp; |
| 345 | 345 | char zPwd[2000]; |
| 346 | 346 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 347 | 347 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 348 | - exit(1); | |
| 348 | + fossil_exit(1); | |
| 349 | 349 | } |
| 350 | 350 | for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){} |
| 351 | 351 | if( zPath[i]==0 ){ |
| 352 | 352 | blob_reset(pOut); |
| 353 | 353 | if( zPwd[i]==0 ){ |
| 354 | 354 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -278,11 +278,11 @@ | |
| 278 | blob_materialize(pOut); |
| 279 | }else{ |
| 280 | char zPwd[2000]; |
| 281 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 282 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 283 | exit(1); |
| 284 | } |
| 285 | blob_zero(pOut); |
| 286 | blob_appendf(pOut, "%//%/", zPwd, zOrigName); |
| 287 | } |
| 288 | blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); |
| @@ -343,11 +343,11 @@ | |
| 343 | int i, j; |
| 344 | Blob tmp; |
| 345 | char zPwd[2000]; |
| 346 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 347 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 348 | exit(1); |
| 349 | } |
| 350 | for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){} |
| 351 | if( zPath[i]==0 ){ |
| 352 | blob_reset(pOut); |
| 353 | if( zPwd[i]==0 ){ |
| 354 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -278,11 +278,11 @@ | |
| 278 | blob_materialize(pOut); |
| 279 | }else{ |
| 280 | char zPwd[2000]; |
| 281 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 282 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 283 | fossil_exit(1); |
| 284 | } |
| 285 | blob_zero(pOut); |
| 286 | blob_appendf(pOut, "%//%/", zPwd, zOrigName); |
| 287 | } |
| 288 | blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut))); |
| @@ -343,11 +343,11 @@ | |
| 343 | int i, j; |
| 344 | Blob tmp; |
| 345 | char zPwd[2000]; |
| 346 | if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){ |
| 347 | fprintf(stderr, "pwd too big: max %d\n", (int)sizeof(zPwd)-20); |
| 348 | fossil_exit(1); |
| 349 | } |
| 350 | for(i=1; zPath[i] && zPwd[i]==zPath[i]; i++){} |
| 351 | if( zPath[i]==0 ){ |
| 352 | blob_reset(pOut); |
| 353 | if( zPwd[i]==0 ){ |
| 354 |
+18
-8
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -217,11 +217,11 @@ | ||
| 217 | 217 | |
| 218 | 218 | /* |
| 219 | 219 | ** This procedure runs first. |
| 220 | 220 | */ |
| 221 | 221 | int main(int argc, char **argv){ |
| 222 | - const char *zCmdName; | |
| 222 | + const char *zCmdName = "unknown"; | |
| 223 | 223 | int idx; |
| 224 | 224 | int rc; |
| 225 | 225 | |
| 226 | 226 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 227 | 227 | g.now = time(0); |
| @@ -229,11 +229,11 @@ | ||
| 229 | 229 | g.argv = argv; |
| 230 | 230 | if( getenv("GATEWAY_INTERFACE")!=0 ){ |
| 231 | 231 | zCmdName = "cgi"; |
| 232 | 232 | }else if( argc<2 ){ |
| 233 | 233 | fprintf(stderr, "Usage: %s COMMAND ...\n", argv[0]); |
| 234 | - exit(1); | |
| 234 | + fossil_exit(1); | |
| 235 | 235 | }else{ |
| 236 | 236 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 237 | 237 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 238 | 238 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 239 | 239 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| @@ -243,27 +243,37 @@ | ||
| 243 | 243 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 244 | 244 | if( rc==1 ){ |
| 245 | 245 | fprintf(stderr,"%s: unknown command: %s\n" |
| 246 | 246 | "%s: use \"help\" for more information\n", |
| 247 | 247 | argv[0], zCmdName, argv[0]); |
| 248 | - return 1; | |
| 248 | + fossil_exit(1); | |
| 249 | 249 | }else if( rc==2 ){ |
| 250 | 250 | fprintf(stderr,"%s: ambiguous command prefix: %s\n" |
| 251 | 251 | "%s: use \"help\" for more information\n", |
| 252 | 252 | argv[0], zCmdName, argv[0]); |
| 253 | - return 1; | |
| 253 | + fossil_exit(1); | |
| 254 | 254 | } |
| 255 | 255 | aCommand[idx].xFunc(); |
| 256 | + fossil_exit(0); | |
| 257 | + /*NOT_REACHED*/ | |
| 256 | 258 | return 0; |
| 257 | 259 | } |
| 258 | 260 | |
| 259 | 261 | /* |
| 260 | 262 | ** The following variable becomes true while processing a fatal error |
| 261 | 263 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 262 | 264 | ** shutting down, the recursive errors are silently ignored. |
| 263 | 265 | */ |
| 264 | 266 | static int mainInFatalError = 0; |
| 267 | + | |
| 268 | +/* | |
| 269 | +** Exit. Take care to close the database first. | |
| 270 | +*/ | |
| 271 | +void fossil_exit(int rc){ | |
| 272 | + db_close(); | |
| 273 | + exit(rc); | |
| 274 | +} | |
| 265 | 275 | |
| 266 | 276 | /* |
| 267 | 277 | ** Print an error message, rollback all databases, and quit. These |
| 268 | 278 | ** routines never return. |
| 269 | 279 | */ |
| @@ -281,11 +291,11 @@ | ||
| 281 | 291 | cgi_reply(); |
| 282 | 292 | }else{ |
| 283 | 293 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 284 | 294 | } |
| 285 | 295 | db_force_rollback(); |
| 286 | - exit(1); | |
| 296 | + fossil_exit(1); | |
| 287 | 297 | } |
| 288 | 298 | void fossil_fatal(const char *zFormat, ...){ |
| 289 | 299 | char *z; |
| 290 | 300 | va_list ap; |
| 291 | 301 | mainInFatalError = 1; |
| @@ -298,11 +308,11 @@ | ||
| 298 | 308 | cgi_reply(); |
| 299 | 309 | }else{ |
| 300 | 310 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 301 | 311 | } |
| 302 | 312 | db_force_rollback(); |
| 303 | - exit(1); | |
| 313 | + fossil_exit(1); | |
| 304 | 314 | } |
| 305 | 315 | |
| 306 | 316 | /* This routine works like fossil_fatal() except that if called |
| 307 | 317 | ** recursively, the recursive call is a no-op. |
| 308 | 318 | ** |
| @@ -326,11 +336,11 @@ | ||
| 326 | 336 | cgi_reply(); |
| 327 | 337 | }else{ |
| 328 | 338 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 329 | 339 | } |
| 330 | 340 | db_force_rollback(); |
| 331 | - exit(1); | |
| 341 | + fossil_exit(1); | |
| 332 | 342 | } |
| 333 | 343 | |
| 334 | 344 | |
| 335 | 345 | /* Print a warning message */ |
| 336 | 346 | void fossil_warning(const char *zFormat, ...){ |
| @@ -389,11 +399,11 @@ | ||
| 389 | 399 | /* |
| 390 | 400 | ** Print a usage comment and quit |
| 391 | 401 | */ |
| 392 | 402 | void usage(const char *zFormat){ |
| 393 | 403 | fprintf(stderr, "Usage: %s %s %s\n", g.argv[0], g.argv[1], zFormat); |
| 394 | - exit(1); | |
| 404 | + fossil_exit(1); | |
| 395 | 405 | } |
| 396 | 406 | |
| 397 | 407 | /* |
| 398 | 408 | ** Remove n elements from g.argv beginning with the i-th element. |
| 399 | 409 | */ |
| 400 | 410 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -217,11 +217,11 @@ | |
| 217 | |
| 218 | /* |
| 219 | ** This procedure runs first. |
| 220 | */ |
| 221 | int main(int argc, char **argv){ |
| 222 | const char *zCmdName; |
| 223 | int idx; |
| 224 | int rc; |
| 225 | |
| 226 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 227 | g.now = time(0); |
| @@ -229,11 +229,11 @@ | |
| 229 | g.argv = argv; |
| 230 | if( getenv("GATEWAY_INTERFACE")!=0 ){ |
| 231 | zCmdName = "cgi"; |
| 232 | }else if( argc<2 ){ |
| 233 | fprintf(stderr, "Usage: %s COMMAND ...\n", argv[0]); |
| 234 | exit(1); |
| 235 | }else{ |
| 236 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 237 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 238 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 239 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| @@ -243,27 +243,37 @@ | |
| 243 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 244 | if( rc==1 ){ |
| 245 | fprintf(stderr,"%s: unknown command: %s\n" |
| 246 | "%s: use \"help\" for more information\n", |
| 247 | argv[0], zCmdName, argv[0]); |
| 248 | return 1; |
| 249 | }else if( rc==2 ){ |
| 250 | fprintf(stderr,"%s: ambiguous command prefix: %s\n" |
| 251 | "%s: use \"help\" for more information\n", |
| 252 | argv[0], zCmdName, argv[0]); |
| 253 | return 1; |
| 254 | } |
| 255 | aCommand[idx].xFunc(); |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | /* |
| 260 | ** The following variable becomes true while processing a fatal error |
| 261 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 262 | ** shutting down, the recursive errors are silently ignored. |
| 263 | */ |
| 264 | static int mainInFatalError = 0; |
| 265 | |
| 266 | /* |
| 267 | ** Print an error message, rollback all databases, and quit. These |
| 268 | ** routines never return. |
| 269 | */ |
| @@ -281,11 +291,11 @@ | |
| 281 | cgi_reply(); |
| 282 | }else{ |
| 283 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 284 | } |
| 285 | db_force_rollback(); |
| 286 | exit(1); |
| 287 | } |
| 288 | void fossil_fatal(const char *zFormat, ...){ |
| 289 | char *z; |
| 290 | va_list ap; |
| 291 | mainInFatalError = 1; |
| @@ -298,11 +308,11 @@ | |
| 298 | cgi_reply(); |
| 299 | }else{ |
| 300 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 301 | } |
| 302 | db_force_rollback(); |
| 303 | exit(1); |
| 304 | } |
| 305 | |
| 306 | /* This routine works like fossil_fatal() except that if called |
| 307 | ** recursively, the recursive call is a no-op. |
| 308 | ** |
| @@ -326,11 +336,11 @@ | |
| 326 | cgi_reply(); |
| 327 | }else{ |
| 328 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 329 | } |
| 330 | db_force_rollback(); |
| 331 | exit(1); |
| 332 | } |
| 333 | |
| 334 | |
| 335 | /* Print a warning message */ |
| 336 | void fossil_warning(const char *zFormat, ...){ |
| @@ -389,11 +399,11 @@ | |
| 389 | /* |
| 390 | ** Print a usage comment and quit |
| 391 | */ |
| 392 | void usage(const char *zFormat){ |
| 393 | fprintf(stderr, "Usage: %s %s %s\n", g.argv[0], g.argv[1], zFormat); |
| 394 | exit(1); |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 | ** Remove n elements from g.argv beginning with the i-th element. |
| 399 | */ |
| 400 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -217,11 +217,11 @@ | |
| 217 | |
| 218 | /* |
| 219 | ** This procedure runs first. |
| 220 | */ |
| 221 | int main(int argc, char **argv){ |
| 222 | const char *zCmdName = "unknown"; |
| 223 | int idx; |
| 224 | int rc; |
| 225 | |
| 226 | sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); |
| 227 | g.now = time(0); |
| @@ -229,11 +229,11 @@ | |
| 229 | g.argv = argv; |
| 230 | if( getenv("GATEWAY_INTERFACE")!=0 ){ |
| 231 | zCmdName = "cgi"; |
| 232 | }else if( argc<2 ){ |
| 233 | fprintf(stderr, "Usage: %s COMMAND ...\n", argv[0]); |
| 234 | fossil_exit(1); |
| 235 | }else{ |
| 236 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 237 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 238 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 239 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| @@ -243,27 +243,37 @@ | |
| 243 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 244 | if( rc==1 ){ |
| 245 | fprintf(stderr,"%s: unknown command: %s\n" |
| 246 | "%s: use \"help\" for more information\n", |
| 247 | argv[0], zCmdName, argv[0]); |
| 248 | fossil_exit(1); |
| 249 | }else if( rc==2 ){ |
| 250 | fprintf(stderr,"%s: ambiguous command prefix: %s\n" |
| 251 | "%s: use \"help\" for more information\n", |
| 252 | argv[0], zCmdName, argv[0]); |
| 253 | fossil_exit(1); |
| 254 | } |
| 255 | aCommand[idx].xFunc(); |
| 256 | fossil_exit(0); |
| 257 | /*NOT_REACHED*/ |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | /* |
| 262 | ** The following variable becomes true while processing a fatal error |
| 263 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 264 | ** shutting down, the recursive errors are silently ignored. |
| 265 | */ |
| 266 | static int mainInFatalError = 0; |
| 267 | |
| 268 | /* |
| 269 | ** Exit. Take care to close the database first. |
| 270 | */ |
| 271 | void fossil_exit(int rc){ |
| 272 | db_close(); |
| 273 | exit(rc); |
| 274 | } |
| 275 | |
| 276 | /* |
| 277 | ** Print an error message, rollback all databases, and quit. These |
| 278 | ** routines never return. |
| 279 | */ |
| @@ -281,11 +291,11 @@ | |
| 291 | cgi_reply(); |
| 292 | }else{ |
| 293 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 294 | } |
| 295 | db_force_rollback(); |
| 296 | fossil_exit(1); |
| 297 | } |
| 298 | void fossil_fatal(const char *zFormat, ...){ |
| 299 | char *z; |
| 300 | va_list ap; |
| 301 | mainInFatalError = 1; |
| @@ -298,11 +308,11 @@ | |
| 308 | cgi_reply(); |
| 309 | }else{ |
| 310 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 311 | } |
| 312 | db_force_rollback(); |
| 313 | fossil_exit(1); |
| 314 | } |
| 315 | |
| 316 | /* This routine works like fossil_fatal() except that if called |
| 317 | ** recursively, the recursive call is a no-op. |
| 318 | ** |
| @@ -326,11 +336,11 @@ | |
| 336 | cgi_reply(); |
| 337 | }else{ |
| 338 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 339 | } |
| 340 | db_force_rollback(); |
| 341 | fossil_exit(1); |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /* Print a warning message */ |
| 346 | void fossil_warning(const char *zFormat, ...){ |
| @@ -389,11 +399,11 @@ | |
| 399 | /* |
| 400 | ** Print a usage comment and quit |
| 401 | */ |
| 402 | void usage(const char *zFormat){ |
| 403 | fprintf(stderr, "Usage: %s %s %s\n", g.argv[0], g.argv[1], zFormat); |
| 404 | fossil_exit(1); |
| 405 | } |
| 406 | |
| 407 | /* |
| 408 | ** Remove n elements from g.argv beginning with the i-th element. |
| 409 | */ |
| 410 |
+5
-5
| --- src/merge3.c | ||
| +++ src/merge3.c | ||
| @@ -303,28 +303,28 @@ | ||
| 303 | 303 | */ |
| 304 | 304 | void delta_3waymerge_cmd(void){ |
| 305 | 305 | Blob pivot, v1, v2, merged; |
| 306 | 306 | if( g.argc!=6 ){ |
| 307 | 307 | fprintf(stderr,"Usage: %s %s PIVOT V1 V2 MERGED\n", g.argv[0], g.argv[1]); |
| 308 | - exit(1); | |
| 308 | + fossil_exit(1); | |
| 309 | 309 | } |
| 310 | 310 | if( blob_read_from_file(&pivot, g.argv[2])<0 ){ |
| 311 | 311 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 312 | - exit(1); | |
| 312 | + fossil_exit(1); | |
| 313 | 313 | } |
| 314 | 314 | if( blob_read_from_file(&v1, g.argv[3])<0 ){ |
| 315 | 315 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 316 | - exit(1); | |
| 316 | + fossil_exit(1); | |
| 317 | 317 | } |
| 318 | 318 | if( blob_read_from_file(&v2, g.argv[4])<0 ){ |
| 319 | 319 | fprintf(stderr,"cannot read %s\n", g.argv[4]); |
| 320 | - exit(1); | |
| 320 | + fossil_exit(1); | |
| 321 | 321 | } |
| 322 | 322 | blob_merge(&pivot, &v1, &v2, &merged); |
| 323 | 323 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 324 | 324 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 325 | - exit(1); | |
| 325 | + fossil_exit(1); | |
| 326 | 326 | } |
| 327 | 327 | blob_reset(&pivot); |
| 328 | 328 | blob_reset(&v1); |
| 329 | 329 | blob_reset(&v2); |
| 330 | 330 | blob_reset(&merged); |
| 331 | 331 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -303,28 +303,28 @@ | |
| 303 | */ |
| 304 | void delta_3waymerge_cmd(void){ |
| 305 | Blob pivot, v1, v2, merged; |
| 306 | if( g.argc!=6 ){ |
| 307 | fprintf(stderr,"Usage: %s %s PIVOT V1 V2 MERGED\n", g.argv[0], g.argv[1]); |
| 308 | exit(1); |
| 309 | } |
| 310 | if( blob_read_from_file(&pivot, g.argv[2])<0 ){ |
| 311 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 312 | exit(1); |
| 313 | } |
| 314 | if( blob_read_from_file(&v1, g.argv[3])<0 ){ |
| 315 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 316 | exit(1); |
| 317 | } |
| 318 | if( blob_read_from_file(&v2, g.argv[4])<0 ){ |
| 319 | fprintf(stderr,"cannot read %s\n", g.argv[4]); |
| 320 | exit(1); |
| 321 | } |
| 322 | blob_merge(&pivot, &v1, &v2, &merged); |
| 323 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 324 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 325 | exit(1); |
| 326 | } |
| 327 | blob_reset(&pivot); |
| 328 | blob_reset(&v1); |
| 329 | blob_reset(&v2); |
| 330 | blob_reset(&merged); |
| 331 |
| --- src/merge3.c | |
| +++ src/merge3.c | |
| @@ -303,28 +303,28 @@ | |
| 303 | */ |
| 304 | void delta_3waymerge_cmd(void){ |
| 305 | Blob pivot, v1, v2, merged; |
| 306 | if( g.argc!=6 ){ |
| 307 | fprintf(stderr,"Usage: %s %s PIVOT V1 V2 MERGED\n", g.argv[0], g.argv[1]); |
| 308 | fossil_exit(1); |
| 309 | } |
| 310 | if( blob_read_from_file(&pivot, g.argv[2])<0 ){ |
| 311 | fprintf(stderr,"cannot read %s\n", g.argv[2]); |
| 312 | fossil_exit(1); |
| 313 | } |
| 314 | if( blob_read_from_file(&v1, g.argv[3])<0 ){ |
| 315 | fprintf(stderr,"cannot read %s\n", g.argv[3]); |
| 316 | fossil_exit(1); |
| 317 | } |
| 318 | if( blob_read_from_file(&v2, g.argv[4])<0 ){ |
| 319 | fprintf(stderr,"cannot read %s\n", g.argv[4]); |
| 320 | fossil_exit(1); |
| 321 | } |
| 322 | blob_merge(&pivot, &v1, &v2, &merged); |
| 323 | if( blob_write_to_file(&merged, g.argv[5])<blob_size(&merged) ){ |
| 324 | fprintf(stderr,"cannot write %s\n", g.argv[4]); |
| 325 | fossil_exit(1); |
| 326 | } |
| 327 | blob_reset(&pivot); |
| 328 | blob_reset(&v1); |
| 329 | blob_reset(&v2); |
| 330 | blob_reset(&merged); |
| 331 |
-1
| --- src/name.c | ||
| +++ src/name.c | ||
| @@ -365,6 +365,5 @@ | ||
| 365 | 365 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name); |
| 366 | 366 | blob_reset(&name); |
| 367 | 367 | } |
| 368 | 368 | return rid; |
| 369 | 369 | } |
| 370 | - | |
| 371 | 370 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -365,6 +365,5 @@ | |
| 365 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name); |
| 366 | blob_reset(&name); |
| 367 | } |
| 368 | return rid; |
| 369 | } |
| 370 | |
| 371 |
| --- src/name.c | |
| +++ src/name.c | |
| @@ -365,6 +365,5 @@ | |
| 365 | rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name); |
| 366 | blob_reset(&name); |
| 367 | } |
| 368 | return rid; |
| 369 | } |
| 370 |
+1
-1
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -374,11 +374,11 @@ | ||
| 374 | 374 | blob_zero(&ans); |
| 375 | 375 | prompt_user("Scrubbing the repository will permanently remove user\n" |
| 376 | 376 | "passwords and other information. Changes cannot be undone.\n" |
| 377 | 377 | "Continue (y/N)? ", &ans); |
| 378 | 378 | if( blob_str(&ans)[0]!='y' ){ |
| 379 | - exit(1); | |
| 379 | + fossil_exit(1); | |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | db_begin_transaction(); |
| 383 | 383 | db_multi_exec( |
| 384 | 384 | "UPDATE user SET pw='';" |
| 385 | 385 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -374,11 +374,11 @@ | |
| 374 | blob_zero(&ans); |
| 375 | prompt_user("Scrubbing the repository will permanently remove user\n" |
| 376 | "passwords and other information. Changes cannot be undone.\n" |
| 377 | "Continue (y/N)? ", &ans); |
| 378 | if( blob_str(&ans)[0]!='y' ){ |
| 379 | exit(1); |
| 380 | } |
| 381 | } |
| 382 | db_begin_transaction(); |
| 383 | db_multi_exec( |
| 384 | "UPDATE user SET pw='';" |
| 385 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -374,11 +374,11 @@ | |
| 374 | blob_zero(&ans); |
| 375 | prompt_user("Scrubbing the repository will permanently remove user\n" |
| 376 | "passwords and other information. Changes cannot be undone.\n" |
| 377 | "Continue (y/N)? ", &ans); |
| 378 | if( blob_str(&ans)[0]!='y' ){ |
| 379 | fossil_exit(1); |
| 380 | } |
| 381 | } |
| 382 | db_begin_transaction(); |
| 383 | db_multi_exec( |
| 384 | "UPDATE user SET pw='';" |
| 385 |
+1
-1
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -99,11 +99,11 @@ | ||
| 99 | 99 | if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN; |
| 100 | 100 | }else if( g.argc==3 ){ |
| 101 | 101 | zUrl = g.argv[2]; |
| 102 | 102 | } |
| 103 | 103 | if( zUrl==0 ){ |
| 104 | - if( urlOptional ) exit(0); | |
| 104 | + if( urlOptional ) fossil_exit(0); | |
| 105 | 105 | usage("URL"); |
| 106 | 106 | } |
| 107 | 107 | url_parse(zUrl); |
| 108 | 108 | if( !g.dontKeepUrl ){ |
| 109 | 109 | db_set("last-sync-url", g.urlCanonical, 0); |
| 110 | 110 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -99,11 +99,11 @@ | |
| 99 | if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN; |
| 100 | }else if( g.argc==3 ){ |
| 101 | zUrl = g.argv[2]; |
| 102 | } |
| 103 | if( zUrl==0 ){ |
| 104 | if( urlOptional ) exit(0); |
| 105 | usage("URL"); |
| 106 | } |
| 107 | url_parse(zUrl); |
| 108 | if( !g.dontKeepUrl ){ |
| 109 | db_set("last-sync-url", g.urlCanonical, 0); |
| 110 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -99,11 +99,11 @@ | |
| 99 | if( db_get_boolean("auto-sync",1) ) configSync = CONFIGSET_SHUN; |
| 100 | }else if( g.argc==3 ){ |
| 101 | zUrl = g.argv[2]; |
| 102 | } |
| 103 | if( zUrl==0 ){ |
| 104 | if( urlOptional ) fossil_exit(0); |
| 105 | usage("URL"); |
| 106 | } |
| 107 | url_parse(zUrl); |
| 108 | if( !g.dontKeepUrl ){ |
| 109 | db_set("last-sync-url", g.urlCanonical, 0); |
| 110 |