正在显示
4 个修改的文件
包含
51 行增加
和
8 行删除
| @@ -3,7 +3,7 @@ There are three types of people that have contributed to the SRS project: | @@ -3,7 +3,7 @@ There are three types of people that have contributed to the SRS project: | ||
| 3 | 2. AUTHORS: Contribute features and 1%~10% code. Names of all PRIMARY response in NetConnection.connect and metadata. | 3 | 2. AUTHORS: Contribute features and 1%~10% code. Names of all PRIMARY response in NetConnection.connect and metadata. |
| 4 | 3. CONTRIBUTORS: Submit patches, report bugs, add translations, help answer newbie questions, and generally make SRS that much better. | 4 | 3. CONTRIBUTORS: Submit patches, report bugs, add translations, help answer newbie questions, and generally make SRS that much better. |
| 5 | 5 | ||
| 6 | -PRIMARY ordered by first contribution. | 6 | +PRIMARY authors ordered by first contribution. |
| 7 | * winlin<winlin@vip.126.com> "Plan, arch, implement SRS1.0 and SRS2.0" | 7 | * winlin<winlin@vip.126.com> "Plan, arch, implement SRS1.0 and SRS2.0" |
| 8 | 8 | ||
| 9 | AUTHORS ordered by first contribution. | 9 | AUTHORS ordered by first contribution. |
| @@ -836,7 +836,6 @@ int SrsServer::do_cycle() | @@ -836,7 +836,6 @@ int SrsServer::do_cycle() | ||
| 836 | srs_info("update resource info, rss."); | 836 | srs_info("update resource info, rss."); |
| 837 | srs_update_system_rusage(); | 837 | srs_update_system_rusage(); |
| 838 | } | 838 | } |
| 839 | -#ifndef SRS_OSX | ||
| 840 | if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) { | 839 | if ((i % SRS_SYS_CPU_STAT_RESOLUTION_TIMES) == 0) { |
| 841 | srs_info("update cpu info, cpu usage."); | 840 | srs_info("update cpu info, cpu usage."); |
| 842 | srs_update_proc_stat(); | 841 | srs_update_proc_stat(); |
| @@ -849,12 +848,10 @@ int SrsServer::do_cycle() | @@ -849,12 +848,10 @@ int SrsServer::do_cycle() | ||
| 849 | srs_info("update memory info, usage/free."); | 848 | srs_info("update memory info, usage/free."); |
| 850 | srs_update_meminfo(); | 849 | srs_update_meminfo(); |
| 851 | } | 850 | } |
| 852 | -#endif | ||
| 853 | if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) { | 851 | if ((i % SRS_SYS_PLATFORM_INFO_RESOLUTION_TIMES) == 0) { |
| 854 | srs_info("update platform info, uptime/load."); | 852 | srs_info("update platform info, uptime/load."); |
| 855 | srs_update_platform_info(); | 853 | srs_update_platform_info(); |
| 856 | } | 854 | } |
| 857 | -#ifndef SRS_OSX | ||
| 858 | if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) { | 855 | if ((i % SRS_SYS_NETWORK_DEVICE_RESOLUTION_TIMES) == 0) { |
| 859 | srs_info("update network devices info."); | 856 | srs_info("update network devices info."); |
| 860 | srs_update_network_devices(); | 857 | srs_update_network_devices(); |
| @@ -872,7 +869,6 @@ int SrsServer::do_cycle() | @@ -872,7 +869,6 @@ int SrsServer::do_cycle() | ||
| 872 | } | 869 | } |
| 873 | #endif | 870 | #endif |
| 874 | #endif | 871 | #endif |
| 875 | -#endif | ||
| 876 | srs_info("server main thread loop"); | 872 | srs_info("server main thread loop"); |
| 877 | } | 873 | } |
| 878 | } | 874 | } |
| @@ -225,6 +225,7 @@ SrsProcSystemStat* srs_get_system_proc_stat() | @@ -225,6 +225,7 @@ SrsProcSystemStat* srs_get_system_proc_stat() | ||
| 225 | 225 | ||
| 226 | bool get_proc_system_stat(SrsProcSystemStat& r) | 226 | bool get_proc_system_stat(SrsProcSystemStat& r) |
| 227 | { | 227 | { |
| 228 | +#ifndef SRS_OSX | ||
| 228 | FILE* f = fopen("/proc/stat", "r"); | 229 | FILE* f = fopen("/proc/stat", "r"); |
| 229 | if (f == NULL) { | 230 | if (f == NULL) { |
| 230 | srs_warn("open system cpu stat failed, ignore"); | 231 | srs_warn("open system cpu stat failed, ignore"); |
| @@ -254,6 +255,10 @@ bool get_proc_system_stat(SrsProcSystemStat& r) | @@ -254,6 +255,10 @@ bool get_proc_system_stat(SrsProcSystemStat& r) | ||
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | fclose(f); | 257 | fclose(f); |
| 258 | +#else | ||
| 259 | + // TODO: FIXME: impelments it. | ||
| 260 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 261 | +#endif | ||
| 257 | 262 | ||
| 258 | r.ok = true; | 263 | r.ok = true; |
| 259 | 264 | ||
| @@ -262,6 +267,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r) | @@ -262,6 +267,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r) | ||
| 262 | 267 | ||
| 263 | bool get_proc_self_stat(SrsProcSelfStat& r) | 268 | bool get_proc_self_stat(SrsProcSelfStat& r) |
| 264 | { | 269 | { |
| 270 | +#ifndef SRS_OSX | ||
| 265 | FILE* f = fopen("/proc/self/stat", "r"); | 271 | FILE* f = fopen("/proc/self/stat", "r"); |
| 266 | if (f == NULL) { | 272 | if (f == NULL) { |
| 267 | srs_warn("open self cpu stat failed, ignore"); | 273 | srs_warn("open self cpu stat failed, ignore"); |
| @@ -288,6 +294,10 @@ bool get_proc_self_stat(SrsProcSelfStat& r) | @@ -288,6 +294,10 @@ bool get_proc_self_stat(SrsProcSelfStat& r) | ||
| 288 | &r.guest_time, &r.cguest_time); | 294 | &r.guest_time, &r.cguest_time); |
| 289 | 295 | ||
| 290 | fclose(f); | 296 | fclose(f); |
| 297 | +#else | ||
| 298 | + // TODO: FIXME: impelments it. | ||
| 299 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 300 | +#endif | ||
| 291 | 301 | ||
| 292 | r.ok = true; | 302 | r.ok = true; |
| 293 | 303 | ||
| @@ -385,6 +395,7 @@ SrsDiskStat* srs_get_disk_stat() | @@ -385,6 +395,7 @@ SrsDiskStat* srs_get_disk_stat() | ||
| 385 | 395 | ||
| 386 | bool srs_get_disk_vmstat_stat(SrsDiskStat& r) | 396 | bool srs_get_disk_vmstat_stat(SrsDiskStat& r) |
| 387 | { | 397 | { |
| 398 | +#ifndef SRS_OSX | ||
| 388 | FILE* f = fopen("/proc/vmstat", "r"); | 399 | FILE* f = fopen("/proc/vmstat", "r"); |
| 389 | if (f == NULL) { | 400 | if (f == NULL) { |
| 390 | srs_warn("open vmstat failed, ignore"); | 401 | srs_warn("open vmstat failed, ignore"); |
| @@ -404,6 +415,10 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r) | @@ -404,6 +415,10 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r) | ||
| 404 | } | 415 | } |
| 405 | 416 | ||
| 406 | fclose(f); | 417 | fclose(f); |
| 418 | +#else | ||
| 419 | + // TODO: FIXME: impelments it. | ||
| 420 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 421 | +#endif | ||
| 407 | 422 | ||
| 408 | r.ok = true; | 423 | r.ok = true; |
| 409 | 424 | ||
| @@ -421,6 +436,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) | @@ -421,6 +436,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) | ||
| 421 | return true; | 436 | return true; |
| 422 | } | 437 | } |
| 423 | 438 | ||
| 439 | +#ifndef SRS_OSX | ||
| 424 | FILE* f = fopen("/proc/diskstats", "r"); | 440 | FILE* f = fopen("/proc/diskstats", "r"); |
| 425 | if (f == NULL) { | 441 | if (f == NULL) { |
| 426 | srs_warn("open vmstat failed, ignore"); | 442 | srs_warn("open vmstat failed, ignore"); |
| @@ -485,6 +501,10 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) | @@ -485,6 +501,10 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) | ||
| 485 | } | 501 | } |
| 486 | 502 | ||
| 487 | fclose(f); | 503 | fclose(f); |
| 504 | +#else | ||
| 505 | + // TODO: FIXME: impelments it. | ||
| 506 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 507 | +#endif | ||
| 488 | 508 | ||
| 489 | r.ok = true; | 509 | r.ok = true; |
| 490 | 510 | ||
| @@ -575,14 +595,15 @@ SrsMemInfo* srs_get_meminfo() | @@ -575,14 +595,15 @@ SrsMemInfo* srs_get_meminfo() | ||
| 575 | 595 | ||
| 576 | void srs_update_meminfo() | 596 | void srs_update_meminfo() |
| 577 | { | 597 | { |
| 598 | + SrsMemInfo& r = _srs_system_meminfo; | ||
| 599 | + | ||
| 600 | +#ifndef SRS_OSX | ||
| 578 | FILE* f = fopen("/proc/meminfo", "r"); | 601 | FILE* f = fopen("/proc/meminfo", "r"); |
| 579 | if (f == NULL) { | 602 | if (f == NULL) { |
| 580 | srs_warn("open meminfo failed, ignore"); | 603 | srs_warn("open meminfo failed, ignore"); |
| 581 | return; | 604 | return; |
| 582 | } | 605 | } |
| 583 | 606 | ||
| 584 | - SrsMemInfo& r = _srs_system_meminfo; | ||
| 585 | - | ||
| 586 | static char buf[1024]; | 607 | static char buf[1024]; |
| 587 | while (fgets(buf, sizeof(buf), f)) { | 608 | while (fgets(buf, sizeof(buf), f)) { |
| 588 | // @see: read_meminfo() from https://github.com/sysstat/sysstat/blob/master/rd_stats.c#L227 | 609 | // @see: read_meminfo() from https://github.com/sysstat/sysstat/blob/master/rd_stats.c#L227 |
| @@ -602,6 +623,10 @@ void srs_update_meminfo() | @@ -602,6 +623,10 @@ void srs_update_meminfo() | ||
| 602 | } | 623 | } |
| 603 | 624 | ||
| 604 | fclose(f); | 625 | fclose(f); |
| 626 | +#else | ||
| 627 | + // TODO: FIXME: impelments it. | ||
| 628 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 629 | +#endif | ||
| 605 | 630 | ||
| 606 | r.sample_time = srs_get_system_time_ms(); | 631 | r.sample_time = srs_get_system_time_ms(); |
| 607 | r.MemActive = r.MemTotal - r.MemFree; | 632 | r.MemActive = r.MemTotal - r.MemFree; |
| @@ -781,6 +806,7 @@ int srs_get_network_devices_count() | @@ -781,6 +806,7 @@ int srs_get_network_devices_count() | ||
| 781 | 806 | ||
| 782 | void srs_update_network_devices() | 807 | void srs_update_network_devices() |
| 783 | { | 808 | { |
| 809 | +#ifndef SRS_OSX | ||
| 784 | if (true) { | 810 | if (true) { |
| 785 | FILE* f = fopen("/proc/net/dev", "r"); | 811 | FILE* f = fopen("/proc/net/dev", "r"); |
| 786 | if (f == NULL) { | 812 | if (f == NULL) { |
| @@ -815,6 +841,10 @@ void srs_update_network_devices() | @@ -815,6 +841,10 @@ void srs_update_network_devices() | ||
| 815 | 841 | ||
| 816 | fclose(f); | 842 | fclose(f); |
| 817 | } | 843 | } |
| 844 | +#else | ||
| 845 | + // TODO: FIXME: impelments it. | ||
| 846 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 847 | +#endif | ||
| 818 | } | 848 | } |
| 819 | 849 | ||
| 820 | SrsNetworkRtmpServer::SrsNetworkRtmpServer() | 850 | SrsNetworkRtmpServer::SrsNetworkRtmpServer() |
| @@ -862,6 +892,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | @@ -862,6 +892,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | ||
| 862 | int nb_tcp_mem = 0; | 892 | int nb_tcp_mem = 0; |
| 863 | int nb_udp4 = 0; | 893 | int nb_udp4 = 0; |
| 864 | 894 | ||
| 895 | +#ifndef SRS_OSX | ||
| 865 | if (true) { | 896 | if (true) { |
| 866 | FILE* f = fopen("/proc/net/sockstat", "r"); | 897 | FILE* f = fopen("/proc/net/sockstat", "r"); |
| 867 | if (f == NULL) { | 898 | if (f == NULL) { |
| @@ -891,9 +922,21 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | @@ -891,9 +922,21 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | ||
| 891 | 922 | ||
| 892 | fclose(f); | 923 | fclose(f); |
| 893 | } | 924 | } |
| 925 | +#else | ||
| 926 | + // TODO: FIXME: impelments it. | ||
| 927 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 928 | + nb_socks = 0; | ||
| 929 | + nb_tcp4_hashed = 0; | ||
| 930 | + nb_tcp_orphans = 0; | ||
| 931 | + nb_tcp_tws = 0; | ||
| 932 | + nb_tcp_total = 0; | ||
| 933 | + nb_tcp_mem = 0; | ||
| 934 | + nb_udp4 = 0; | ||
| 935 | +#endif | ||
| 894 | 936 | ||
| 895 | int nb_tcp_estab = 0; | 937 | int nb_tcp_estab = 0; |
| 896 | 938 | ||
| 939 | +#ifndef SRS_OSX | ||
| 897 | if (true) { | 940 | if (true) { |
| 898 | FILE* f = fopen("/proc/net/snmp", "r"); | 941 | FILE* f = fopen("/proc/net/snmp", "r"); |
| 899 | if (f == NULL) { | 942 | if (f == NULL) { |
| @@ -923,6 +966,10 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | @@ -923,6 +966,10 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) | ||
| 923 | 966 | ||
| 924 | fclose(f); | 967 | fclose(f); |
| 925 | } | 968 | } |
| 969 | +#else | ||
| 970 | + // TODO: FIXME: impelments it. | ||
| 971 | + // Fuck all of you who use osx for a long time and never patch the osx features for srs. | ||
| 972 | +#endif | ||
| 926 | 973 | ||
| 927 | // @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c | 974 | // @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c |
| 928 | // TODO: FIXME: ignore the slabstat, @see: get_slabstat() | 975 | // TODO: FIXME: ignore the slabstat, @see: get_slabstat() |
| @@ -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 145 | 34 | +#define VERSION_REVISION 146 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论