正在显示
2 个修改的文件
包含
9 行增加
和
4 行删除
| @@ -1000,12 +1000,14 @@ void srs_update_network_devices() | @@ -1000,12 +1000,14 @@ void srs_update_network_devices() | ||
| 1000 | 1000 | ||
| 1001 | // @see: read_net_dev() from https://github.com/sysstat/sysstat/blob/master/rd_stats.c#L786 | 1001 | // @see: read_net_dev() from https://github.com/sysstat/sysstat/blob/master/rd_stats.c#L786 |
| 1002 | // @remark, we use our algorithm, not sysstat. | 1002 | // @remark, we use our algorithm, not sysstat. |
| 1003 | + char fname[7]; | ||
| 1003 | sscanf(buf, "%6[^:]:%llu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %lu %lu %lu %lu\n", | 1004 | sscanf(buf, "%6[^:]:%llu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %lu %lu %lu %lu\n", |
| 1004 | - r.name, &r.rbytes, &r.rpackets, &r.rerrs, &r.rdrop, &r.rfifo, &r.rframe, &r.rcompressed, &r.rmulticast, | 1005 | + fname, &r.rbytes, &r.rpackets, &r.rerrs, &r.rdrop, &r.rfifo, &r.rframe, &r.rcompressed, &r.rmulticast, |
| 1005 | &r.sbytes, &r.spackets, &r.serrs, &r.sdrop, &r.sfifo, &r.scolls, &r.scarrier, &r.scompressed); | 1006 | &r.sbytes, &r.spackets, &r.serrs, &r.sdrop, &r.sfifo, &r.scolls, &r.scarrier, &r.scompressed); |
| 1006 | 1007 | ||
| 1007 | - r.name[sizeof(r.name) - 1] = 0; | 1008 | + sscanf(fname, "%s", r.name); |
| 1008 | _nb_srs_system_network_devices = i + 1; | 1009 | _nb_srs_system_network_devices = i + 1; |
| 1010 | + srs_info("scan network device ifname=%s, total=%d", r.name, _nb_srs_system_network_devices); | ||
| 1009 | 1011 | ||
| 1010 | r.sample_time = srs_get_system_time_ms(); | 1012 | r.sample_time = srs_get_system_time_ms(); |
| 1011 | r.ok = true; | 1013 | r.ok = true; |
| @@ -1026,6 +1028,8 @@ static std::map<std::string, bool> _srs_device_ifs; | @@ -1026,6 +1028,8 @@ static std::map<std::string, bool> _srs_device_ifs; | ||
| 1026 | 1028 | ||
| 1027 | bool srs_net_device_is_internet(string ifname) | 1029 | bool srs_net_device_is_internet(string ifname) |
| 1028 | { | 1030 | { |
| 1031 | + srs_info("check ifname=%s", ifname.c_str()); | ||
| 1032 | + | ||
| 1029 | if (_srs_device_ifs.find(ifname) == _srs_device_ifs.end()) { | 1033 | if (_srs_device_ifs.find(ifname) == _srs_device_ifs.end()) { |
| 1030 | return false; | 1034 | return false; |
| 1031 | } | 1035 | } |
| @@ -1254,10 +1258,10 @@ void retrieve_local_ipv4_ips() | @@ -1254,10 +1258,10 @@ void retrieve_local_ipv4_ips() | ||
| 1254 | 1258 | ||
| 1255 | // set the device internet status. | 1259 | // set the device internet status. |
| 1256 | if (!srs_net_device_is_internet(inaddr->s_addr)) { | 1260 | if (!srs_net_device_is_internet(inaddr->s_addr)) { |
| 1257 | - srs_trace("detect intranet address: %s", ip.c_str()); | 1261 | + srs_trace("detect intranet address: %s, ifname=%s", ip.c_str(), cur->ifa_name); |
| 1258 | _srs_device_ifs[cur->ifa_name] = false; | 1262 | _srs_device_ifs[cur->ifa_name] = false; |
| 1259 | } else { | 1263 | } else { |
| 1260 | - srs_trace("detect internet address: %s", ip.c_str()); | 1264 | + srs_trace("detect internet address: %s, ifname=%s", ip.c_str(), cur->ifa_name); |
| 1261 | _srs_device_ifs[cur->ifa_name] = true; | 1265 | _srs_device_ifs[cur->ifa_name] = true; |
| 1262 | } | 1266 | } |
| 1263 | } | 1267 | } |
| @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 34 | #include <string> | 34 | #include <string> |
| 35 | #include <sstream> | 35 | #include <sstream> |
| 36 | 36 | ||
| 37 | +#include <arpa/inet.h> | ||
| 37 | #include <sys/resource.h> | 38 | #include <sys/resource.h> |
| 38 | 39 | ||
| 39 | #include <srs_app_st.hpp> | 40 | #include <srs_app_st.hpp> |
-
请 注册 或 登录 后发表评论