Fossil SCM
Fix the /chat-poll page so that it works even when called from "fossil ui".
Commit
6f424a32b5ef1ddbc086dba562ff7e2ff3b5a422686ebbfa5fbcf8684692f6c8
Parent
2261b294155d856…
1 file changed
+7
-3
+7
-3
| --- src/chat.c | ||
| +++ src/chat.c | ||
| @@ -263,11 +263,10 @@ | ||
| 263 | 263 | ** The "mdel" will only exist if "xmsg" is an empty string and "fsize" is zero. |
| 264 | 264 | */ |
| 265 | 265 | void chat_poll_webpage(void){ |
| 266 | 266 | Blob json; /* The json to be constructed and returned */ |
| 267 | 267 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 268 | - sqlite3_int64 newDataVers; | |
| 269 | 268 | int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 270 | 269 | const char *zSep = "{\"msgs\":[\n"; /* List separator */ |
| 271 | 270 | int msgid = atoi(PD("name","0")); |
| 272 | 271 | Stmt q1; |
| 273 | 272 | login_check_credentials(); |
| @@ -325,20 +324,25 @@ | ||
| 325 | 324 | blob_appendf(&json, ",\"mdel\":%d}", iToDel); |
| 326 | 325 | }else{ |
| 327 | 326 | blob_append(&json, "}", 1); |
| 328 | 327 | } |
| 329 | 328 | } |
| 329 | + db_reset(&q1); | |
| 330 | 330 | if( cnt ){ |
| 331 | 331 | blob_append(&json, "\n]}", 3); |
| 332 | 332 | cgi_set_content(&json); |
| 333 | 333 | break; |
| 334 | 334 | } |
| 335 | 335 | sqlite3_sleep(iDelay); |
| 336 | - while( (newDataVers = db_int64(0,"PRAGMA data_version"))==dataVersion ){ | |
| 336 | + while( 1 ){ | |
| 337 | + sqlite3_int64 newDataVers = db_int64(0,"PRAGMA repository.data_version"); | |
| 338 | + if( newDataVers!=dataVersion ){ | |
| 339 | + dataVersion = newDataVers; | |
| 340 | + break; | |
| 341 | + } | |
| 337 | 342 | sqlite3_sleep(iDelay); |
| 338 | 343 | } |
| 339 | - dataVersion = newDataVers; | |
| 340 | 344 | } /* Exit by "break" */ |
| 341 | 345 | db_finalize(&q1); |
| 342 | 346 | return; |
| 343 | 347 | } |
| 344 | 348 | |
| 345 | 349 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -263,11 +263,10 @@ | |
| 263 | ** The "mdel" will only exist if "xmsg" is an empty string and "fsize" is zero. |
| 264 | */ |
| 265 | void chat_poll_webpage(void){ |
| 266 | Blob json; /* The json to be constructed and returned */ |
| 267 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 268 | sqlite3_int64 newDataVers; |
| 269 | int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 270 | const char *zSep = "{\"msgs\":[\n"; /* List separator */ |
| 271 | int msgid = atoi(PD("name","0")); |
| 272 | Stmt q1; |
| 273 | login_check_credentials(); |
| @@ -325,20 +324,25 @@ | |
| 325 | blob_appendf(&json, ",\"mdel\":%d}", iToDel); |
| 326 | }else{ |
| 327 | blob_append(&json, "}", 1); |
| 328 | } |
| 329 | } |
| 330 | if( cnt ){ |
| 331 | blob_append(&json, "\n]}", 3); |
| 332 | cgi_set_content(&json); |
| 333 | break; |
| 334 | } |
| 335 | sqlite3_sleep(iDelay); |
| 336 | while( (newDataVers = db_int64(0,"PRAGMA data_version"))==dataVersion ){ |
| 337 | sqlite3_sleep(iDelay); |
| 338 | } |
| 339 | dataVersion = newDataVers; |
| 340 | } /* Exit by "break" */ |
| 341 | db_finalize(&q1); |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 |
| --- src/chat.c | |
| +++ src/chat.c | |
| @@ -263,11 +263,10 @@ | |
| 263 | ** The "mdel" will only exist if "xmsg" is an empty string and "fsize" is zero. |
| 264 | */ |
| 265 | void chat_poll_webpage(void){ |
| 266 | Blob json; /* The json to be constructed and returned */ |
| 267 | sqlite3_int64 dataVersion; /* Data version. Used for polling. */ |
| 268 | int iDelay = 1000; /* Delay until next poll (milliseconds) */ |
| 269 | const char *zSep = "{\"msgs\":[\n"; /* List separator */ |
| 270 | int msgid = atoi(PD("name","0")); |
| 271 | Stmt q1; |
| 272 | login_check_credentials(); |
| @@ -325,20 +324,25 @@ | |
| 324 | blob_appendf(&json, ",\"mdel\":%d}", iToDel); |
| 325 | }else{ |
| 326 | blob_append(&json, "}", 1); |
| 327 | } |
| 328 | } |
| 329 | db_reset(&q1); |
| 330 | if( cnt ){ |
| 331 | blob_append(&json, "\n]}", 3); |
| 332 | cgi_set_content(&json); |
| 333 | break; |
| 334 | } |
| 335 | sqlite3_sleep(iDelay); |
| 336 | while( 1 ){ |
| 337 | sqlite3_int64 newDataVers = db_int64(0,"PRAGMA repository.data_version"); |
| 338 | if( newDataVers!=dataVersion ){ |
| 339 | dataVersion = newDataVers; |
| 340 | break; |
| 341 | } |
| 342 | sqlite3_sleep(iDelay); |
| 343 | } |
| 344 | } /* Exit by "break" */ |
| 345 | db_finalize(&q1); |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 |