Fossil SCM

Fix 'fossil sync' with local file URIs (and SCGI URIs on Windows) while retaining the 'fossil ui' enhancements that permit using an open checkout (e.g. to resolve the symbolic names prev, next, and current).

mistachkin 2014-09-16 02:44 trunk
Commit 1f8a4ecdb77e123ab75678d344e39c28e4849737
+2
--- src/cgi.c
+++ src/cgi.c
@@ -1626,10 +1626,12 @@
16261626
/*
16271627
** Bitmap values for the flags parameter to cgi_http_server().
16281628
*/
16291629
#define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */
16301630
#define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */
1631
+#define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */
1632
+#define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */
16311633
16321634
#endif /* INTERFACE */
16331635
16341636
/*
16351637
** Maximum number of child processes that we can have running
16361638
--- src/cgi.c
+++ src/cgi.c
@@ -1626,10 +1626,12 @@
1626 /*
1627 ** Bitmap values for the flags parameter to cgi_http_server().
1628 */
1629 #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */
1630 #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */
 
 
1631
1632 #endif /* INTERFACE */
1633
1634 /*
1635 ** Maximum number of child processes that we can have running
1636
--- src/cgi.c
+++ src/cgi.c
@@ -1626,10 +1626,12 @@
1626 /*
1627 ** Bitmap values for the flags parameter to cgi_http_server().
1628 */
1629 #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */
1630 #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */
1631 #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */
1632 #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */
1633
1634 #endif /* INTERFACE */
1635
1636 /*
1637 ** Maximum number of child processes that we can have running
1638
--- src/http_transport.c
+++ src/http_transport.c
@@ -257,12 +257,12 @@
257257
*/
258258
void transport_flip(UrlData *pUrlData){
259259
if( pUrlData->isFile ){
260260
char *zCmd;
261261
fclose(transport.pFile);
262
- zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
263
- g.nameOfExe, pUrlData->name, transport.zOutFile, transport.zInFile
262
+ zCmd = mprintf("\"%s\" http \"%s\" \"%s\" 127.0.0.1 \"%s\" --localauth",
263
+ g.nameOfExe, transport.zOutFile, transport.zInFile, pUrlData->name
264264
);
265265
fossil_system(zCmd);
266266
free(zCmd);
267267
transport.pFile = fossil_fopen(transport.zInFile, "rb");
268268
}
269269
--- src/http_transport.c
+++ src/http_transport.c
@@ -257,12 +257,12 @@
257 */
258 void transport_flip(UrlData *pUrlData){
259 if( pUrlData->isFile ){
260 char *zCmd;
261 fclose(transport.pFile);
262 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1 --localauth",
263 g.nameOfExe, pUrlData->name, transport.zOutFile, transport.zInFile
264 );
265 fossil_system(zCmd);
266 free(zCmd);
267 transport.pFile = fossil_fopen(transport.zInFile, "rb");
268 }
269
--- src/http_transport.c
+++ src/http_transport.c
@@ -257,12 +257,12 @@
257 */
258 void transport_flip(UrlData *pUrlData){
259 if( pUrlData->isFile ){
260 char *zCmd;
261 fclose(transport.pFile);
262 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" 127.0.0.1 \"%s\" --localauth",
263 g.nameOfExe, transport.zOutFile, transport.zInFile, pUrlData->name
264 );
265 fossil_system(zCmd);
266 free(zCmd);
267 transport.pFile = fossil_fopen(transport.zInFile, "rb");
268 }
269
+4
--- src/main.c
+++ src/main.c
@@ -2195,10 +2195,12 @@
21952195
if( zIpAddr ){
21962196
zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
21972197
}else{
21982198
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
21992199
}
2200
+ if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201
+ if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
22002202
}
22012203
db_close(1);
22022204
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
22032205
fossil_fatal("unable to listen on TCP socket %d", iPort);
22042206
}
@@ -2224,10 +2226,12 @@
22242226
if( zIpAddr ){
22252227
zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
22262228
}else{
22272229
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
22282230
}
2231
+ if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2232
+ if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
22292233
}
22302234
db_close(1);
22312235
if( win32_http_service(iPort, zNotFound, zFileGlob, flags) ){
22322236
win32_http_server(iPort, mxPort, zBrowserCmd,
22332237
zStopperFile, zNotFound, zFileGlob, zIpAddr, flags);
22342238
--- src/main.c
+++ src/main.c
@@ -2195,10 +2195,12 @@
2195 if( zIpAddr ){
2196 zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
 
 
2200 }
2201 db_close(1);
2202 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2203 fossil_fatal("unable to listen on TCP socket %d", iPort);
2204 }
@@ -2224,10 +2226,12 @@
2224 if( zIpAddr ){
2225 zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
2226 }else{
2227 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2228 }
 
 
2229 }
2230 db_close(1);
2231 if( win32_http_service(iPort, zNotFound, zFileGlob, flags) ){
2232 win32_http_server(iPort, mxPort, zBrowserCmd,
2233 zStopperFile, zNotFound, zFileGlob, zIpAddr, flags);
2234
--- src/main.c
+++ src/main.c
@@ -2195,10 +2195,12 @@
2195 if( zIpAddr ){
2196 zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
2200 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202 }
2203 db_close(1);
2204 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2205 fossil_fatal("unable to listen on TCP socket %d", iPort);
2206 }
@@ -2224,10 +2226,12 @@
2226 if( zIpAddr ){
2227 zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
2228 }else{
2229 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2230 }
2231 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2232 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2233 }
2234 db_close(1);
2235 if( win32_http_service(iPort, zNotFound, zFileGlob, flags) ){
2236 win32_http_server(iPort, mxPort, zBrowserCmd,
2237 zStopperFile, zNotFound, zFileGlob, zIpAddr, flags);
2238
+19 -10
--- src/winhttp.c
+++ src/winhttp.c
@@ -32,10 +32,11 @@
3232
typedef struct HttpRequest HttpRequest;
3333
struct HttpRequest {
3434
int id; /* ID counter */
3535
SOCKET s; /* Socket on which to receive data */
3636
SOCKADDR_IN addr; /* Address from which data is coming */
37
+ int flags; /* Flags passed to win32_http_server() */
3738
const char *zOptions; /* --notfound and/or --localauth options */
3839
};
3940
4041
/*
4142
** Prefix for a temporary file.
@@ -111,17 +112,24 @@
111112
}
112113
wanted -= got;
113114
}
114115
fclose(out);
115116
out = 0;
116
- sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
117
- get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
118
- );
119
- /* if g.zLocalRoot is set, then we are in a checkout directory,
120
- ** even if the db handle is now closed */
121
- if( !g.zLocalRoot || !g.zLocalRoot[0] ){
122
- sqlite3_snprintf(sizeof(zCmd), zCmd, "%s\n%s", zCmd, g.zRepositoryName);
117
+ /*
118
+ ** The repository name is only needed if there was no open checkout. This
119
+ ** is designed to allow the open checkout for the interactive user to work
120
+ ** with the local Fossil server started via the "ui" command.
121
+ */
122
+ if( g.zRepositoryName && (p->flags&HTTP_SERVER_HAD_CHECKOUT)==0 ){
123
+ sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s",
124
+ get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
125
+ g.zRepositoryName
126
+ );
127
+ }else{
128
+ sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
129
+ get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
130
+ );
123131
}
124132
out = fossil_fopen(zCmdFName, "wb");
125133
if( out==0 ) goto end_request;
126134
fwrite(zCmd, 1, strlen(zCmd), out);
127135
fclose(out);
@@ -185,13 +193,13 @@
185193
wanted += got;
186194
}
187195
fclose(out);
188196
out = 0;
189197
sqlite3_snprintf(sizeof(zCmd), zCmd,
190
- "\"%s\" http \"%s\" %s %s %s --scgi --nossl%s",
191
- g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName,
192
- inet_ntoa(p->addr.sin_addr), p->zOptions
198
+ "\"%s\" http \"%s\" \"%s\" %s \"%s\" --scgi --nossl%s",
199
+ g.nameOfExe, zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
200
+ g.zRepositoryName, p->zOptions
193201
);
194202
fossil_system(zCmd);
195203
in = fossil_fopen(zReplyFName, "rb");
196204
if( in ){
197205
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
@@ -322,10 +330,11 @@
322330
}
323331
p = fossil_malloc( sizeof(*p) );
324332
p->id = ++idCnt;
325333
p->s = client;
326334
p->addr = client_addr;
335
+ p->flags = flags;
327336
p->zOptions = blob_str(&options);
328337
if( flags & HTTP_SERVER_SCGI ){
329338
_beginthread(win32_scgi_request, 0, (void*)p);
330339
}else{
331340
_beginthread(win32_http_request, 0, (void*)p);
332341
--- src/winhttp.c
+++ src/winhttp.c
@@ -32,10 +32,11 @@
32 typedef struct HttpRequest HttpRequest;
33 struct HttpRequest {
34 int id; /* ID counter */
35 SOCKET s; /* Socket on which to receive data */
36 SOCKADDR_IN addr; /* Address from which data is coming */
 
37 const char *zOptions; /* --notfound and/or --localauth options */
38 };
39
40 /*
41 ** Prefix for a temporary file.
@@ -111,17 +112,24 @@
111 }
112 wanted -= got;
113 }
114 fclose(out);
115 out = 0;
116 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
117 get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
118 );
119 /* if g.zLocalRoot is set, then we are in a checkout directory,
120 ** even if the db handle is now closed */
121 if( !g.zLocalRoot || !g.zLocalRoot[0] ){
122 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s\n%s", zCmd, g.zRepositoryName);
 
 
 
 
 
 
 
123 }
124 out = fossil_fopen(zCmdFName, "wb");
125 if( out==0 ) goto end_request;
126 fwrite(zCmd, 1, strlen(zCmd), out);
127 fclose(out);
@@ -185,13 +193,13 @@
185 wanted += got;
186 }
187 fclose(out);
188 out = 0;
189 sqlite3_snprintf(sizeof(zCmd), zCmd,
190 "\"%s\" http \"%s\" %s %s %s --scgi --nossl%s",
191 g.nameOfExe, g.zRepositoryName, zRequestFName, zReplyFName,
192 inet_ntoa(p->addr.sin_addr), p->zOptions
193 );
194 fossil_system(zCmd);
195 in = fossil_fopen(zReplyFName, "rb");
196 if( in ){
197 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
@@ -322,10 +330,11 @@
322 }
323 p = fossil_malloc( sizeof(*p) );
324 p->id = ++idCnt;
325 p->s = client;
326 p->addr = client_addr;
 
327 p->zOptions = blob_str(&options);
328 if( flags & HTTP_SERVER_SCGI ){
329 _beginthread(win32_scgi_request, 0, (void*)p);
330 }else{
331 _beginthread(win32_http_request, 0, (void*)p);
332
--- src/winhttp.c
+++ src/winhttp.c
@@ -32,10 +32,11 @@
32 typedef struct HttpRequest HttpRequest;
33 struct HttpRequest {
34 int id; /* ID counter */
35 SOCKET s; /* Socket on which to receive data */
36 SOCKADDR_IN addr; /* Address from which data is coming */
37 int flags; /* Flags passed to win32_http_server() */
38 const char *zOptions; /* --notfound and/or --localauth options */
39 };
40
41 /*
42 ** Prefix for a temporary file.
@@ -111,17 +112,24 @@
112 }
113 wanted -= got;
114 }
115 fclose(out);
116 out = 0;
117 /*
118 ** The repository name is only needed if there was no open checkout. This
119 ** is designed to allow the open checkout for the interactive user to work
120 ** with the local Fossil server started via the "ui" command.
121 */
122 if( g.zRepositoryName && (p->flags&HTTP_SERVER_HAD_CHECKOUT)==0 ){
123 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s",
124 get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
125 g.zRepositoryName
126 );
127 }else{
128 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
129 get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
130 );
131 }
132 out = fossil_fopen(zCmdFName, "wb");
133 if( out==0 ) goto end_request;
134 fwrite(zCmd, 1, strlen(zCmd), out);
135 fclose(out);
@@ -185,13 +193,13 @@
193 wanted += got;
194 }
195 fclose(out);
196 out = 0;
197 sqlite3_snprintf(sizeof(zCmd), zCmd,
198 "\"%s\" http \"%s\" \"%s\" %s \"%s\" --scgi --nossl%s",
199 g.nameOfExe, zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
200 g.zRepositoryName, p->zOptions
201 );
202 fossil_system(zCmd);
203 in = fossil_fopen(zReplyFName, "rb");
204 if( in ){
205 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
@@ -322,10 +330,11 @@
330 }
331 p = fossil_malloc( sizeof(*p) );
332 p->id = ++idCnt;
333 p->s = client;
334 p->addr = client_addr;
335 p->flags = flags;
336 p->zOptions = blob_str(&options);
337 if( flags & HTTP_SERVER_SCGI ){
338 _beginthread(win32_scgi_request, 0, (void*)p);
339 }else{
340 _beginthread(win32_http_request, 0, (void*)p);
341

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button