More debugging of api

This commit is contained in:
John Jones 2017-09-25 10:00:49 -05:00
parent 4b1cd8cb11
commit 982c7e9e6e
3 changed files with 11 additions and 11 deletions

View file

@ -691,7 +691,7 @@ void *api_listen_thread (void *ptr)
} else { } else {
local_node->api_context->conns_count++; local_node->api_context->conns_count++;
} }
libp2p_logger_error("api", "API for %s: Accept connection %s:%d (%d/%d), pthread %d.\n", client, port, local_node->api_context->conns_count, local_node->api_context->max_conns, i+1); libp2p_logger_debug("api", "API for %s: Accept connection %s:%d (%d/%d), pthread %d.\n", client, port, local_node->api_context->conns_count, local_node->api_context->max_conns, i+1);
pthread_mutex_unlock(&local_node->api_context->conns_lock); pthread_mutex_unlock(&local_node->api_context->conns_lock);
} }
api_connections_cleanup (local_node); api_connections_cleanup (local_node);
@ -756,8 +756,6 @@ int api_start (struct IpfsNode* local_node, int max_conns, int timeout)
} }
memset(local_node->api_context->conns, 0, alloc_size); memset(local_node->api_context->conns, 0, alloc_size);
local_node->api_context = (struct ApiContext*) malloc(sizeof(struct ApiContext));
if (pthread_create(&local_node->api_context->api_thread, NULL, api_listen_thread, (void*)local_node)) { if (pthread_create(&local_node->api_context->api_thread, NULL, api_listen_thread, (void*)local_node)) {
close (s); close (s);
free (local_node->api_context->conns); free (local_node->api_context->conns);

View file

@ -46,11 +46,6 @@ int api_running(struct IpfsNode* local_node) {
memset(&serv_addr, 0, sizeof(struct sockaddr_in)); memset(&serv_addr, 0, sizeof(struct sockaddr_in));
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
memmove(&serv_addr.sin_addr.s_addr, server->h_addr_list[0], server->h_length); memmove(&serv_addr.sin_addr.s_addr, server->h_addr_list[0], server->h_length);
/*
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
*/
serv_addr.sin_port = htons(portno); serv_addr.sin_port = htons(portno);
int retVal = connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)); int retVal = connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr));
close(sockfd); close(sockfd);

View file

@ -12,12 +12,15 @@ int test_core_api_startup_shutdown() {
char* repo_path = "/tmp/ipfs_1"; char* repo_path = "/tmp/ipfs_1";
char* peer_id = NULL; char* peer_id = NULL;
int retVal = 0; int retVal = 0;
pthread_t daemon_thread;
//libp2p_logger_add_class("api");
if (!drop_and_build_repository(repo_path, 4001, NULL, &peer_id)) if (!drop_and_build_repository(repo_path, 4001, NULL, &peer_id))
goto exit; goto exit;
// this should start the api // this should start the api
test_daemon_start(repo_path); pthread_create(&daemon_thread, NULL, test_daemon_start, repo_path);
sleep(3); sleep(3);
// make a client to the api // make a client to the api
@ -25,14 +28,18 @@ int test_core_api_startup_shutdown() {
if (!ipfs_node_offline_new(repo_path, &client_node)) { if (!ipfs_node_offline_new(repo_path, &client_node)) {
goto exit; goto exit;
} }
// test to see if it is working // test to see if it is working
if (client_node->mode == MODE_API_AVAILABLE) if (client_node->mode != MODE_API_AVAILABLE) {
libp2p_logger_error("test_api", "API Not available.\n");
goto exit; goto exit;
}
retVal = 1; retVal = 1;
// cleanup // cleanup
exit: exit:
ipfs_daemon_stop(); ipfs_daemon_stop();
pthread_join(daemon_thread, NULL);
if (peer_id != NULL) if (peer_id != NULL)
free(peer_id); free(peer_id);
@ -146,7 +153,7 @@ int test_core_api_name_resolve() {
char* resolve_args[] = {"ipfs", "--config", ipfs_path2, "name", "resolve", peer_id1 }; char* resolve_args[] = {"ipfs", "--config", ipfs_path2, "name", "resolve", peer_id1 };
struct CliArguments* args = NULL; struct CliArguments* args = NULL;
libp2p_logger_add_class("api"); //libp2p_logger_add_class("api");
// build 2 repos... repo 1 // build 2 repos... repo 1
if (!drop_build_open_repo(ipfs_path1, &fs_repo, config_file1)) { if (!drop_build_open_repo(ipfs_path1, &fs_repo, config_file1)) {