正在显示
3 个修改的文件
包含
9 行增加
和
10 行删除
@@ -387,6 +387,7 @@ Supported operating systems and hardware: | @@ -387,6 +387,7 @@ Supported operating systems and hardware: | ||
387 | 387 | ||
388 | ## History | 388 | ## History |
389 | 389 | ||
390 | +* v1.0, 2015-05-22, fix [#397](https://github.com/simple-rtmp-server/srs/issues/397) the USER_HZ maybe not 100. 1.0.32 | ||
390 | * v1.0, 2015-03-26, fix hls aac adts bug, in aac mux. 1.0.31. | 391 | * v1.0, 2015-03-26, fix hls aac adts bug, in aac mux. 1.0.31. |
391 | * <strong>v1.0, 2015-03-19, [1.0r3 release(1.0.30)](https://github.com/simple-rtmp-server/srs/releases/tag/1.0r3) released. 59511 lines.</strong> | 392 | * <strong>v1.0, 2015-03-19, [1.0r3 release(1.0.30)](https://github.com/simple-rtmp-server/srs/releases/tag/1.0r3) released. 59511 lines.</strong> |
392 | * v1.0, 2015-03-17, remove the osx for 1.0.30. | 393 | * v1.0, 2015-03-17, remove the osx for 1.0.30. |
@@ -292,15 +292,13 @@ bool get_proc_self_stat(SrsProcSelfStat& r) | @@ -292,15 +292,13 @@ bool get_proc_self_stat(SrsProcSelfStat& r) | ||
292 | 292 | ||
293 | void srs_update_proc_stat() | 293 | void srs_update_proc_stat() |
294 | { | 294 | { |
295 | - // always assert the USER_HZ is 1/100ths | ||
296 | // @see: http://stackoverflow.com/questions/7298646/calculating-user-nice-sys-idle-iowait-irq-and-sirq-from-proc-stat/7298711 | 295 | // @see: http://stackoverflow.com/questions/7298646/calculating-user-nice-sys-idle-iowait-irq-and-sirq-from-proc-stat/7298711 |
297 | - static bool user_hz_assert = false; | ||
298 | - if (!user_hz_assert) { | ||
299 | - user_hz_assert = true; | ||
300 | - | ||
301 | - int USER_HZ = sysconf(_SC_CLK_TCK); | ||
302 | - srs_trace("USER_HZ=%d", USER_HZ); | ||
303 | - srs_assert(USER_HZ == 100); | 296 | + // @see https://github.com/simple-rtmp-server/srs/issues/397 |
297 | + static int user_hz = 0; | ||
298 | + if (user_hz <= 0) { | ||
299 | + user_hz = sysconf(_SC_CLK_TCK); | ||
300 | + srs_trace("USER_HZ=%d", user_hz); | ||
301 | + srs_assert(user_hz > 0); | ||
304 | } | 302 | } |
305 | 303 | ||
306 | // system cpu stat | 304 | // system cpu stat |
@@ -345,7 +343,7 @@ void srs_update_proc_stat() | @@ -345,7 +343,7 @@ void srs_update_proc_stat() | ||
345 | int64_t total = r.sample_time - o.sample_time; | 343 | int64_t total = r.sample_time - o.sample_time; |
346 | int64_t usage = (r.utime + r.stime) - (o.utime + o.stime); | 344 | int64_t usage = (r.utime + r.stime) - (o.utime + o.stime); |
347 | if (total > 0) { | 345 | if (total > 0) { |
348 | - r.percent = (float)(usage * 1000 / (double)total / 100); | 346 | + r.percent = (float)(usage * 1000 / (double)total / user_hz); |
349 | } | 347 | } |
350 | 348 | ||
351 | // upate cache. | 349 | // upate cache. |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 1 | 32 | #define VERSION_MAJOR 1 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 31 | 34 | +#define VERSION_REVISION 32 |
35 | 35 | ||
36 | // server info. | 36 | // server info. |
37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论