File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ typedef enum CaCacheState {
4747
4848struct CaSync {
4949 CaDirection direction ;
50- bool started ;
50+ uint64_t start_nsec ;
5151
5252 CaEncoder * encoder ;
5353 CaDecoder * decoder ;
@@ -153,6 +153,8 @@ struct CaSync {
153153 uint64_t last_chunk_request_nsec ;
154154};
155155
156+ #define CA_SYNC_IS_STARTED (s ) ((s)->start_nsec != 0)
157+
156158static CaSync * ca_sync_new (void ) {
157159 CaSync * s ;
158160
@@ -1284,7 +1286,7 @@ static int ca_sync_start(CaSync *s) {
12841286
12851287 assert (s );
12861288
1287- if (s -> started )
1289+ if (CA_SYNC_IS_STARTED ( s ) )
12881290 return 0 ;
12891291
12901292 if (s -> direction == CA_SYNC_ENCODE && s -> archive_path && s -> archive_fd < 0 ) {
@@ -1588,7 +1590,7 @@ static int ca_sync_start(CaSync *s) {
15881590 }
15891591
15901592 s -> cache_state = ca_sync_use_cache (s ) ? CA_SYNC_CACHE_CHECK : CA_SYNC_CACHE_OFF ;
1591- s -> started = true ;
1593+ s -> start_nsec = now ( CLOCK_MONOTONIC ) ;
15921594
15931595 return 1 ;
15941596}
@@ -4423,14 +4425,27 @@ int ca_sync_get_decoding_time_nsec(CaSync *s, uint64_t *ret) {
44234425 return 0 ;
44244426}
44254427
4428+ int ca_sync_get_runtime_nsec (CaSync * s , uint64_t * ret ) {
4429+ if (!s )
4430+ return - EINVAL ;
4431+ if (!ret )
4432+ return - EINVAL ;
4433+
4434+ if (s -> start_nsec == 0 )
4435+ return - ENODATA ;
4436+
4437+ * ret = now (CLOCK_MONOTONIC ) - s -> start_nsec ;
4438+ return 0 ;
4439+ }
4440+
44264441int ca_sync_set_compression_type (CaSync * s , CaCompressionType compression ) {
44274442 if (!s )
44284443 return - EINVAL ;
44294444 if (compression < 0 )
44304445 return - EINVAL ;
44314446 if (compression >= _CA_COMPRESSION_TYPE_MAX )
44324447 return - EOPNOTSUPP ;
4433- if (s -> started )
4448+ if (CA_SYNC_IS_STARTED ( s ) )
44344449 return - EBUSY ;
44354450
44364451 s -> compression_type = compression ;
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ int ca_sync_get_remote_requests(CaSync *s, uint64_t *ret);
159159int ca_sync_get_remote_request_bytes (CaSync * s , uint64_t * ret );
160160
161161int ca_sync_get_decoding_time_nsec (CaSync * s , uint64_t * ret );
162+ int ca_sync_get_runtime_nsec (CaSync * s , uint64_t * ret );
162163
163164int ca_sync_current_cache_hits (CaSync * s , uint64_t * ret );
164165int ca_sync_current_cache_misses (CaSync * s , uint64_t * ret );
You can’t perform that action at this time.
0 commit comments