Skip to content

Commit

Permalink
Clear heap area when release object
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Feb 17, 2024
1 parent 609083e commit 2328612
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/ilios/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ static void cluster_destroy(void *ptr)
if (cassandra_cluster->cluster) {
cass_cluster_free(cassandra_cluster->cluster);
}
bzero(cassandra_cluster, sizeof(CassandraCluster));
xfree(cassandra_cluster);
}

Expand Down
1 change: 1 addition & 0 deletions ext/ilios/future.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ static void future_destroy(void *ptr)
cass_future_free(cassandra_future->future);
}
uv_sem_destroy(&cassandra_future->sem);
bzero(cassandra_future, sizeof(CassandraFuture));
xfree(cassandra_future);
}

Expand Down
3 changes: 3 additions & 0 deletions ext/ilios/nogvl.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ static void *nogvl_sem_wait_cb(void *ptr)

void nogvl_sem_wait(uv_sem_t *sem)
{
if (!sem) {
abort();
}
// Releases GVL to run another thread while waiting
rb_thread_call_without_gvl(nogvl_sem_wait_cb, sem, RUBY_UBF_PROCESS, 0);
}
1 change: 1 addition & 0 deletions ext/ilios/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static void result_destroy(void *ptr)
if (cassandra_result->future) {
cass_future_free(cassandra_result->future);
}
bzero(cassandra_result, sizeof(CassandraResult));
xfree(cassandra_result);
}

Expand Down
1 change: 1 addition & 0 deletions ext/ilios/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ static void session_destroy(void *ptr)
if (cassandra_session->connect_future) {
cass_future_free(cassandra_session->connect_future);
}
bzero(cassandra_session, sizeof(CassandraSession));
xfree(cassandra_session);
}

Expand Down
1 change: 1 addition & 0 deletions ext/ilios/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ static void statement_destroy(void *ptr)
if (cassandra_statement->statement) {
cass_statement_free(cassandra_statement->statement);
}
bzero(cassandra_statement, sizeof(CassandraStatement));
xfree(cassandra_statement);
}

Expand Down

0 comments on commit 2328612

Please sign in to comment.