Skip to content

Commit

Permalink
ASAN: Keep global variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 22, 2024
1 parent 8f48a0e commit adcd3c3
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
9 changes: 1 addition & 8 deletions trunk/src/main/srs_main_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ const char* _srs_binary = NULL;
// @global Other variables.
bool _srs_in_docker = false;

// Free global data, for address sanitizer.
extern void srs_free_global_system_ips();

#ifdef SRS_SANITIZER_LOG
extern void asan_report_callback(const char* str);
#endif
Expand Down Expand Up @@ -242,9 +239,7 @@ srs_error_t do_main(int argc, char** argv, char** envp)
__asan_set_error_report_callback(asan_report_callback);
#endif

err = run_directly_or_daemon();
srs_free_global_system_ips();
if (err != srs_success) {
if ((err = run_directly_or_daemon()) != srs_success) {
return srs_error_wrap(err, "run");
}

Expand Down Expand Up @@ -440,7 +435,6 @@ srs_error_t run_directly_or_daemon()
int status = 0;
waitpid(pid, &status, 0);
srs_trace("grandpa process exit.");
srs_free_global_system_ips();
exit(0);
}

Expand All @@ -453,7 +447,6 @@ srs_error_t run_directly_or_daemon()

if(pid > 0) {
srs_trace("father process exit");
srs_free_global_system_ips();
exit(0);
}

Expand Down
14 changes: 0 additions & 14 deletions trunk/src/protocol/srs_protocol_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,17 +673,6 @@ bool srs_net_device_is_internet(const sockaddr* addr)
}

vector<SrsIPAddress*> _srs_system_ips;
void srs_free_global_system_ips()
{
vector<SrsIPAddress*>& ips = _srs_system_ips;

// Release previous IPs.
for (int i = 0; i < (int)ips.size(); i++) {
SrsIPAddress* ip = ips[i];
srs_freep(ip);
}
ips.clear();
}

void discover_network_iface(ifaddrs* cur, vector<SrsIPAddress*>& ips, stringstream& ss0, stringstream& ss1, bool ipv6, bool loopback)
{
Expand Down Expand Up @@ -721,9 +710,6 @@ void discover_network_iface(ifaddrs* cur, vector<SrsIPAddress*>& ips, stringstre

void retrieve_local_ips()
{
// Release previous IPs.
srs_free_global_system_ips();

vector<SrsIPAddress*>& ips = _srs_system_ips;

// Get the addresses.
Expand Down
5 changes: 0 additions & 5 deletions trunk/src/utest/srs_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ srs_error_t prepare_main() {
return err;
}

// Free global data, for address sanitizer.
extern void srs_free_global_system_ips();

// We could do something in the main of utest.
// Copy from gtest-1.6.0/src/gtest_main.cc
GTEST_API_ int main(int argc, char **argv) {
Expand All @@ -117,8 +114,6 @@ GTEST_API_ int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
int r0 = RUN_ALL_TESTS();

srs_free_global_system_ips();

return r0;
}

Expand Down

0 comments on commit adcd3c3

Please sign in to comment.