Fossil SCM
Added fossil_timer_is_active(timerId), removed fossil_has_timer().
Commit
590406df3c5cb6da25a736354a7e95aada071a7c
Parent
e28433a692fa606…
2 files changed
+5
-2
+8
-3
+5
-2
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1424,23 +1424,26 @@ | ||
| 1424 | 1424 | cson_object_set( o, "cmd.offset", tmp ); |
| 1425 | 1425 | cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) ); |
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | |
| 1429 | - if(fossil_has_timer()){ | |
| 1429 | + if(fossil_timer_is_active(g.json.timerId)){ | |
| 1430 | 1430 | /* This is, philosophically speaking, not quite the right place |
| 1431 | 1431 | for ending the timer, but this is the one function which all of |
| 1432 | 1432 | the JSON exit paths use (and they call it after processing, |
| 1433 | 1433 | just before they end). |
| 1434 | 1434 | */ |
| 1435 | - sqlite3_uint64 span = fossil_timer_fetch(g.json.timerId); | |
| 1435 | + sqlite3_uint64 span = fossil_timer_stop(g.json.timerId); | |
| 1436 | 1436 | /* I'm actually seeing sub-uSec runtimes in some tests, but a time of |
| 1437 | 1437 | 0 is "just kinda wrong". |
| 1438 | 1438 | */ |
| 1439 | 1439 | cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span)); |
| 1440 | 1440 | span /= 1000/*for milliseconds */; |
| 1441 | 1441 | cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span)); |
| 1442 | + assert(!fossil_timer_is_active(g.json.timerId)); | |
| 1443 | + g.json.timerId = -1; | |
| 1444 | + | |
| 1442 | 1445 | } |
| 1443 | 1446 | if(g.json.warnings){ |
| 1444 | 1447 | tmp = cson_array_value(g.json.warnings); |
| 1445 | 1448 | SET("warnings"); |
| 1446 | 1449 | } |
| 1447 | 1450 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1424,23 +1424,26 @@ | |
| 1424 | cson_object_set( o, "cmd.offset", tmp ); |
| 1425 | cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) ); |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | if(fossil_has_timer()){ |
| 1430 | /* This is, philosophically speaking, not quite the right place |
| 1431 | for ending the timer, but this is the one function which all of |
| 1432 | the JSON exit paths use (and they call it after processing, |
| 1433 | just before they end). |
| 1434 | */ |
| 1435 | sqlite3_uint64 span = fossil_timer_fetch(g.json.timerId); |
| 1436 | /* I'm actually seeing sub-uSec runtimes in some tests, but a time of |
| 1437 | 0 is "just kinda wrong". |
| 1438 | */ |
| 1439 | cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span)); |
| 1440 | span /= 1000/*for milliseconds */; |
| 1441 | cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span)); |
| 1442 | } |
| 1443 | if(g.json.warnings){ |
| 1444 | tmp = cson_array_value(g.json.warnings); |
| 1445 | SET("warnings"); |
| 1446 | } |
| 1447 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1424,23 +1424,26 @@ | |
| 1424 | cson_object_set( o, "cmd.offset", tmp ); |
| 1425 | cson_object_set( o, "isCGI", cson_value_new_bool( g.isHTTP ) ); |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | if(fossil_timer_is_active(g.json.timerId)){ |
| 1430 | /* This is, philosophically speaking, not quite the right place |
| 1431 | for ending the timer, but this is the one function which all of |
| 1432 | the JSON exit paths use (and they call it after processing, |
| 1433 | just before they end). |
| 1434 | */ |
| 1435 | sqlite3_uint64 span = fossil_timer_stop(g.json.timerId); |
| 1436 | /* I'm actually seeing sub-uSec runtimes in some tests, but a time of |
| 1437 | 0 is "just kinda wrong". |
| 1438 | */ |
| 1439 | cson_object_set(o,"procTimeUs", cson_value_new_integer((cson_int_t)span)); |
| 1440 | span /= 1000/*for milliseconds */; |
| 1441 | cson_object_set(o,"procTimeMs", cson_value_new_integer((cson_int_t)span)); |
| 1442 | assert(!fossil_timer_is_active(g.json.timerId)); |
| 1443 | g.json.timerId = -1; |
| 1444 | |
| 1445 | } |
| 1446 | if(g.json.warnings){ |
| 1447 | tmp = cson_array_value(g.json.warnings); |
| 1448 | SET("warnings"); |
| 1449 | } |
| 1450 |
+8
-3
| --- src/util.c | ||
| +++ src/util.c | ||
| @@ -285,10 +285,15 @@ | ||
| 285 | 285 | return rc; |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /* |
| 290 | -** Returns 1 if fossil has timer capabilities. | |
| 290 | +** Returns true (non-0) if the given timer ID (as returned from | |
| 291 | +** fossil_timer_start() is currently active. | |
| 291 | 292 | */ |
| 292 | -int fossil_has_timer(){ | |
| 293 | - return 1; | |
| 293 | +int fossil_timer_is_active( int timerId ){ | |
| 294 | + if(timerId<0 || timerId>=FOSSIL_TIMER_COUNT){ | |
| 295 | + return 0; | |
| 296 | + }else{ | |
| 297 | + return fossilTimerList[timerId].used; | |
| 298 | + } | |
| 294 | 299 | } |
| 295 | 300 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -285,10 +285,15 @@ | |
| 285 | return rc; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | ** Returns 1 if fossil has timer capabilities. |
| 291 | */ |
| 292 | int fossil_has_timer(){ |
| 293 | return 1; |
| 294 | } |
| 295 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -285,10 +285,15 @@ | |
| 285 | return rc; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | ** Returns true (non-0) if the given timer ID (as returned from |
| 291 | ** fossil_timer_start() is currently active. |
| 292 | */ |
| 293 | int fossil_timer_is_active( int timerId ){ |
| 294 | if(timerId<0 || timerId>=FOSSIL_TIMER_COUNT){ |
| 295 | return 0; |
| 296 | }else{ |
| 297 | return fossilTimerList[timerId].used; |
| 298 | } |
| 299 | } |
| 300 |