Skip to content

Commit 7b8094f

Browse files
author
DenverM80
committed
Remove debug prints and other code cleanup
1 parent d67fb0c commit 7b8094f

File tree

3 files changed

+6
-78
lines changed

3 files changed

+6
-78
lines changed

src/ds3_connection.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ ds3_connection_pool* ds3_connection_pool_init(void) {
4040
}
4141

4242
ds3_connection_pool* ds3_connection_pool_init_with_size(uint16_t pool_size) {
43-
printf("ds3_connection_pool_init_with_size(%u)\n", pool_size);
4443
ds3_connection_pool* pool = g_new0(ds3_connection_pool, 1);
4544

4645
pool->connections = g_new0(ds3_connection*, pool_size);
@@ -64,7 +63,6 @@ void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locke
6463
if (already_locked == False) {
6564
g_mutex_lock(&pool->mutex);
6665
}
67-
printf("ds3_connection_pool_clear(%s)\n", (already_locked ? "locked" : "not locked"));
6866

6967
for (index = 0; index < pool->num_connections; index++) {
7068
if (pool->connections[index] != NULL) {
@@ -80,7 +78,6 @@ void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locke
8078
}
8179

8280
static int _queue_inc(int index, uint16_t size) {
83-
printf("_pool_inc(%d, %u) :[%d]\n", index, size, (index+1) % size);
8481
return (index+1) % size;
8582
}
8683

@@ -93,7 +90,6 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) {
9390
ds3_connection* connection = NULL;
9491

9592
g_mutex_lock(&pool->mutex);
96-
printf("ds3_connection_acquire() BEGIN: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail);
9793
while (_queue_is_empty(pool) && pool->num_connections >= pool->max_connections) {
9894
g_cond_wait(&pool->available_connection_notifier, &pool->mutex);
9995
}
@@ -109,23 +105,20 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) {
109105
pool->queue_tail = _queue_inc(pool->queue_tail, pool->max_connections);
110106
}
111107

112-
printf("ds3_connection_acquire() END: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail);
113108
g_mutex_unlock(&pool->mutex);
114109

115110
return connection;
116111
}
117112

118113
void ds3_connection_release(ds3_connection_pool* pool, ds3_connection* connection) {
119114
g_mutex_lock(&pool->mutex);
120-
printf("ds3_connection_release() BEGIN: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail);
121115

122116
curl_easy_reset(connection);
123117

124118
pool->connection_queue[pool->queue_head] = connection;
125119

126120
pool->queue_head = _queue_inc(pool->queue_head, pool->max_connections);
127121

128-
printf("ds3_connection_release() END: head[%d] tail[%d]\n", pool->queue_head, pool->queue_tail);
129122
g_cond_signal(&pool->available_connection_notifier);
130123
g_mutex_unlock(&pool->mutex);
131124
}

test/put_directory.cpp

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -25,78 +25,12 @@
2525
#include "ds3_utils.h"
2626
#include "test.h"
2727

28-
/*
29-
BOOST_AUTO_TEST_CASE( put_directory) {
30-
printf("-----Testing PUT all objects in a directory-------\n");
31-
32-
const char* dir_path = getenv("DS3_TEST_DIRECTORY");
33-
if (dir_path == NULL) {
34-
printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory test.\n");
35-
return;
36-
}
37-
38-
const char* bucket_name = "test_bulk_put_directory";
39-
printf(" Putting all files in [%s] to bucket [%s]\n", dir_path, bucket_name);
40-
41-
ds3_client* client = get_client();
42-
int client_thread=1;
43-
ds3_client_register_logging(client, DS3_DEBUG, test_log, (void*)&client_thread); // Use DEBUG level logging
44-
45-
ds3_error* error = create_bucket_with_data_policy(client, bucket_name, ids.data_policy_id->value);
46-
47-
char* objects_list[100];
48-
uint64_t num_objs = 0;
49-
GDir* dir_info = g_dir_open(dir_path, 0, NULL);
50-
for (char* current_obj = (char*)g_dir_read_name(dir_info); current_obj != NULL; current_obj = (char*)g_dir_read_name(dir_info)) {
51-
objects_list[num_objs++] = current_obj;
52-
printf(" obj[%" PRIu64 "][%s]\n", num_objs, objects_list[num_objs-1]);
53-
}
54-
55-
ds3_bulk_object_list_response* bulk_object_list = ds3_convert_file_list_with_basepath((const char**)objects_list, num_objs, dir_path);
56-
57-
ds3_request* request = ds3_init_put_bulk_job_spectra_s3_request(bucket_name, bulk_object_list);
58-
ds3_master_object_list_response* mol;
59-
error = ds3_put_bulk_job_spectra_s3_request(client, request, &mol);
60-
ds3_request_free(request);
61-
ds3_bulk_object_list_response_free(bulk_object_list);
62-
handle_error(error);
63-
64-
// Allocate cache
65-
ds3_master_object_list_response* chunks_list = ensure_available_chunks(client, mol->job_id);
66-
67-
// Use helper functions from test.cpp
68-
GPtrArray* put_dir_args = new_put_chunks_threads_args(client, NULL, dir_path, bucket_name, mol, chunks_list, 1, True); // Last param indicates verbose logging in the spawned thread
69-
70-
// capture test start time
71-
struct timespec start_time_t, end_time_t;
72-
double elapsed_t;
73-
clock_gettime(CLOCK_MONOTONIC, &start_time_t);
74-
75-
GThread* put_dir_xfer_thread = g_thread_new("put_dir_xfer_thread", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 0));
76-
77-
// Block and cleanup GThread(s)
78-
g_thread_join(put_dir_xfer_thread);
79-
80-
// find elapsed CPU and real time
81-
clock_gettime(CLOCK_MONOTONIC, &end_time_t);
82-
elapsed_t = timespec_to_seconds(&end_time_t) - timespec_to_seconds(&start_time_t);
83-
ds3_log_message(client->log, DS3_INFO, " Elapsed time[%f]", elapsed_t);
84-
85-
g_dir_close(dir_info);
86-
ds3_master_object_list_response_free(chunks_list);
87-
ds3_master_object_list_response_free(mol);
88-
put_chunks_threads_args_free(put_dir_args);
89-
clear_bucket(client, bucket_name);
90-
free_client(client);
91-
}
92-
*/
93-
9428
BOOST_AUTO_TEST_CASE( put_directory_4_threads) {
9529
printf("-----Testing PUT all objects in a directory with 4 threads-------\n");
9630

9731
const char* dir_path = getenv("DS3_TEST_DIRECTORY");
9832
if (dir_path == NULL) {
99-
printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory test.\n");
33+
printf("ENV[DS3_TEST_DIRECTORY] unset - Skipping put_directory_4_threads test.\n");
10034
return;
10135
}
10236

test/test.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,29 @@ struct BoostTestFixture {
4545

4646
BOOST_GLOBAL_FIXTURE( BoostTestFixture );
4747

48-
void log_timestamp(char* string_buff, long buff_size)
48+
static void _log_timestamp(char* string_buff, long buff_size)
4949
{
5050
time_t ltime;
5151
struct tm result;
5252
struct timeval tv;
5353
char usec_buff[8];
54+
int millisec;
5455

5556
gettimeofday(&tv, NULL);
5657
millisec = lrint(tv.tv_usec/1000.0); // Round to nearest millisec
5758

5859
ltime = time(NULL);
5960
localtime_r(&ltime, &result);
6061

61-
strftime(string_buff, buff_size, "%Y:%m:%dT%H:%M:%S", tm);
62+
strftime(string_buff, buff_size, "%Y:%m:%dT%H:%M:%S", &result);
6263
strcat(string_buff, ".");
63-
sprintf(usec_buff,"%d", (int)tmnow.tv_usec);
64+
sprintf(usec_buff,"%03d", millisec);
6465
strcat(string_buff, usec_buff);
6566
}
6667

6768
void test_log(const char* message, void* user_data) {
6869
char timebuffer[32];
69-
log_timestamp(timebuffer, 32);
70+
_log_timestamp(timebuffer, 32);
7071
if (user_data) {
7172
int client_num = *((int*)user_data);
7273
fprintf(stderr, "%s Client[%d] %s\n", timebuffer, client_num, message);

0 commit comments

Comments
 (0)