Skip to content

Commit 46b661b

Browse files
author
DenverM80
committed
Add debugging prints, WIP log timestamp
1 parent cdc2992 commit 46b661b

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

src/ds3_connection.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ds3_connection_pool* ds3_connection_pool_init(void) {
2828
}
2929

3030
ds3_connection_pool* ds3_connection_pool_init_with_size(uint16_t pool_size) {
31+
printf("ds3_connection_pool_init_with_size(%u)\n", pool_size);
3132
ds3_connection_pool* pool = g_new0(ds3_connection_pool, 1);
3233
pool->connections = g_new0(ds3_connection*, pool_size);
3334
pool->num_connections = pool_size;
@@ -38,6 +39,7 @@ ds3_connection_pool* ds3_connection_pool_init_with_size(uint16_t pool_size) {
3839
}
3940

4041
void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locked) {
42+
printf("ds3_connection_pool_clear(%s)\n", (already_locked ? "locked" : "not locked"));
4143
int index;
4244

4345
if (pool == NULL) {
@@ -61,14 +63,17 @@ void ds3_connection_pool_clear(ds3_connection_pool* pool, ds3_bool already_locke
6163
}
6264

6365
static int _pool_inc(int index, uint16_t num_connections) {
66+
printf("_pool_inc(%d, %u) :[%d]\n", index, num_connections, (index+1) % num_connections);
6467
return (index+1) % num_connections;
6568
}
6669

6770
static int _pool_full(ds3_connection_pool* pool) {
71+
printf("_pool_full(): head[%d] tail[%d] : [%d]\n", pool->head, pool->tail, (_pool_inc(pool->head, pool->num_connections) == pool->tail) );
6872
return (_pool_inc(pool->head, pool->num_connections) == pool->tail);
6973
}
7074

7175
ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) {
76+
printf("ds3_connection_acquire() BEGIN: head[%d] tail[%d]\n", pool->head, pool->tail);
7277
ds3_connection* connection = NULL;
7378

7479
g_mutex_lock(&pool->mutex);
@@ -87,17 +92,20 @@ ds3_connection* ds3_connection_acquire(ds3_connection_pool* pool) {
8792

8893
g_mutex_unlock(&pool->mutex);
8994

95+
printf("ds3_connection_acquire() END: head[%d] tail[%d]\n", pool->head, pool->tail);
9096
return connection;
9197
}
9298

9399
void ds3_connection_release(ds3_connection_pool* pool, ds3_connection* connection) {
100+
printf("ds3_connection_release() BEGIN: head[%d] tail[%d]\n", pool->head, pool->tail);
94101
g_mutex_lock(&pool->mutex);
95102

96103
curl_easy_reset(connection);
97104
pool->tail = _pool_inc(pool->tail, pool->num_connections);
98105

99106
g_mutex_unlock(&pool->mutex);
100107
g_cond_signal(&pool->available_connections);
108+
printf("ds3_connection_release() END: head[%d] tail[%d]\n", pool->head, pool->tail);
101109
}
102110

103111
void ds3_connection_pool_inc_ref(ds3_connection_pool* pool) {

test/put_directory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE( put_directory_4_threads) {
103103
const char* bucket_name = "test_bulk_put_directory";
104104
printf(" Putting all files in [%s] to bucket [%s]\n", dir_path, bucket_name);
105105

106-
ds3_client* client = get_client();
106+
ds3_client* client = get_client_at_loglvl(DS3_DEBUG);
107107
int client_thread=1;
108108
ds3_client_register_logging(client, DS3_DEBUG, test_log, (void*)&client_thread); // Use DEBUG level logging
109109

@@ -139,10 +139,10 @@ BOOST_AUTO_TEST_CASE( put_directory_4_threads) {
139139
double elapsed_t;
140140
clock_gettime(CLOCK_MONOTONIC, &start_time_t);
141141

142-
GThread* put_dir_xfer_thread_0 = g_thread_new("put_dir_xfer_thread_1", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 0));
143-
GThread* put_dir_xfer_thread_1 = g_thread_new("put_dir_xfer_thread_2", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 1));
144-
GThread* put_dir_xfer_thread_2 = g_thread_new("put_dir_xfer_thread_3", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 2));
145-
GThread* put_dir_xfer_thread_3 = g_thread_new("put_dir_xfer_thread_4", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 3));
142+
GThread* put_dir_xfer_thread_0 = g_thread_new("put_dir_xfer_thread_0", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 0));
143+
GThread* put_dir_xfer_thread_1 = g_thread_new("put_dir_xfer_thread_1", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 1));
144+
GThread* put_dir_xfer_thread_2 = g_thread_new("put_dir_xfer_thread_2", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 2));
145+
GThread* put_dir_xfer_thread_3 = g_thread_new("put_dir_xfer_thread_3", (GThreadFunc)put_chunks_from_file, g_ptr_array_index(put_dir_args, 3));
146146

147147
// Block and cleanup GThread(s)
148148
g_thread_join(put_dir_xfer_thread_0);

test/test.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ struct BoostTestFixture {
4545

4646
BOOST_GLOBAL_FIXTURE( BoostTestFixture );
4747

48+
void log_timestamp(char* string_buff, long buff_size)
49+
{
50+
51+
g_snprintf(string_buff, buff_size, "%s", );
52+
}
53+
4854
void test_log(const char* message, void* user_data) {
55+
char timebuffer[32];
56+
log_timestamp(timebuffer, 32);
4957
if (user_data) {
5058
int client_num = *((int*)user_data);
51-
fprintf(stderr, "ClientNum[%d], Log Message: %s\n", client_num, message);
59+
fprintf(stderr, "%s Client[%d] %s\n", client_num, message);
5260
} else {
53-
fprintf(stderr, "Log Message: %s\n", message);
61+
fprintf(stderr, "%s %s\n", message);
5462
}
5563
}
5664

@@ -541,6 +549,9 @@ void put_chunks_from_file(void* args) {
541549
char* file_with_path = g_strconcat(_args->src_dir, object->name->value, (char*)NULL);
542550
printf(" opening file[%s]\n", file_with_path);
543551
file = fopen(file_with_path, "r");
552+
if (file == NULL) {
553+
printf(" ***Unable to open file[%s]!!!\n", file_with_path);
554+
}
544555
g_free(file_with_path);
545556
}
546557
if (object->offset != 0) {

0 commit comments

Comments
 (0)