winlin

fix #397, the USER_HZ maybe not 100. 2.0.165

@@ -562,6 +562,7 @@ Supported operating systems and hardware: @@ -562,6 +562,7 @@ Supported operating systems and hardware:
562 562
563 ### SRS 2.0 history 563 ### SRS 2.0 history
564 564
  565 +* v2.0, 2015-05-22, fix [#397](https://github.com/simple-rtmp-server/srs/issues/397) the USER_HZ maybe not 100. 2.0.165
565 * v2.0, 2015-05-22, for [#400](https://github.com/simple-rtmp-server/srs/issues/400), parse when got entire http header, by feilong. 2.0.164. 566 * v2.0, 2015-05-22, for [#400](https://github.com/simple-rtmp-server/srs/issues/400), parse when got entire http header, by feilong. 2.0.164.
566 * v2.0, 2015-05-19, merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163. 567 * v2.0, 2015-05-19, merge from bravo system, add the rtmfp to bms(commercial srs). 2.0.163.
567 * v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS. 568 * v2.0, 2015-05-10, support push flv stream over HTTP POST to SRS.
@@ -672,6 +673,10 @@ Supported operating systems and hardware: @@ -672,6 +673,10 @@ Supported operating systems and hardware:
672 673
673 ### SRS 1.0 history 674 ### SRS 1.0 history
674 675
  676 +* 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
  677 +* v1.0, 2015-03-26, fix hls aac adts bug, in aac mux. 1.0.31.
  678 +* <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>
  679 +* v1.0, 2015-03-17, remove the osx for 1.0.30.
675 * v1.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 1.0.28. 680 * v1.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 1.0.28.
676 * <strong>v1.0, 2015-02-12, [1.0r2 release(1.0.27)](https://github.com/simple-rtmp-server/srs/releases/tag/1.0r2) released. 59507 lines.</strong> 681 * <strong>v1.0, 2015-02-12, [1.0r2 release(1.0.27)](https://github.com/simple-rtmp-server/srs/releases/tag/1.0r2) released. 59507 lines.</strong>
677 * v1.0, 2015-02-11, dev code HuKaiqun for 1.0.27. 682 * v1.0, 2015-02-11, dev code HuKaiqun for 1.0.27.
@@ -418,15 +418,13 @@ bool get_proc_self_stat(SrsProcSelfStat& r) @@ -418,15 +418,13 @@ bool get_proc_self_stat(SrsProcSelfStat& r)
418 418
419 void srs_update_proc_stat() 419 void srs_update_proc_stat()
420 { 420 {
421 - // always assert the USER_HZ is 1/100ths  
422 // @see: http://stackoverflow.com/questions/7298646/calculating-user-nice-sys-idle-iowait-irq-and-sirq-from-proc-stat/7298711 421 // @see: http://stackoverflow.com/questions/7298646/calculating-user-nice-sys-idle-iowait-irq-and-sirq-from-proc-stat/7298711
423 - static bool user_hz_assert = false;  
424 - if (!user_hz_assert) {  
425 - user_hz_assert = true;  
426 -  
427 - int USER_HZ = sysconf(_SC_CLK_TCK);  
428 - srs_trace("USER_HZ=%d", USER_HZ);  
429 - srs_assert(USER_HZ == 100); 422 + // @see https://github.com/simple-rtmp-server/srs/issues/397
  423 + static int user_hz = 0;
  424 + if (user_hz <= 0) {
  425 + user_hz = sysconf(_SC_CLK_TCK);
  426 + srs_trace("USER_HZ=%d", user_hz);
  427 + srs_assert(user_hz > 0);
430 } 428 }
431 429
432 // system cpu stat 430 // system cpu stat
@@ -471,7 +469,7 @@ void srs_update_proc_stat() @@ -471,7 +469,7 @@ void srs_update_proc_stat()
471 int64_t total = r.sample_time - o.sample_time; 469 int64_t total = r.sample_time - o.sample_time;
472 int64_t usage = (r.utime + r.stime) - (o.utime + o.stime); 470 int64_t usage = (r.utime + r.stime) - (o.utime + o.stime);
473 if (total > 0) { 471 if (total > 0) {
474 - r.percent = (float)(usage * 1000 / (double)total / 100); 472 + r.percent = (float)(usage * 1000 / (double)total / user_hz);
475 } 473 }
476 474
477 // upate cache. 475 // 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 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 164 34 +#define VERSION_REVISION 165
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"