Thread: [C-mpi-commits] SF.net SVN: c-mpi:[4] src
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2010-04-20 04:09:52
|
Revision: 4
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=4&view=rev
Author: jmwozniak
Date: 2010-04-20 04:09:45 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Do not use these anymore.
Removed Paths:
-------------
src/kda-1/
src/mpirpc-1/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2010-04-20 04:16:46
|
Revision: 7
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=7&view=rev
Author: jmwozniak
Date: 2010-04-20 04:16:40 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Only one MPIRPC in effect.
Added Paths:
-----------
src/mpirpc/
Removed Paths:
-------------
src/mpirpc-2/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2010-05-13 04:44:39
|
Revision: 111
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=111&view=rev
Author: jmwozniak
Date: 2010-05-13 04:44:33 +0000 (Thu, 13 May 2010)
Log Message:
-----------
Mostly works, some memory problem
Modified Paths:
--------------
src/cmpi/cmpi.c
src/cmpi/driver.c
src/cmpi/node.c
src/cmpi-cp/cmpi-cp.c
src/dense-1/dense.c
src/mpirpc/mpirpc.c
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/cmpi/cmpi.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -158,7 +158,7 @@
cmpi_cached_store(char* key, char* data, int length)
{
struct keyvalue* kv;
- SHOW_FS(key);
+ SHOW_FSI(key, length);
kv = lru_table_add(cmpi_cache, key, data, length);
if (kv)
{
Modified: src/cmpi/driver.c
===================================================================
--- src/cmpi/driver.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/cmpi/driver.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -54,6 +54,9 @@
signal(SIGPIPE, SIG_IGN);
+ unlink(fifo_in);
+ unlink(fifo_out);
+
int error = mkfifo(fifo_in, S_IRUSR|S_IWUSR);
if (error != 0 &&
errno != EEXIST)
@@ -127,6 +130,7 @@
if (value == NULL)
{
fprintf(driver->sink, "-1\n");
+ printf("driver: doesn't exist\n");
}
else
{
@@ -236,14 +240,14 @@
void
driver_process(cmpi_driver* driver)
{
- gossip_ldebug(MASK_DRIVER, "driver_process()...\n");
+ // gossip_ldebug(MASK_DRIVER, "driver_process()...\n");
while (! driver->quitting)
{
char* result =
fgets(driver->command, CMPI_DRIVER_MAX_COMMAND, driver->source);
if (!result)
{
- gossip_ldebug(MASK_DRIVER, "Resetting driver...\n");
+ NOTE("Resetting driver...");
fclose(driver->source);
fclose(driver->sink);
driver_setup_fifo(driver);
Modified: src/cmpi/node.c
===================================================================
--- src/cmpi/node.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/cmpi/node.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -188,24 +188,32 @@
sleep(1);
+ char hostname[128];
/*
- char hostname[128];
char* buffer;
int length = file_to_buffer(&buffer, "/etc/hostname");
memset(hostname, 0, 128);
memcpy(hostname, buffer, length);
NOTE_S("hostname: ", hostname);
*/
-
+ int error = gethostname(hostname, 128);
+ if (error)
+ {
+ printf("could not gethostname()!\n");
+ exit(1);
+ }
+
if (cmpi_mode_select(mpi_rank, mpi_size, cmpi_nodes) ==
CMPI_MODE_NODE)
{
NOTE("I am node");
+ printf("node: %i @ %s\n", mpi_rank, hostname);
cmpi_init();
}
else
{
NOTE("I am client");
+ printf("client: %i @ %s\n", mpi_size, hostname);
cmpi_init_client();
cmpi_client_code();
}
Modified: src/cmpi-cp/cmpi-cp.c
===================================================================
--- src/cmpi-cp/cmpi-cp.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/cmpi-cp/cmpi-cp.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -115,7 +115,7 @@
int
cmpi_cp_get(char* object, FILE* file)
{
- // char message[64];
+ char message[64];
char data[value_size];
int count, c;
int length;
@@ -126,10 +126,11 @@
fprintf(to_cmpi, "get %s\n", object);
fflush(to_cmpi);
- c = fscanf(from_cmpi, "%i\n", &length);
- // printf("message: %i\n", c);
- // printf("message: %s\n", message);
- // sscanf(message, "%i", &length);
+ // c = fscanf(from_cmpi, "%i\n", &length);
+ fgets(message, 64, from_cmpi);
+ //printf("message: %i\n", c);
+ printf("message: %s\n", message);
+ sscanf(message, "%i", &length);
if (length == -1)
return CMPI_DOESNT_EXIST;
Modified: src/dense-1/dense.c
===================================================================
--- src/dense-1/dense.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/dense-1/dense.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -150,7 +150,7 @@
DENSE_Translate_k(MPIRPC_Node node, DENSE_ID id)
{
MPIRPC* rpc =
- MPIRPC_Call(node, heap("query_id_k"), xheap(id),
+ MPIRPC_Call(node, "query_id_k", xheap(id),
NULL, MPIRPC_PROCEED_NULL);
return rpc;
}
@@ -164,10 +164,10 @@
{
SHOW_FSI(key, length);
int klength = strlen(key);
- int vlength = strlen(value);
- char* args = malloc((klength+vlength+5)*sizeof(char));
- assert(args);
- strcpy(args, key);
+ // int vlength = strlen(value);
+ // char* args = malloc((klength+vlength+5)*sizeof(char));
+ // assert(args);
+ // strcpy(args, key);
MPIRPC* rpc = MPIRPC_Call_blob(node, "store", key,
value, length,
Modified: src/mpirpc/mpirpc.c
===================================================================
--- src/mpirpc/mpirpc.c 2010-05-13 01:16:17 UTC (rev 110)
+++ src/mpirpc/mpirpc.c 2010-05-13 04:44:33 UTC (rev 111)
@@ -69,7 +69,8 @@
Time in microseconds to snooze when MPIRPC_Check() finds nothing.
snooze() & reset_snooze() are called by MPIRPC_Wait().
*/
-unsigned int snooze_amount = 1;
+unsigned int snooze_amount_reset = 0;
+unsigned int snooze_amount = 0;
/**
The maximum amount of time to snooze in microseconds.
@@ -548,9 +549,9 @@
{
MPIRPC_Value* value = malloc(sizeof(MPIRPC_Value));
- value->unique = unique;
+ value->unique = unique;
value->length = length;
- value->result = result;
+ value->result = result;
return value;
}
@@ -761,11 +762,12 @@
void MPIRPC_Snooze_reset()
{
- snooze_amount = 1;
+ snooze_amount = snooze_amount_reset;
}
/**
Convenience method for MPI_Comm_get_name().
+ Places the name in a static location.
*/
char*
MPIRPC_Comm_get_name(MPI_Comm comm)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2010-04-27 21:27:33
|
Revision: 40
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=40&view=rev
Author: jmwozniak
Date: 2010-04-27 21:27:26 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
KDA-2A and KDA-2B compile.
Modified Paths:
--------------
include/cmpi.h
include/kda-2.h
include/kda_conn-A.h
include/kda_conn-B.h
src/cmpi/cmpi.c
src/cmpi-db/cmpi-db-fifo.c
src/kda-2/cmpi_kademlia.c
src/kda-2/conn-A.c
src/kda-2/conn-B.c
src/kda-2/conn-C.c
src/kda-2/kademlia.c
src/kda-2/module.mk.in
src/kda-2/neighbor.c
src/mpi_tools/mpi_tools.c
src/mpirpc/mpirpc.c
Modified: include/cmpi.h
===================================================================
--- include/cmpi.h 2010-04-20 20:43:44 UTC (rev 39)
+++ include/cmpi.h 2010-04-27 21:27:26 UTC (rev 40)
@@ -226,6 +226,9 @@
/**
Retrieve a key/value pair from CMPI.
+ @param key The key
+ @param value Store pointer to value here
+ @param length OUT The value length
*/
CMPI_RETURN cmpi_get(char* key, char** value, int* length);
Modified: include/kda-2.h
===================================================================
--- include/kda-2.h 2010-04-20 20:43:44 UTC (rev 39)
+++ include/kda-2.h 2010-04-27 21:27:26 UTC (rev 40)
@@ -2,13 +2,13 @@
#ifndef KDA_2_H
#define KDA_2_H
-#include <limits.h>
-#include <signal.h>
-#include <stdbool.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
+#include <time.h>
+#include <unistd.h>
#include <mpi.h>
@@ -16,81 +16,81 @@
#include <itable.h>
#include <list.h>
#include <ilist.h>
-#include <inlist.h>
+#include <inlist.h>
#include <cmpi.h>
-#include <mpi_tools.h>
+#include <mpi_tools.h>
-#include "kda_types-2.h"
+#include "kda_types-2.h"
-#include "connection.h"
+#include "connection.h"
#include "kda_neighbor-2.h"
-#define KDA_SPACE_SIZE (sizeof(KDA_ID)*8) // 160 in paper
-#define KDA_HASH_SPACE UINT_MAX //
+#define KDA_SPACE_SIZE (sizeof(KDA_ID)*8) // 160 in paper
+#define KDA_HASH_SPACE UINT_MAX //
/**
Obtain the Kademlia distance between two ids.
*/
-#define XOR(id1, id2) (((unsigned int) id1) ^ ((unsigned int) id2))
+#define XOR(id1, id2) (((unsigned int) id1) ^ ((unsigned int) id2))
-extern KDA_ID id;
-extern K_BUCKET k_bucket[];
-extern struct list* hubs;
+extern KDA_ID id;
+extern K_BUCKET k_bucket[];
+extern struct list* hubs;
extern int kda_nodes;
enum
{
KDA_STATUS_SEARCHING,
KDA_STATUS_CALLING,
- KDA_STATUS_COMPLETE
+ KDA_STATUS_COMPLETE
};
/**
KDA_ID_NULL=0 is an invalid KDA_ID used for semantic purposes.
- make_id must not create this id.
+ make_id must not create this id.
*/
#define KDA_ID_NULL 0
/**
- KDA_ID_CLIENT=1 is an invalid KDA_ID used to identify client comms.
+ KDA_ID_CLIENT=1 is an invalid KDA_ID used to identify client comms.
*/
#define KDA_ID_CLIENT 1
void KDA_Init(int alpha_in, int k_in);
void KDA_Init_client(int alpha_in, int k_in);
-void KDA_Init_conn(void);
-void KDA_Init_conn_client(void);
+void KDA_Init_conn(void);
+void KDA_Init_conn_client(void);
//// General API...
/**
Return once op->status is KDA_STATUS_COMPLETE
*/
-void KDA_Wait(KDA_Operation* op);
+void KDA_Wait(KDA_Operation* op);
//// In-DHT API...
-void KDA_Ping(KDA_ID other_id);
-int KDA_Rank(KDA_ID other_id);
+void KDA_Ping(KDA_ID other_id);
+int KDA_Rank(KDA_ID other_id);
struct ilist* KDA_Closest(KDA_ID object_id);
struct ilist* KDA_Find_key(char* key);
-struct ilist* KDA_Find(KDA_ID object_id);
-MPIRPC_Node* KDA_Node(KDA_ID other_id);
+struct ilist* KDA_Find(KDA_ID object_id);
+MPIRPC_Node* KDA_Node(KDA_ID other_id);
//// Helpers...
-void KDA_Setup_node_port(void);
+void KDA_Setup_node_port(void);
void KDA_Serve(void);
-void KDA_Serve_id(KDA_ID other_id, MPIRPC_Node node);
+void KDA_Serve_id(KDA_ID other_id, MPIRPC_Node node);
MPIRPC_Node KDA_Serve_accept(void);
void KDA_Serve_client(MPIRPC_Node node);
void KDA_Serve_handshake(MPIRPC_Node node,
- KDA_ID* other_id, int* msg);
+ KDA_ID* other_id, int* msg);
void KDA_Serve_neighbor(KDA_ID other_id, MPIRPC_Node node);
void KDA_Setup_connector_port(void);
void KDA_Connect_port(char* port);
MPIRPC_Node* KDA_Attach(void);
MPIRPC_Node* KDA_Attach_port(char* port);
-MPIRPC_Node* KDA_Register_hub(MPI_Comm comm);
+MPIRPC_Node* KDA_Register_hub(MPI_Comm comm);
void KDA_Comm_set_name(KDA_Neighbor* neighbor);
@@ -98,34 +98,34 @@
void (*proceed)(MPIRPC* rpc),
KDA_Query* query);
bool KDA_Find_node(KDA_Operation* op);
-bool KDA_Find_node_again(KDA_Operation* op);
+bool KDA_Find_node_again(KDA_Operation* op);
// void KDA_Send_neighbor(MPI_Comm comm);
void KDA_Serve_shutdown(void);
-void KDA_Detach(MPIRPC_Node node);
-void KDA_Shutdown(void);
+void KDA_Detach(MPIRPC_Node node);
+void KDA_Shutdown(void);
void KDA_Shutdown_port(char* hub_port);
/**
- Return the KDA_Neighbor for this MPIRPC_Node.
+ Return the KDA_Neighbor for this MPIRPC_Node.
Could fail if other_id is not in local neighbor table.
*/
-KDA_Neighbor* KDA_Neighbor_node(MPIRPC_Node node);
+KDA_Neighbor* KDA_Neighbor_node(MPIRPC_Node node);
/**
Could fail if other_id is not in local neighbor table.
- */
-KDA_Neighbor* KDA_Neighbor_ID(KDA_ID other_id);
+ */
+KDA_Neighbor* KDA_Neighbor_ID(KDA_ID other_id);
/**
Attempt to contact the node other_id using a node as a
- reference.
+ reference.
*/
-void KDA_Harpoon(MPIRPC_Node reference, KDA_ID other_id);
+void KDA_Harpoon(MPIRPC_Node reference, KDA_ID other_id);
/**
Connect two neighbors in the DHT.
- @param node1 The neighbor to issue the accept().
+ @param node1 The neighbor to issue the accept().
@param node2 The neighbor to issue the connect().
*/
void KDA_Link(MPIRPC_Node node1, MPIRPC_Node node2);
@@ -133,57 +133,56 @@
/**
@return A description of the form "id".
*/
-char* KDA_Description(void);
-char* KDA_id_tostring(KDA_ID other_id);
+char* KDA_Description(void);
+char* KDA_id_tostring(KDA_ID other_id);
-//// Remote API:
+//// Remote API:
MPIRPC* KDA_Translate(MPIRPC_Node node, KDA_ID id);
MPIRPC* KDA_Translate_k(MPIRPC_Node node, KDA_ID id);
MPIRPC* KDA_Lookup(MPIRPC_Node node, char* key);
MPIRPC* KDA_Lookup_k(MPIRPC_Node node, char* key);
+
+MPIRPC* KDA_Store(KDA_Neighbor* neighbor, char* key, char* value, int length);
+
/**
- Instruct a node to store a value.
-*/
-MPIRPC* KDA_Store(KDA_Neighbor* neighbor, char* key, char* value);
-/**
Instruct a node to retrieve a value.
*/
MPIRPC* KDA_Retrieve(KDA_Neighbor* neighbor, char* key);
//// Convenience prototypes to keep functions in decent order...
KDA_ID make_id(int salt);
-// void join(MPIRPC_Node* node);
+// void join(MPIRPC_Node* node);
char* id_tostring(void);
-void listen_loop(void);
+void listen_loop(void);
void bootstrap(MPIRPC_Node node);
KDA_Neighbor* random_neighbor(void);
-int KDA_Neighbor_table_size(void);
+int KDA_Neighbor_table_size(void);
-//// Neighbor management...
+//// Neighbor management...
/**
- Add neighbor to the neighbor table.
+ Add neighbor to the neighbor table.
@return false iff n is already in the neighbor table.
*/
bool neighbor_add(KDA_Neighbor* neighbor);
/**
- Add neighbor to the client list.
+ Add neighbor to the client list.
*/
void client_add(KDA_Neighbor* client);
/**
- Find neighbor in buckets and set its comm.
+ Find neighbor in buckets and set its comm.
*/
void neighbor_set_node(KDA_Neighbor* neighbor, MPIRPC_Node node);
/**
Translate a dummy neighbor that is set to MPI_COMM_NULL to
a good one in a bucket.
- TODO: Speed this up with an index or something.
+ TODO: Speed this up with an index or something.
*/
-KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
+KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
/**
Use node to connect to neighbor.
@@ -192,13 +191,13 @@
/**
Add neighbor to the neighbor table.
- Use node to link to the neighbor.
+ Use node to link to the neighbor.
*/
-void connect_neighbor(MPIRPC_Node* node, KDA_Neighbor* neighbor);
+void connect_neighbor(MPIRPC_Node* node, KDA_Neighbor* neighbor);
-void dump_bucket_ids(void);
+void dump_bucket_ids(void);
char* bucket_ids_tostring(void);
-void dump_buckets(void);
+void dump_buckets(void);
char* buckets_tostring(void);
//// Handlers...
@@ -206,42 +205,53 @@
/**
Generate info string for debugging
*/
-void handle_info(MPIRPC_Node node, int unique, char* args);
-void handle_join(MPIRPC_Node caller, int unique, char* args);
-void handle_link(MPIRPC_Node caller, int unique, char* args);
-void handle_find_node(MPIRPC_Node node, int unique, char* args);
-void handle_neighbor(MPIRPC_Node node, int unique, char* args);
-void handle_ping(MPIRPC_Node node, int unique, char* args);
-void handle_query_id(MPIRPC_Node node, int unique, char* args);
-void handle_query_id_k(MPIRPC_Node node, int unique, char* args);
-void handle_store(MPIRPC_Node node, int unique, char* args);
-void handle_retrieve(MPIRPC_Node node, int unique, char* args);
-void handle_shutdown(MPIRPC_Node caller, int unique, char* args);
+void handle_info(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_join(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_link(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_find_node(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_neighbor(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_ping(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id_k(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_store(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_retrieve(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_shutdown(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
/* SPECIFIC TO CONN TYPE
- void handle_accept(MPIRPC_Node* caller, int unique, char* args);
- void handle_connect(MPIRPC_Node* caller, int unique, char* args);
+ void handle_accept(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
+ void handle_connect(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
*/
// Synchronous methods...
-struct ilist* find_node(KDA_ID id);
+struct ilist* find_node(KDA_ID id);
-// Asynchronous methods and return services...
+// Asynchronous methods and return services...
void query_id(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id(KDA_Operation* op);
+void return_query_id(KDA_Operation* op);
void query_id_k(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id_k(KDA_Operation* op);
+void return_query_id_k(KDA_Operation* op);
// RPCs...
-void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
+void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
// Proceeds...
void proceed_find(MPIRPC* rpc);
-void proceed_ping(MPIRPC* rpc);
-void proceed_link(MPIRPC* rpc);
+void proceed_ping(MPIRPC* rpc);
+void proceed_link(MPIRPC* rpc);
// void proceed_
-#endif
+#endif
Modified: include/kda_conn-A.h
===================================================================
--- include/kda_conn-A.h 2010-04-20 20:43:44 UTC (rev 39)
+++ include/kda_conn-A.h 2010-04-27 21:27:26 UTC (rev 40)
@@ -1,23 +1,18 @@
-#include "kademlia.h"
+#include "kda-2.h"
void KDA_Init_conn(void);
MPI_Comm KDA_Comm_create(int* other_rank);
-void KDA_Join(int other_id, int other_rank);
+void KDA_Join(int other_id, int other_rank);
/**
- Initiate a connection with the caller.
+ Translate a KDA_ID to a rank in MPI_COMM_WORLD.
*/
-void handle_join(MPIRPC_Node* caller, int unique, char* args);
+void handle_get_rank(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length);
/**
- Translate a KDA_ID to a rank in MPI_COMM_WORLD.
+ Return the local KDA_ID.
*/
-void handle_get_rank(MPIRPC_Node* caller, int unique, char* args);
-
-/**
- Return the local KDA_ID.
-*/
-void handle_get_id(MPIRPC_Node* caller, int unique, char* args);
+void handle_get_id(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length);
Modified: include/kda_conn-B.h
===================================================================
--- include/kda_conn-B.h 2010-04-20 20:43:44 UTC (rev 39)
+++ include/kda_conn-B.h 2010-04-27 21:27:26 UTC (rev 40)
@@ -2,65 +2,67 @@
/**
Connection techniques for KDA-2B DHT.
Uses HUBs to manage initial bootstrap connections.
- Uses three-way link/accept/connect/join to add neighbors.
+ Uses three-way link/accept/connect/join to add neighbors.
*/
-
#include "kda-2.h"
-extern char port[];
+extern char port[];
-void KDA_Init_conn(void);
+void KDA_Init_conn(void);
-void KDA_Connect_port(char* port);
+void KDA_Connect_port(char* port);
-//// Hub methods:
-void KDA_Hub_init(void);
-void KDA_Hub_loop(void);
+//// Hub methods:
+void KDA_Hub_init(void);
+void KDA_Hub_loop(void);
MPIRPC_Node KDA_Serve_accept(void);
void KDA_Serve_handshake(MPIRPC_Node node, KDA_ID* other_id,
- int* msg);
-void KDA_Serve_id(KDA_ID other_id, MPIRPC_Node node);
-void KDA_Serve_client(MPIRPC_Node node);
-void KDA_Serve_neighbor(KDA_ID other_id, MPIRPC_Node node);
+ int* msg);
+void KDA_Serve_id(KDA_ID other_id, MPIRPC_Node node);
+void KDA_Serve_client(MPIRPC_Node node);
+void KDA_Serve_neighbor(KDA_ID other_id, MPIRPC_Node node);
void KDA_Node_init(void);
-void KDA_Init_conn_client(void);
+void KDA_Init_conn_client(void);
void KDA_Setup_node_port(void);
/**
After establishing connection via MPI-2,
- connector calls acceptor to update neighbor tables.
+ connector calls acceptor to update neighbor tables.
*/
-void KDA_Join(MPI_Comm comm);
+void KDA_Join(MPI_Comm comm);
-MPIRPC_Node* KDA_Attach(void);
+MPIRPC_Node* KDA_Attach(void);
-MPIRPC_Node* KDA_Attach_port(char* hub_port);
+MPIRPC_Node* KDA_Attach_port(char* hub_port);
/**
- Register this comm as a hub.
-*/
-MPIRPC_Node* KDA_Register_hub(MPI_Comm comm);
+ Register this comm as a hub.
+*/
+MPIRPC_Node* KDA_Register_hub(MPI_Comm comm);
/**
- Link the caller node to the requested node.
+ Link the caller node to the requested node.
*/
-void handle_link(MPIRPC_Node caller, int unique, char* args);
+void handle_link(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
/**
- Connect two neighbors in the DHT, if neither is NULL.
- @param n1 The neighbor to issue the accept().
+ Connect two neighbors in the DHT, if neither is NULL.
+ @param n1 The neighbor to issue the accept().
@param n2 The neighbor to issue the connect().
*/
-void KDA_Link(MPIRPC_Node node1, MPIRPC_Node node2);
+void KDA_Link(MPIRPC_Node node1, MPIRPC_Node node2);
-void handle_accept(MPIRPC_Node caller, int unique, char* args);
+void handle_accept(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
-void handle_connect(MPIRPC_Node caller, int unique, char* args);
+void handle_connect(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
KDA_ID rpc_join(MPIRPC_Node node);
-void rpc_link_neighbor(MPIRPC_Node node, KDA_ID other_id);
+void rpc_link_neighbor(MPIRPC_Node node, KDA_ID other_id);
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2010-04-20 20:43:44 UTC (rev 39)
+++ src/cmpi/cmpi.c 2010-04-27 21:27:26 UTC (rev 40)
@@ -104,7 +104,10 @@
}
/**
-
+ Obtain pointer to requested data
+ @param key Locate the data for this key
+ @param data OUT Store data pointer here
+ @return length of data
*/
int
cmpi_cached_retrieve(char* key, char** data)
Modified: src/cmpi-db/cmpi-db-fifo.c
===================================================================
--- src/cmpi-db/cmpi-db-fifo.c 2010-04-20 20:43:44 UTC (rev 39)
+++ src/cmpi-db/cmpi-db-fifo.c 2010-04-27 21:27:26 UTC (rev 40)
@@ -1,17 +1,17 @@
-#include <unistd.h>
+#include <unistd.h>
-#include <node.h>
-#include <driver.h>
+#include <node.h>
+#include <driver.h>
void
wait_for_notification(void)
{
int tmp;
- MPI_Status status;
+ MPI_Status status;
MPI_Recv(&tmp, 1, MPI_INT,
- MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
- assert(tmp == -2);
+ MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
+ assert(tmp == -2);
}
void
@@ -19,27 +19,27 @@
{
if (mpi_rank < mpi_size-1)
{
- int msg = -2;
+ int msg = -2;
MPI_Send(&msg, 1, MPI_INT, mpi_rank+1, 0, MPI_COMM_WORLD);
}
else
{
- // NOTE("NOTIFICATION COMPLETE");
+ // NOTE("NOTIFICATION COMPLETE");
}
}
void
cmpi_client_code()
{
- char hostname[100];
+ char hostname[100];
wait_for_notification();
- notify_next();
-
- NOTE("CMPI-DB-FIFO...");
- gethostname(hostname, 100);
- SHOW_S(hostname);
-
+ notify_next();
+
+ NOTE("CMPI-DB-FIFO...");
+ gethostname(hostname, 100);
+ SHOW_S(hostname);
+
cmpi_driver* driver = driver_create();
while (! driver->quitting)
Modified: src/kda-2/cmpi_kademlia.c
===================================================================
--- src/kda-2/cmpi_kademlia.c 2010-04-20 20:43:44 UTC (rev 39)
+++ src/kda-2/cmpi_kademlia.c 2010-04-27 21:27:26 UTC (rev 40)
@@ -1,18 +1,18 @@
-#include "cmpi_kda-2.h"
+#include "cmpi_kda-2.h"
/**
List of KDA_Neighbor*s.
*/
-struct list* contacts;
+struct list* contacts;
CMPI_RETURN
cmpi_init_impl()
{
- // NOTE_F;
+ // NOTE_F;
KDA_Init(3, 3);
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
@@ -21,7 +21,7 @@
contacts = list_create();
KDA_Init_client(3,3);
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
@@ -34,13 +34,13 @@
kda_nodes = n;
}
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
cmpi_attach()
{
- CMPI_RETURN result;
+ CMPI_RETURN result;
if (KDA_Attach())
{
add_contacts();
@@ -48,8 +48,8 @@
}
else
result = CMPI_ERROR_SERVICENAME;
-
- return result;
+
+ return result;
}
void
@@ -57,23 +57,23 @@
{
int i;
struct list_item* item;
- NOTE_F;
+ NOTE_F;
for (i = 0; i < KDA_SPACE_SIZE; i++)
- for (item = k_bucket[i]->head;
+ for (item = k_bucket[i]->head;
item; item = item->next)
{
KDA_Neighbor* neighbor = (KDA_Neighbor*) item->data;
- KDA_Neighbor_dump(neighbor);
+ KDA_Neighbor_dump(neighbor);
list_add_unique(contacts, KDA_Neighbor_cmp, neighbor);
- KDA_Comm_set_name(neighbor);
+ KDA_Comm_set_name(neighbor);
}
}
-KDA_Neighbor*
+KDA_Neighbor*
contact_lookup(KDA_Neighbor* neighbor)
{
struct list_item* item;
- NOTE_FX(neighbor->id);
+ NOTE_FX(neighbor->id);
for (item = contacts->head;
item; item = item->next)
{
@@ -81,45 +81,45 @@
if (n->id == neighbor->id)
return n;
}
-
+
NOTE("CONTACT LOOKUP FAILED: LINKING");
- KDA_Harpoon(random_neighbor()->node, neighbor->id);
- add_contacts();
-
- return contact_lookup(neighbor);
+ KDA_Harpoon(random_neighbor()->node, neighbor->id);
+ add_contacts();
+
+ return contact_lookup(neighbor);
}
char*
cmpi_info(CMPI_ID key)
{
char* result = NULL;
- KDA_Neighbor* neighbor = (KDA_Neighbor*) list_random(contacts);
+ KDA_Neighbor* neighbor = (KDA_Neighbor*) list_random(contacts);
MPIRPC* rpc = MPIRPC_Call(neighbor->node, "info",
- xheap(key),
- "", MPIRPC_PROCEED_NULL);
+ xheap(key),
+ "", MPIRPC_PROCEED_NULL);
MPIRPC_Wait(rpc);
- result = rpc->result;
- MPIRPC_Free(rpc);
- return result;
+ result = rpc->result;
+ MPIRPC_Free(rpc);
+ return result;
}
/**
Ex-DHT search.
- @return The MPI rank closest to the given key.
+ @return The MPI rank closest to the given key.
*/
CMPI_ID
cmpi_lookup(char* key)
{
- NOTE_FS(key);
+ NOTE_FS(key);
KDA_Neighbor* n = (KDA_Neighbor*) list_random(contacts);
- MPIRPC* rpc = KDA_Lookup(n->node, key);
+ MPIRPC* rpc = KDA_Lookup(n->node, key);
MPIRPC_Wait(rpc);
- printf("cmpi_lookup()@%X -> %s \n", n->id, rpc->result);
-
+ printf("cmpi_lookup()@%X -> %s \n", n->id, rpc->result);
+
return 0;
}
@@ -128,8 +128,8 @@
{
NOTE_F;
- NOTE_XI("TRANSLATE: ", id, id);
-
+ NOTE_XI("TRANSLATE: ", id, id);
+
MPIRPC_Node* node = (MPIRPC_Node*) list_random(contacts);
if (node == NULL)
return CMPI_ERROR_NEIGHBORS;
@@ -137,18 +137,18 @@
MPIRPC* rpc = KDA_Translate(*node, (KDA_ID) id);
MPIRPC_Wait(rpc);
- int result = 0;
+ int result = 0;
sscanf(rpc->result, "%X", &result);
- return result;
+ return result;
}
CMPI_RETURN
-cmpi_put(char* key, char* value)
+cmpi_put(char* key, char* value, int length)
{
struct list_item* item;
NOTE_FSS(key, value);
- // printf("contacts: %i \n", contacts);
+ // printf("contacts: %i \n", contacts);
KDA_Neighbor* n = (KDA_Neighbor*) list_random(contacts);
MPIRPC* lookup = KDA_Lookup_k(n->node, key);
@@ -160,21 +160,21 @@
item; item = item->next)
{
KDA_Neighbor* neighbor =
- contact_lookup((KDA_Neighbor*) item->data);
- MPIRPC* rpc = KDA_Store(neighbor, key, value);
+ contact_lookup((KDA_Neighbor*) item->data);
+ MPIRPC* rpc = KDA_Store(neighbor, key, value, length);
MPIRPC_Wait(rpc);
MPIRPC_Free(rpc);
- NOTE("freed");
+ NOTE("freed");
}
- list_destroy(neighbors);
+ list_destroy(neighbors);
- DONE;
- return CMPI_SUCCESS;
+ DONE;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
-cmpi_get(char* key, char** value)
+cmpi_get(char* key, char** value, int* length)
{
struct list_item* item;
NOTE_FS(key);
@@ -184,9 +184,9 @@
MPIRPC* lookup = KDA_Lookup_k(n->node, key);
MPIRPC_Wait(lookup);
- struct list* neighbors = KDA_Neighbor_node_list(lookup->result);
- NOTE_I("neighbors->size ", neighbors->size);
-
+ struct list* neighbors = KDA_Neighbor_node_list(lookup->result);
+ NOTE_I("neighbors->size ", neighbors->size);
+
for (item = neighbors->head;
item; item = item->next)
{
@@ -198,13 +198,13 @@
MPIRPC* rpc = KDA_Retrieve(neighbor, key);
MPIRPC_Wait(rpc);
*value = rpc->result;
- NOTE_S("value: ", *value);
+ NOTE_S("value: ", *value);
MPIRPC_Free(rpc);
}
- list_destroy(neighbors);
+ list_destroy(neighbors);
- NOTE("cmpi_get() done \n");
+ NOTE("cmpi_get() done \n");
return CMPI_SUCCESS;
}
@@ -213,25 +213,25 @@
{
while (contacts->size > 0)
{
- NOTE("LOOP");
- KDA_Neighbor* neighbor = (KDA_Neighbor*) list_poll(contacts);
+ NOTE("LOOP");
+ KDA_Neighbor* neighbor = (KDA_Neighbor*) list_poll(contacts);
KDA_Detach(neighbor->node);
- free(neighbor);
+ free(neighbor);
}
while (hubs->size > 0)
{
MPIRPC_Node* hub = (MPIRPC_Node*) list_poll(hubs);
KDA_Detach(*hub);
- free(hub);
+ free(hub);
}
-
- NOTE("DETACHED");
+
+ NOTE("DETACHED");
}
void
cmpi_shutdown()
{
- KDA_Shutdown();
+ KDA_Shutdown();
}
Modified: src/kda-2/conn-A.c
===================================================================
--- src/kda-2/conn-A.c 2010-04-20 20:43:44 UTC (rev 39)
+++ src/kda-2/conn-A.c 2010-04-27 21:27:26 UTC (rev 40)
@@ -1,87 +1,88 @@
-#include "conn-A.h"
+#include "kda_conn-A.h"
/**
Maps KDA_IDs to ints.
- Stores MPI ranks in MPI_COMM_WORLD for all known KDA_IDs.
+ Stores MPI ranks in MPI_COMM_WORLD for all known KDA_IDs.
*/
-struct hashtable* world_ranks;
+struct hashtable* world_ranks;
void
KDA_Init_conn()
{
- // Add self to world_ranks...
+ // Add self to world_ranks...
world_ranks = hashtable_create(mpi_size);
int* heap_mpi_rank = malloc(sizeof(int));
- *heap_mpi_rank = mpi_size;
- hashtable_add(world_ranks, xheap(id), heap_mpi_rank);
-
- MPIRPC_Comm_add(MPI_COMM_WORLD);
+ *heap_mpi_rank = mpi_size;
+ hashtable_add(world_ranks, xheap(id), heap_mpi_rank);
+ MPIRPC_Comm_add(MPI_COMM_WORLD);
+
MPIRPC_Register("get_id", handle_get_id);
- MPIRPC_Register("get_rank", handle_get_rank);
-
- sleep(mpi_rank * 10);
+ MPIRPC_Register("get_rank", handle_get_rank);
- if (mpi_rank > 0)
+ sleep(mpi_rank * 10);
+
+ if (mpi_rank > 0)
{
- int other_rank = rand_lt(mpi_rank);
- MPIRPC_Node* node = MPIRPC_Node_create(MPI_COMM_WORLD,
- other_rank);
- SHOW_I(other_rank);
+ int other_rank = rand_lt(mpi_rank);
+ MPIRPC_Node node;
+ MPIRPC_Node_make(MPI_COMM_WORLD, other_rank, &node);
+ SHOW_I(other_rank);
char* result = MPIRPC_Block(node, "get_id", NULL);
KDA_ID other_id;
- sscanf(result, "%X", &other_id);
+ sscanf(result, "%X", &other_id);
KDA_Join(other_id, other_rank);
}
-
- listen_loop();
+
+ listen_loop();
}
/**
- Attach
+ Attach
*/
-MPIRPC_Node*
+MPIRPC_Node*
KDA_Attach()
{
- int other_rank = rand_lt(mpi_rank);
- MPIRPC_Node* node = MPIRPC_Node_create(MPI_COMM_WORLD,
- other_rank);
+ int other_rank = rand_lt(mpi_rank);
+ MPIRPC_Node node;
+ MPIRPC_Node_make(MPI_COMM_WORLD, other_rank, &node);
char* result = MPIRPC_Block(node, "get_id", NULL);
KDA_ID other_id;
- sscanf(result, "%X", &other_id);
+ sscanf(result, "%X", &other_id);
char* args = malloc(20*sizeof(int));
- sprintf(args, "%X %i", KDA_ID_CLIENT, mpi_rank);
- MPIRPC_Block(node, "join", args);
-
- return NULL;
+ sprintf(args, "%X %i", KDA_ID_CLIENT, mpi_rank);
+ MPIRPC_Block(node, "join", args);
+
+ return NULL;
}
void
-KDA_Harpoon(MPIRPC_Node* reference, KDA_ID other_id)
+KDA_Harpoon(MPIRPC_Node reference, KDA_ID other_id)
{
KDA_ID* heap_id = malloc(sizeof(KDA_ID));
- *heap_id = other_id;
- char* result = MPIRPC_Block(reference,
- "get_rank", xheap(other_id));
+ *heap_id = other_id;
+ char* result = MPIRPC_Block(reference, "get_rank", xheap(other_id));
int* other_rank = malloc(sizeof(int));
- sscanf(result, "%i", other_rank);
+ sscanf(result, "%i", other_rank);
hashtable_add(world_ranks, xheap(other_id), other_rank);
- KDA_Join(other_id, *other_rank);
+ KDA_Join(other_id, *other_rank);
}
void
KDA_Join(int other_id, int other_rank)
{
- MPIRPC_Node* node1 = MPIRPC_Node_create(MPI_COMM_WORLD, other_rank);
+ MPIRPC_Node node1, node2;
+ MPIRPC_Node_make(MPI_COMM_WORLD, other_rank, &node1);
char* args = malloc(20*sizeof(int));
- sprintf(args, "%X %i", id, mpi_rank);
- MPIRPC_Block(node1, "join", args);
+ sprintf(args, "%X %i", id, mpi_rank);
+ MPIRPC_Block(node1, "join", args);
- MPI_Comm newcomm = KDA_Comm_create(&other_rank);
- MPIRPC_Node* node2 = MPIRPC_Node_create(newcomm, 0);
- KDA_Neighbor* neighbor = KDA_Neighbor_create_id(other_id, node2);
+ MPI_Comm newcomm = KDA_Comm_create(&other_rank);
+ MPIRPC_Node_make(newcomm, 0, &node2);
+ KDA_ID kda_id = (KDA_ID) other_id;
+ KDA_Neighbor* neighbor = KDA_Neighbor_create_id(other_id, node2);
neighbor_add(neighbor);
}
@@ -89,49 +90,48 @@
KDA_Comm_create(int* other_rank)
{
MPI_Group world_group, newgroup;
- MPI_Comm newcomm;
+ MPI_Comm newcomm;
MPI_Comm_group(MPI_COMM_WORLD, &world_group);
MPI_Group_incl(world_group, 1, other_rank, &newgroup);
MPI_Comm_create(MPI_COMM_WORLD, newgroup, &newcomm);
MPIRPC_Comm_add(newcomm);
- return newcomm;
+ return newcomm;
}
void
-handle_join(MPIRPC_Node* caller, int unique, char* args)
+handle_join(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
{
KDA_ID other_id;
- int* other_rank = malloc(sizeof(int));
+ int* other_rank = malloc(sizeof(int));
sscanf(args, "%X %i", &other_id, other_rank);
- MPI_Comm newcomm = KDA_Comm_create(other_rank);
+ MPI_Comm newcomm = KDA_Comm_create(other_rank);
if (other_id != KDA_ID_CLIENT)
{
- MPIRPC_Node* node = MPIRPC_Node_create(newcomm, 0);
- KDA_Neighbor* neighbor = KDA_Neighbor_create_id(other_id, node);
- neighbor_add(neighbor);
+ MPIRPC_Node node;
+ MPIRPC_Node_make(newcomm, 0, &node);
+ KDA_Neighbor* neighbor = KDA_Neighbor_create_id(other_id, node);
+ neighbor_add(neighbor);
hashtable_add(world_ranks, xheap(other_id), other_rank);
}
-
- MPIRPC_Return(caller, unique, NULL);
+
+ MPIRPC_Null(caller, unique);
}
void
-handle_get_rank(MPIRPC_Node* caller, int unique, char* args)
+handle_get_rank(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
{
- int* other_rank = (int*) hashtable_search(world_ranks, args);
+ int* other_rank = (int*) hashtable_search(world_ranks, args);
char* result = malloc(10*sizeof(char));
- sprintf(result, "%i", *other_rank);
- MPIRPC_Return(caller, unique, result);
+ int length = sprintf(result, "%i", *other_rank);
+ MPIRPC_Return(caller, unique, result, length+1);
}
void
-handle_get_id(MPIRPC_Node* caller, int unique, char* args)
+handle_get_id(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
{
char* result = malloc(10*sizeof(char));
- sprintf(result, "%X", id);
- MPIRPC_Return(caller, unique, result);
+ int length = sprintf(result, "%X", id);
+ MPIRPC_Return(caller, unique, result, length+1);
}
-
-
Modified: src/k...
[truncated message content] |
|
From: <jmw...@us...> - 2010-05-21 15:10:25
|
Revision: 139
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=139&view=rev
Author: jmwozniak
Date: 2010-05-21 15:10:19 +0000 (Fri, 21 May 2010)
Log Message:
-----------
Small output suppression
Modified Paths:
--------------
src/adts/lru_table.c
src/cmpi/cmpi.c
Modified: src/adts/lru_table.c
===================================================================
--- src/adts/lru_table.c 2010-05-21 15:09:09 UTC (rev 138)
+++ src/adts/lru_table.c 2010-05-21 15:10:19 UTC (rev 139)
@@ -143,8 +143,8 @@
result->data = item->data;
result->length = item->length;
- printdata("lru found: ", item->data, item->length);
- printf("\n");
+ DEBUG(printdata("lru found: ", item->data, item->length));
+ DEBUG(printf("\n"));
return result;
}
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2010-05-21 15:09:09 UTC (rev 138)
+++ src/cmpi/cmpi.c 2010-05-21 15:10:19 UTC (rev 139)
@@ -125,7 +125,6 @@
SHOW_P(*data);
result = found->length;
printf("length: %i\n", result);
- // free(found->key);
free(found);
}
else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2010-05-27 20:43:18
|
Revision: 152
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=152&view=rev
Author: jmwozniak
Date: 2010-05-27 20:43:12 +0000 (Thu, 27 May 2010)
Log Message:
-----------
Various changes for paper results
Modified Paths:
--------------
Makefile.in
include/cmpi-cp.h
include/cmpi-types.h
include/ilist.h
include/mpi_tools.h
include/mpirpc.h
src/adts/About.txt
src/adts/ilist.c
src/adts/itable.c
src/cmpi/accessor.c
src/cmpi/cmpi.c
src/cmpi/driver.c
src/cmpi/node.c
src/cmpi-cp/cmpi-cp.c
src/cmpi-db/cmpi-db-fifo-quit.c
src/cmpi-db/cmpi-db-fifo.c
src/dense-1/dense.c
src/mpirpc/mpirpc.c
Modified: Makefile.in
===================================================================
--- Makefile.in 2010-05-24 19:20:40 UTC (rev 151)
+++ Makefile.in 2010-05-27 20:43:12 UTC (rev 152)
@@ -186,7 +186,7 @@
ifeq ($(DEBUG),1)
CFLAGS += @RDYNAMIC@ -Wno-unused-variable -ggdb3
else
-# CFLAGS += -O
+ CFLAGS += -O2
endif
# turn on large file support by default
CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
@@ -372,6 +372,7 @@
mpirpc: $(MPIRPC)
cmpi: $(CMPI)
+tools: bin/cmpi-db bin/cmpi-db-quit bin/cmpi-cp
#cmpi-io: $(CMPI_IO)
Modified: include/cmpi-cp.h
===================================================================
--- include/cmpi-cp.h 2010-05-24 19:20:40 UTC (rev 151)
+++ include/cmpi-cp.h 2010-05-27 20:43:12 UTC (rev 152)
@@ -28,4 +28,6 @@
void printhelp(void);
-#define debug(x) x
+#define debugging(x)
+#define dbg(x) debugging(printf("%s\n", x); \
+ fflush(stdout);)
Modified: include/cmpi-types.h
===================================================================
--- include/cmpi-types.h 2010-05-24 19:20:40 UTC (rev 151)
+++ include/cmpi-types.h 2010-05-27 20:43:12 UTC (rev 152)
@@ -10,30 +10,30 @@
/**
Successful return code.
*/
- CMPI_SUCCESS,
+ CMPI_SUCCESS = 0,
/**
- Record does not exist.
+ Unknown error.
*/
- CMPI_DOESNT_EXIST,
+ CMPI_ERROR_UNKNOWN = 1,
/**
- Query target is in a fault state.
+ Record does not exist.
*/
- CMPI_ERROR_FAULT,
+ CMPI_DOESNT_EXIST = 2,
/**
- Unknown error.
+ Query target is in a fault state.
*/
- CMPI_ERROR_UNKNOWN,
+ CMPI_ERROR_FAULT = 3,
/**
Could not find port to attach.
*/
- CMPI_ERROR_SERVICENAME,
+ CMPI_ERROR_SERVICENAME = 4,
/**
Insufficient neighbors or poorly connected network.
*/
- CMPI_ERROR_NEIGHBORS
+ CMPI_ERROR_NEIGHBORS = 5
} CMPI_RETURN;
Modified: include/ilist.h
===================================================================
--- include/ilist.h 2010-05-24 19:20:40 UTC (rev 151)
+++ include/ilist.h 2010-05-27 20:43:12 UTC (rev 152)
@@ -1,83 +1,84 @@
/**
Extremely simple singly-linked list of int-keyed data items.
- */
+ */
#ifndef ILIST_H
#define ILIST_H
-#include <stdio.h>
-#include <stdlib.h>
+#include <stdio.h>
+#include <stdlib.h>
-#include <mpi_tools.h>
+#include <mpi_tools.h>
// Maximum size of a ilist datum
-#define ILIST_MAX_DATUM 100
+#define ILIST_MAX_DATUM 100
struct ilist_item
{
- int key;
+ int key;
void* data;
- struct ilist_item* next;
-};
+ struct ilist_item* next;
+};
struct ilist
{
struct ilist_item* head;
- struct ilist_item* tail;
- int size;
+ struct ilist_item* tail;
+ int size;
};
-struct ilist* ilist_create(void);
+struct ilist* ilist_create(void);
-struct ilist_item* ilist_add(struct ilist* target,
- int key, void* data);
+void ilist_append(struct ilist* target, int key, void* data);
-#define ilist_push(target, key, data) ilist_add(target, key, data)
+bool ilist_add(struct ilist* target, int key, void* data);
-struct ilist_item* ilist_replace(struct ilist* target,
- int key, void* data);
+#define ilist_push(target, key, data) ilist_add(target, key, data)
-bool ilist_contains(struct ilist* target, int key);
+//struct ilist_item* ilist_replace(struct ilist* target,
+// int key, void* data);
+bool ilist_contains(struct ilist* target, int key);
+
bool ilist_matches(struct ilist* target,
- int (*cmp)(void*,void*), void* data);
+ int (*cmp)(void*,void*), void* data);
struct ilist_item* ilist_ordered_insert(struct ilist* target,
int key, void* data);
struct ilist_item*
-ilist_ordered_insert_unique(struct ilist* target,
+ilist_ordered_insert_unique(struct ilist* target,
int (*cmp)(void*,void*),
- int key, void* data);
+ int key, void* data);
-void* ilist_pop(struct ilist* target);
+void* ilist_pop(struct ilist* target);
void* ilist_poll(struct ilist* target);
-void* ilist_get(struct ilist* target, int i);
+void* ilist_get(struct ilist* target, int i);
void* ilist_search(struct ilist* target, int key);
-void ilist_free(struct ilist* target);
+void ilist_free(struct ilist* target);
-void ilist_destroy(struct ilist* target);
+void ilist_destroy(struct ilist* target);
-void* ilist_remove(struct ilist* target, int key);
+void* ilist_remove(struct ilist* target, int key);
//// Output methods...
void ilist_dump(char* (f)(void*), struct ilist* target);
-void ilist_printf(char* format, struct ilist* target);
+void ilist_printf(char* format, struct ilist* target);
void ilist_fdump(FILE* file, char* (f)(void*), struct ilist* target);
void ilist_fprintf(FILE* file, char* format, struct ilist* target);
-void ilist_dumpkeys(struct ilist* target);
+void ilist_dumpkeys(struct ilist* target);
void ilist_xdumpkeys(struct ilist* target);
-void ilist_fdumpkeys(FILE* file, struct ilist* target);
+void ilist_fdumpkeys(FILE* file, struct ilist* target);
void ilist_output(char* (*f)(void*), struct ilist* target);
int ilist_snprintf(char* str, size_t size,
- char* format, struct ilist* target);
+ char* format, struct ilist* target);
int ilist_marshal(char* str, size_t size,
char* (f)(void*), struct ilist* target);
-char* ilist_serialize_ptrs(struct ilist* target);
+char* ilist_serialize_ptrs(struct ilist* target);
#endif
Modified: include/mpi_tools.h
===================================================================
--- include/mpi_tools.h 2010-05-24 19:20:40 UTC (rev 151)
+++ include/mpi_tools.h 2010-05-27 20:43:12 UTC (rev 152)
@@ -34,11 +34,6 @@
*/
void whoami(void);
-/**
- Output msgs in rank order.
- */
-void sync_output(int rank, int size, char* msg);
-
char* heap(char* s);
char* iheap(int i);
char* xheap(int i);
Modified: include/mpirpc.h
===================================================================
--- include/mpirpc.h 2010-05-24 19:20:40 UTC (rev 151)
+++ include/mpirpc.h 2010-05-27 20:43:12 UTC (rev 152)
@@ -42,7 +42,7 @@
int status;
char name[MPIRPC_MAX_NAME];
char args[MPIRPC_MAX_ARGS];
- char* blob;
+ void* blob;
int blob_length;
void* result;
int result_length;
@@ -75,7 +75,7 @@
{
int unique;
int length;
- char* result;
+ void* result;
MPI_Request request[4];
} MPIRPC_Value;
@@ -98,20 +98,20 @@
void* extras, void (*proceed)(MPIRPC*));
MPIRPC* MPIRPC_Call_blob(MPIRPC_Node target, char* name, char* args,
- char* blob, int blob_length,
+ void* blob, int blob_length,
void* extras, void (*proceed)(MPIRPC*));
-char* MPIRPC_Block(MPIRPC_Node target, char* name, char* args);
+void* MPIRPC_Block(MPIRPC_Node target, char* name, char* args);
-char* MPIRPC_Block_blob(MPIRPC_Node target, char* name, char* args,
- char* blob, int blob_length);
+void* MPIRPC_Block_blob(MPIRPC_Node target, char* name, char* args,
+ void* blob, int blob_length);
-char* MPIRPC_Wait(MPIRPC* rpc);
+void* MPIRPC_Wait(MPIRPC* rpc);
void MPIRPC_Null(MPIRPC_Node caller, int unique);
void MPIRPC_Return(MPIRPC_Node caller, int unique,
- char* result, int rlength);
+ void* result, int rlength);
MPIRPC_Node* MPIRPC_Node_create(MPI_Comm comm, int rank);
@@ -119,8 +119,9 @@
MPIRPC_Node* node);
void MPIRPC_Garbage_collect(void);
+bool MPIRPC_Garbage_collect_value(void);
-struct list* MPIRPC_Comms(void);
+// struct list* MPIRPC_Comms(void);
void MPIRPC_Dump(MPIRPC* rpc);
@@ -128,8 +129,6 @@
void MPIRPC_Dump_channels(void);
-MPIRPC* MPIRPC_Lookup(int unique);
-
void MPIRPC_Flush_returns(void);
char* MPIRPC_Comm_get_name(MPI_Comm comm);
@@ -142,14 +141,6 @@
void MPIRPC_Snooze_reset(void);
-//// Internal routines...
-
-bool MPIRPC_Garbage_collect_value(void);
-
-void MPIRPC_Value_free(MPIRPC_Value* value);
-
-MPIRPC_Value* MPIRPC_Value_create(int unique, char* result, int length);
-
//// Data structure helpers...
int MPIRPC_Node_cmp(void* node1, void* node2);
Modified: src/adts/About.txt
===================================================================
--- src/adts/About.txt 2010-05-24 19:20:40 UTC (rev 151)
+++ src/adts/About.txt 2010-05-27 20:43:12 UTC (rev 152)
@@ -1,16 +1,31 @@
+void _append(target, key)
+bool _add(target, key)
+ { false and do nothing if key found }
+bool _add_unique(target, cmp(), key)
+ {false and do nothing if key found }
bool _contains(target, key)
-bool _matches(target, cmp, data)
+bool _matches(target, cmp(), data)
DATA _search(target, key)
DATA _inspect(target, data, n)
+ _update(target, key, data, offset, length)
+ _set(target, key, data)
+DATA _poll() { head }
+DATA _pop() { tail }
+DATA _get(i)
-LIST _select_where(target, cmp, pattern)
-LIST _pop_where(target, cmp, pattern)
+LIST _select(target, key)
+LIST _pop(target, key)
+LIST _select_where(target, cmp(), pattern)
+LIST _pop_where(target, cmp(), pattern)
bool _remove(target, key)
+DATA _remove(target, key)
bool _erase(target, key, n) -> delete
-bool _clear(target) free all list items
+void _remove_where(target, cmp())
+
+bool _clear(target) remove and free all list items
bool _clobber(target) clear the list and free the data
bool _destroy(target) clobber and free the list
Modified: src/adts/ilist.c
===================================================================
--- src/adts/ilist.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/adts/ilist.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -18,12 +18,11 @@
return new_ilist;
}
-struct ilist_item*
-ilist_add(struct ilist* target, int key, void* data)
+void
+ilist_append(struct ilist* target, int key, void* data)
{
struct ilist_item* new_item = malloc(sizeof(struct ilist_item));
- if (! new_item)
- return NULL;
+ assert(new_item);
new_item->key = key;
new_item->data = data;
@@ -39,26 +38,38 @@
}
target->tail = new_item;
target->size++;
- return new_item;
}
/**
-
+ Set data
*/
-struct ilist_item*
-ilist_replace(struct ilist* target, int key, void* data)
+bool
+ilist_set(struct ilist* target, int key, void* data)
{
struct ilist_item* item;
for (item = target->head; item; item = item->next)
if (item->key == key)
{
item->data = data;
- return item;
+ return true;
}
- return ilist_add(target, key, data);
+ return false;
}
+/**
+ Add key/data pair to table.
+ If key exists, do nothing and return false
+*/
bool
+ilist_add(struct ilist* target, int key, void* data)
+{
+ if (ilist_contains(target, key))
+ return false;
+ ilist_append(target, key, data);
+ return true;
+}
+
+bool
ilist_contains(struct ilist* target, int key)
{
struct ilist_item* item;
@@ -210,6 +221,7 @@
}
/**
+ Remove and return tail data of list
This is expensive: singly linked list.
*/
void*
Modified: src/adts/itable.c
===================================================================
--- src/adts/itable.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/adts/itable.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -4,7 +4,7 @@
int
hash_int(int key, int table_size)
{
- return (key % table_size);
+ return (key % table_size);
}
struct itable*
@@ -14,12 +14,12 @@
struct itable *new_table = NULL;
new_table =
- (struct itable*) malloc(sizeof(struct itable));
+ (struct itable*) malloc(sizeof(struct itable));
if (! new_table)
return (NULL);
new_table->size = 0;
- new_table->capacity = capacity;
+ new_table->capacity = capacity;
new_table->array =
(struct ilist**) malloc(sizeof(struct ilist*) * capacity);
@@ -33,8 +33,8 @@
{
struct ilist* new_ilist = ilist_create();
if (! new_ilist)
- return NULL;
- new_table->array[i] = new_ilist;
+ return NULL;
+ new_table->array[i] = new_ilist;
}
return new_table;
@@ -44,7 +44,7 @@
void
itable_finalize(struct itable *old_table)
{
- // DOES NOT free ILISTS!
+ // DOES NOT free ILISTS!
free(old_table->array);
free(old_table);
return;
@@ -52,50 +52,53 @@
*/
/**
- Add key/data pair to table.
- If key exists, replace with new data.
-*/
-bool
+ Add key/data pair to table.
+ If key exists, do nothing and return false
+*/
+bool
itable_add(struct itable* table, int key, void* data)
{
int index = hash_int(key, table->capacity);
-
- struct ilist_item* new_item =
- ilist_replace(table->array[index], key, data);
- if (! new_item)
- return false;
+ bool result = ilist_add(table->array[index], key, data);
- table->size++;
-
- return true;
+ if (result)
+ table->size++;
+
+ return result;
}
/**
- @return The data or NULL if not found.
+ @return The data or NULL if not found.
*/
-void*
+void*
itable_search(struct itable* table, int key)
{
int index = hash_int(key, table->capacity);
- return ilist_search(table->array[index], key);
+ return ilist_search(table->array[index], key);
}
void*
itable_remove(struct itable* table, int key)
{
int index = hash_int(key, table->capacity);
- return ilist_remove(table->array[index], key);
+ void* result = ilist_remove(table->array[index], key);
+ if (result)
+ table->size--;
+ return result;
}
+/**
+ Should only be called on an empty table
+*/
void
itable_free(struct itable* target)
{
int i;
// NOTE_F;
- // SHOW_FI(target->size);
-
+ // SHOW_FI(target->size);
+
for (i = 0; i < target->capacity; i++)
{
ilist_free(target->array[i]);
@@ -110,8 +113,8 @@
int i;
// NOTE_F;
- // SHOW_FI(target->size);
-
+ // SHOW_FI(target->size);
+
for (i = 0; i < target->capacity; i++)
{
ilist_destroy(target->array[i]);
@@ -119,24 +122,24 @@
free(target->array);
free(target);
- // DONE;
+ // DONE;
}
/**
@param format specifies the output format for the data items
- */
+ */
void
itable_dump(char* format, struct itable* target)
{
int i;
- char s[200];
+ char s[200];
printf("{\n");
for (i = 0; i < target->capacity; i++)
{
if (target->array[i]->size > 0)
{
- ilist_snprintf(s, 200, "%s", target->array[i]);
- printf("%i: %s \n", i, s);
+ ilist_snprintf(s, 200, "%s", target->array[i]);
+ printf("%i: %s \n", i, s);
}
}
printf("}\n");
@@ -145,32 +148,32 @@
/** Dump ilist to string a la snprintf()
size must be greater than 2.
format specifies the output format for the data items
- internally allocates O(size) memory
+ internally allocates O(size) memory
returns int greater than size if size limits are exceeded
- indicating result is garbage
+ indicating result is garbage
*/
int itable_tostring(char* str, size_t size,
char* format, struct itable* target)
{
- int error = size+1;
- char* ptr = str;
+ int error = size+1;
+ char* ptr = str;
int i;
ptr += sprintf(str, "{\n");
- char* s = (char*) malloc(sizeof(char) * size);
-
+ char* s = (char*) malloc(sizeof(char) * size);
+
for (i = 0; i < target->size; i++)
{
int r = ilist_snprintf(s, size, format, target->array[i]);
if ((ptr-str) + r + 2 < size)
ptr += sprintf(ptr, "%s\n", s);
else
- return error;
+ return error;
}
sprintf(ptr, "}\n");
free(s);
- return (ptr-str);
+ return (ptr-str);
}
#ifdef DEBUG_ITABLE
@@ -178,20 +181,20 @@
int
main()
{
- char s[200];
+ char s[200];
struct itable* table = itable_create(30);
-
+
itable_add(table, 30, "hello30");
itable_add(table, 22, "hello22");
itable_add(table, 21, "hello21");
itable_add(table, 51, "hello51");
// itable_tostring(s, 200, "%s", table);
- itable_dump("%s", table);
+ itable_dump("%s", table);
itable_remove(table, 22);
- itable_dump("%s", table);
+ itable_dump("%s", table);
}
#endif
Modified: src/cmpi/accessor.c
===================================================================
--- src/cmpi/accessor.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi/accessor.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -58,6 +58,24 @@
return true;
}
+/*
+char*
+driver_access_ok(char* buffer, int length, FILE* file)
+{
+ char* result;
+
+ result = fgets(buffer, length, file);
+ if (!result)
+ return NULL;
+
+ if (strcmp(msg, "ok\n"))
+ {
+ printf("cmpi-cp: put(): received:_ %s %i\n", msg, strlen(msg));
+ return CMPI_ERROR_UNKNOWN;
+ }
+}
+*/
+
void
driver_access_fifo_close()
{
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi/cmpi.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -124,12 +124,10 @@
*data = found->data;
SHOW_P(*data);
result = found->length;
- printf("length: %i\n", result);
free(found);
}
else
{
- printf("LOADPAIR!\n");
result = cmpi_disk_loadpair(key, data);
if (*data != NULL)
@@ -163,7 +161,7 @@
if (kv)
{
cmpi_disk_storepair(kv->key, kv->data, length);
- printf("CACHE_DROP: %s\n", kv->key);
+ NOTE_S("CACHE_DROP: ", kv->key);
free(kv->key);
free(kv);
}
Modified: src/cmpi/driver.c
===================================================================
--- src/cmpi/driver.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi/driver.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -126,10 +126,12 @@
char* key = tokens->head->next->data;
char value[CMPI_VALUE_LENGTH];
int length;
- sscanf(tokens->head->next->next->data, "%i", &length);
+ int n;
+ n = sscanf(tokens->head->next->next->data, "%i", &length);
+ assert(n == 1);
SHOW_FSI(key, length);
- fprintf(driver->sink, "ok\n");
+ fprintf(driver->sink, "ok got: put-command\n");
fflush(driver->sink);
OK;
@@ -138,11 +140,9 @@
NOTE("got buffer");
cmpi_put(key, value, length);
- int error = fprintf(driver->sink, "ok\n");
- if (error == -1)
- printf("driver_put result error!\n");
+ int error = fprintf(driver->sink, "ok got: put-data\n");
+ assert(error >= 0);
fflush(driver->sink);
- NOTE("said ok\n");
}
void
@@ -159,17 +159,14 @@
if (value == NULL)
{
fprintf(driver->sink, "-1\n");
- printf("driver: doesn't exist\n");
}
else
{
- printf("driver: length: %i\n", length);
fprintf(driver->sink, "%i\n", length);
fflush(driver->sink);
buffer_to_stream(value, length, driver->sink);
}
fflush(driver->sink);
- printf("driver: streamed\n");
DONE;
}
Modified: src/cmpi/node.c
===================================================================
--- src/cmpi/node.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi/node.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -195,6 +195,10 @@
exit(1);
}
+ char* tag = cmpi_params_search("tag");
+ if (tag)
+ note_s("tag: ", tag);
+
int mode = cmpi_mode_select(mpi_rank, mpi_size, cmpi_nodes);
if (mode == CMPI_MODE_NODE)
{
@@ -205,7 +209,7 @@
else
{
NOTE("I am client");
- printf("client: %i @ %s\n", mpi_size, hostname);
+ printf("client: %i @ %s\n", mpi_rank, hostname);
cmpi_init_client();
cmpi_client_code();
}
Modified: src/cmpi-cp/cmpi-cp.c
===================================================================
--- src/cmpi-cp/cmpi-cp.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi-cp/cmpi-cp.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -1,6 +1,7 @@
#include <assert.h>
#include <string.h>
+#include <unistd.h>
#include <cmpi-cp.h>
@@ -10,11 +11,12 @@
#include <dmalloc.h>
void setup_dmalloc()
{
- dmalloc_logpath = strdup("dmalloc_cmpicp.out");
- printf("dmalloc_logpath: %s\n", dmalloc_logpath);
+ dmalloc_logpath = malloc(64);
+ strcpy(dmalloc_logpath, "dmalloc_cmpicp.out");
+ // printf("dmalloc_logpath: %s\n", dmalloc_logpath);
}
#else
-#define setup_malloc()
+#define setup_dmalloc()
#endif
char* target1;
@@ -22,20 +24,24 @@
int value_size;
+bool fifos_open = false;
+
void
finish(char* msg, int code)
{
+ // if (fifos_open)
+ // driver_access_fifo_close();
if (msg)
printf("%s\n", msg);
#ifdef DMALLOC
- printf("dmalloc_logpath: %s\n", dmalloc_logpath); \
+ dbg("dmalloc");
+ // printf("dmalloc_logpath: %s\n", dmalloc_logpath); \
dmalloc_shutdown(); \
dmalloc_log_unfreed();
#endif
exit(code);
}
-
void
cmpi_cp_args(int argc, char* argv[])
{
@@ -91,16 +97,19 @@
int
cmpi_cp_put(FILE* file, char* object)
{
- char key[CMPI_KEY_LENGTH+10];
+ char key[CMPI_KEY_LENGTH+16];
char data[value_size];
- char msg[100];
+ char msg[128];
int count = 0;
+ int total = 0;
+ char* result;
+ int i;
- debug(printf("cmpi_cmp_put()...\n"));
+ dbg("cmpi_cmp_put()...");
while (! feof(file))
{
- int total = 0;
+ total = 0;
while (!feof(file) &&
total < value_size)
{
@@ -112,57 +121,107 @@
if (total == 0)
break;
+ dbg("read file");
+
sprintf(key, "%s[%i]", object, count++);
- // printf("put: %s\n", key);
fprintf(to_cmpi, "put %s %i\n", key, total);
fflush(to_cmpi);
- fscanf(from_cmpi, "%s", msg);
- if (strcmp(msg, "ok") != 0)
+ fflush(stdout);
+ result = NULL;
+ i = 0;
+ while ((result = fgets(msg, 64, from_cmpi)) == NULL)
+ {
+ printf("cmpi-cp: put(): received: NULL\n");
+ if (i++ == 3)
+ return CMPI_ERROR_UNKNOWN;
+ sleep(1);
+ }
+ if (strcmp(msg, "ok got: put-command\n"))
+ {
+ printf("cmpi-cp: put(): received: %s %i\n", msg, strlen(msg));
return CMPI_ERROR_UNKNOWN;
+ }
buffer_to_stream(data, total, to_cmpi);
fflush(to_cmpi);
+
+ result = fgets(msg, 64, from_cmpi);
+ if (!result)
+ {
+ printf("cmpi-cp: put(): received after data post: NULL\n");
+ return CMPI_ERROR_UNKNOWN;
+ }
+ if (strcmp(msg, "ok got: put-data\n"))
+ {
+ printf("cmpi-cp: put(): received after data post: %s %i\n");
+ return CMPI_ERROR_UNKNOWN;
+ }
}
+ dbg("sent chunks");
+
sprintf(data, "DHT: %i", count);
- fprintf(to_cmpi, "put %s %i\n", object, (int) strlen(data));
+ total = (int) strlen(data)+1;
+ fprintf(to_cmpi, "put %s %i\n", object, total);
fflush(to_cmpi);
- fscanf(from_cmpi, "%s", msg);
- if (strcmp(msg, "ok") != 0)
+ result = NULL;
+ i = 0;
+ while ((result = fgets(msg, 64, from_cmpi)) == NULL)
+ {
+ printf("cmpi-cp: put(): received after metadata post: NULL\n");
+ if (i++ == 3)
+ return CMPI_ERROR_UNKNOWN;
+ sleep(1);
+ }
+ if (strcmp(msg, "ok got: put-command\n"))
+ {
+ printf("got bad response after metadata put: %s\n", msg);
return CMPI_ERROR_UNKNOWN;
- fprintf(to_cmpi, "%s", data);
+ }
+ buffer_to_stream(data, total, to_cmpi);
fflush(to_cmpi);
- char result[32];
- fscanf(from_cmpi, "%s\n", result);
-
- if (strncmp(result, "ok", 2))
+ fgets(msg, 64, from_cmpi);
+ if (strcmp(result, "ok got: put-data\n"))
+ {
+ printf("got bad response after metadata post: %s\n");
return CMPI_ERROR_UNKNOWN;
+ }
- // printf("cmpi_cp_put(): complete\n");
-
+ // printf("put() complete\n");
return CMPI_SUCCESS;
}
int
cmpi_cp_get(char* object, FILE* file)
{
- char message[64];
+ char msg[64];
char data[value_size];
- int count, c;
+ int count, c, n, i;
int length;
+ char* result;
- debug(printf("cmpi_cp_get()\n"));
- // fflush(stdout);
+ dbg("cmpi_cp_get()...");
+ fflush(stdout);
fprintf(to_cmpi, "get %s\n", object);
fflush(to_cmpi);
- // c = fscanf(from_cmpi, "%i\n", &length);
- fgets(message, 64, from_cmpi);
- //printf("message: %i\n", c);
- debug(printf("message: %s\n", message));
- sscanf(message, "%i", &length);
+ result = NULL;
+ i = 0;
+ while ((result = fgets(msg, 64, from_cmpi)) == NULL)
+ {
+ printf("cmpi-cp: get(): bad metadata length: NULL\n");
+ if (i++ == 3)
+ return CMPI_ERROR_UNKNOWN;
+ sleep(1);
+ }
+ n = sscanf(msg, "%i", &length);
+ if (n != 1)
+ {
+ printf("cmpi-cp: get(): bad metadata length: %s\n", msg);
+ return CMPI_ERROR_UNKNOWN;
+ }
if (length == -1)
return CMPI_DOESNT_EXIST;
@@ -173,19 +232,27 @@
c = sscanf(data, "DHT: %i\n", &count);
if (c != 1)
{
- printf("bad response: %s\n", data);
+ printf("cmpi-cp: get(): bad metadata: %s\n", data);
finish(NULL, 1);
}
- printf("count: %i\n", count);
+ // printf("count: %i\n", count);
for (c = 0; c < count; c++)
{
fprintf(to_cmpi, "get %s[%i]\n", object, c);
fflush(to_cmpi);
- fscanf(from_cmpi, "%i", &length);
- // printf("incoming length: %i\n", length);
- // fgetc(from_cmpi);
+ result = fgets(msg, 64, from_cmpi);
+ if (!result)
+ {
+ printf("got bad data length: NULL\n");
+ return CMPI_ERROR_UNKNOWN;
+ }
+ n = sscanf(msg, "%i", &length);
+ if (n != 1)
+ {
+ printf("cmpi-cp: get(): bad data length: %s\n", msg);
+ }
if (length == -1)
{
printf("not found: %s[%i]\n", object, c);
@@ -193,7 +260,6 @@
}
stream_to_buffer(data, length, from_cmpi);
- // printf("got buffer\n");
buffer_to_stream(data, length, file);
}
@@ -257,12 +323,18 @@
return result;
}
+/**
+ Exit codes:
+ 0 : success
+ 1 : error
+ 2 : not found
+*/
int
main(int argc, char* argv[])
{
- debug(printf("\ncmpi-cp start\n\n"));
+ dbg("\ncmpi-cp start\n");
- fflush(stdout);
+ // setup_dmalloc();
CMPI_CP_TYPE target1_type;
CMPI_CP_TYPE target2_type;
@@ -281,9 +353,10 @@
finish("cmpi-cp: given two files!", 1);
driver_access_fifo_setup(NULL);
- debug(printf("setup\n"));
+ dbg("setup");
driver_access_fifo();
- debug(printf("access\n"));
+ fifos_open = true;
+ dbg("access");
int result =
cmpi_cp_case(target1_type, object1, target2_type, object2);
@@ -292,10 +365,13 @@
{
// cmpi_get could not find the dht:// target
printf("does not exist: %s\n", target1);
- finish(NULL, 1);
+ finish(NULL, 2);
}
else if (result != CMPI_SUCCESS)
finish("error!\n", 1);
- return 0;
+ driver_access_fifo_close();
+
+ dbg("cmpi-cp: normal exit\n");
+ finish(NULL, 0);
}
Modified: src/cmpi-db/cmpi-db-fifo-quit.c
===================================================================
--- src/cmpi-db/cmpi-db-fifo-quit.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi-db/cmpi-db-fifo-quit.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -21,7 +21,8 @@
fscanf(from_cmpi, "%s\n", msg);
if (strcmp(msg, "ok") != 0)
{
- printf("error\n");
+ printf("error in cmpi-db-fifo-quit!\n");
+ printf("received: %s\n", msg);
return EXIT_FAILURE;
}
Modified: src/cmpi-db/cmpi-db-fifo.c
===================================================================
--- src/cmpi-db/cmpi-db-fifo.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/cmpi-db/cmpi-db-fifo.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -29,7 +29,7 @@
}
else
{
- NOTE("NOTIFICATION COMPLETE");
+ printf("cmpi-db ready\n");
}
}
@@ -40,9 +40,10 @@
char* s = getenv("DMALLOC_OPTIONS");
+ // printf("cmpi_client_code()\n");
NOTE("CMPI-DB-FIFO...");
- printf("DO: %s\n", s);
+ printf("DMALLOC_OPTIONS: %s\n", s);
wait_for_notification();
notify_next();
Modified: src/dense-1/dense.c
===================================================================
--- src/dense-1/dense.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/dense-1/dense.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -128,8 +128,10 @@
MPIRPC*
DENSE_Translate(MPIRPC_Node node, DENSE_ID id)
{
+ char args[16];
+ sprintf(args, "%i", id);
MPIRPC* rpc =
- MPIRPC_Call(node, heap("query_id"), iheap(id),
+ MPIRPC_Call(node, "query_id", args,
NULL, MPIRPC_PROCEED_NULL);
return rpc;
}
@@ -149,8 +151,10 @@
MPIRPC*
DENSE_Translate_k(MPIRPC_Node node, DENSE_ID id)
{
+ char args[32];
+ sprintf(args, "%X", id);
MPIRPC* rpc =
- MPIRPC_Call(node, "query_id_k", xheap(id),
+ MPIRPC_Call(node, "query_id_k", args,
NULL, MPIRPC_PROCEED_NULL);
return rpc;
}
@@ -199,7 +203,7 @@
DENSE_Retrieve(MPIRPC_Node node, char* key)
{
MPIRPC* rpc =
- MPIRPC_Call(node, "retrieve", heap(key),
+ MPIRPC_Call(node, "retrieve", key,
NULL, MPIRPC_PROCEED_NULL);
return rpc;
}
@@ -264,7 +268,7 @@
inlist_add(ranks, other_rank);
}
char* result = inlist_serialize(ranks);
- MPIRPC_Return(caller, unique, result, strlen(result));
+ MPIRPC_Return(caller, unique, result, strlen(result)+1);
}
void
@@ -284,12 +288,13 @@
handle_update(MPIRPC_Node caller, int unique, char* args,
char* blob, int blob_length)
{
- char* key = malloc(strlen(args));
- int offset;
+ char* key = malloc(strlen(args)+1);
SHOW_FSI(args, blob_length);
- sscanf(args, "%s %i", key, &offset);
+ int offset;
+ int n = sscanf(args, "%s %i", key, &offset);
+ assert(n == 2);
cmpi_cached_update(key, blob, offset, blob_length);
// DEBUG(lru_table_printdata("%s", cmpi_cache));
@@ -306,7 +311,7 @@
char* data;
int length = cmpi_cached_retrieve(args, &data);
- printdata("result1: ", data, length);
+ // printdata("result1: ", data, length);
char* result = malloc(CMPI_VALUE_LENGTH);
Modified: src/mpirpc/mpirpc.c
========================================...
[truncated message content] |
|
From: <jmw...@us...> - 2011-04-14 14:30:17
|
Revision: 165
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=165&view=rev
Author: jmwozniak
Date: 2011-04-14 14:30:08 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
Code cleanups, more notes...
Modified Paths:
--------------
Makefile.in
include/kda-2.h
include/mpirpc.h
src/kda-2/kademlia.c
src/mpi_tools/mpi_tools.c
src/mpirpc/module.mk.in
src/mpirpc/mpirpc.c
Modified: Makefile.in
===================================================================
--- Makefile.in 2011-03-03 23:13:44 UTC (rev 164)
+++ Makefile.in 2011-04-14 14:30:08 UTC (rev 165)
@@ -109,11 +109,11 @@
endif
ifeq ($(QUIET_COMPILE),1)
- # say a one-line description of the action, do not echo the command
+ # Prints a short description of the action, does not show command
Q=@echo
E=@
else
- # do not say the short Q lines, but do echo the entire command
+ # Just echo the entire command
Q=@echo >/dev/null
E=
endif
@@ -292,7 +292,7 @@
$(E)echo CFLAGS: $(CFLAGS)
$(E)echo IFLAGS: $(IFLAGS)
$(E)echo LIBS: $(LIBS)
- $(E)echo DEPENDS: $(DEPENDS)
+ $(E)echo CMPI_DEPS: $(CMPI_DEPS)
$(E)echo OPENSSL: $(OPENSSL_LOCATION)
$(E)echo GOSSIP_OBJS: $(GOSSIP_OBJS)
$(E)echo ADTS_OBJS: $(ADTS_OBJS)
@@ -351,8 +351,11 @@
CMPI_OBJS := $(TABLE_OBJS) $(MPIRPC_OBJS) $(CMPI_OBJS)
# $(DISKSIM_OBJS)
-CMPI_DEPS := $(patsubst %.o,%.d,$(CMPI_OBJS))
+MPIRPC_DEPS := $(patsubst %.o,%.d,$(MPIRPC_OBJS))
+CMPI_DEPS := $(patsubst %.o,%.d,$(CMPI_OBJS))
+deps: $(CMPI_DEPS)
+
################################################################
# Test cases
# Test rules are heavily based on the definitions above
@@ -397,7 +400,8 @@
# Grab any CFLAGS defined by the make stub for a particular file, and
# for the directory in which the source resides.
# modcflags = $(MODCFLAGS_$(call canonname,$(1))) \
-# $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1))) # -I$(srcdir)/$(call dirname,$(1))
+# $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1)))
+# -I$(srcdir)/$(call dirname,$(1))
# modldflags = $(MODLDFLAGS_$(call canonname,$(1))) \
# $(MODLDFLAGS_$(patsubst $(srcdir)/%,%,$(1)))
@@ -548,9 +552,9 @@
# NOTE: we wrap this in ifneq's in order to prevent the
# dependencies from being generated for special targets that don't
# require them
-ifeq (,$(filter clean distclean dist docs cscope tags nodep,$(MAKECMDGOALS)))
--include $(DEPENDS)
-endif
+#ifeq (,$(filter clean distclean dist docs cscope tags nodep,$(MAKECMDGOALS)))
+ include $(CMPI_DEPS)
+#endif
# add this as a make goal to disable rebuilding dependencies
.PHONY: nodep clean
@@ -571,9 +575,9 @@
$(Q) " SPLINT splint.out"
$(E) splint $(SPLINTOPTS) $(IFLAGS) -I $(MPI)/include $(CMPI_SRC) > splint.out
-%.p: %.c
- $(Q) " CPP $@"
- $(E) cpp $(IFLAGS) -I $(MPI)/include $(<) > $(@) # || rm -v $(@)
+#%.p: %.c
+# $(Q) " CPP $@"
+# $(E) cpp $(IFLAGS) -I $(MPI)/include $(<) > $(@) # || rm -v $(@)
install:: all install_doc
install -d $(prefix)/include
Modified: include/kda-2.h
===================================================================
--- include/kda-2.h 2011-03-03 23:13:44 UTC (rev 164)
+++ include/kda-2.h 2011-04-14 14:30:08 UTC (rev 165)
@@ -144,114 +144,8 @@
MPIRPC* KDA_Store(KDA_Neighbor* neighbor, char* key, char* value, int length);
-/**
- Instruct a node to retrieve a value.
-*/
MPIRPC* KDA_Retrieve(KDA_Neighbor* neighbor, char* key);
-//// Convenience prototypes to keep functions in decent order...
-KDA_ID make_id(int salt);
-// void join(MPIRPC_Node* node);
-char* id_tostring(void);
-void listen_loop(void);
-void bootstrap(MPIRPC_Node node);
-KDA_Neighbor* random_neighbor(void);
-int KDA_Neighbor_table_size(void);
-//// Neighbor management...
-
-/**
- Add neighbor to the neighbor table.
- @return false iff n is already in the neighbor table.
-*/
-bool neighbor_add(KDA_Neighbor* neighbor);
-
-/**
- Add neighbor to the client list.
-*/
-void client_add(KDA_Neighbor* client);
-
-/**
- Find neighbor in buckets and set its comm.
-*/
-void neighbor_set_node(KDA_Neighbor* neighbor, MPIRPC_Node node);
-
-/**
- Translate a dummy neighbor that is set to MPI_COMM_NULL to
- a good one in a bucket.
- TODO: Speed this up with an index or something.
-*/
-KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
-
-/**
- Use node to connect to neighbor.
-*/
-KDA_Neighbor* check_neighbor(MPIRPC_Node node, KDA_Neighbor* neighbor);
-
-/**
- Add neighbor to the neighbor table.
- Use node to link to the neighbor.
-*/
-void connect_neighbor(MPIRPC_Node* node, KDA_Neighbor* neighbor);
-
-void dump_bucket_ids(void);
-char* bucket_ids_tostring(void);
-void dump_buckets(void);
-char* buckets_tostring(void);
-
-//// Handlers...
-
-/**
- Generate info string for debugging
-*/
-void handle_info(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_join(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-void handle_link(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-void handle_find_node(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_neighbor(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_ping(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_query_id(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_query_id_k(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_store(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_retrieve(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_shutdown(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-
-/* SPECIFIC TO CONN TYPE
- void handle_accept(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
- void handle_connect(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
-*/
-
-// Synchronous methods...
-struct ilist* find_node(KDA_ID id);
-
-// Asynchronous methods and return services...
-void query_id(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id(KDA_Operation* op);
-void query_id_k(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id_k(KDA_Operation* op);
-
-// RPCs...
-
-void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
-
-// Proceeds...
-void proceed_find(MPIRPC* rpc);
-void proceed_ping(MPIRPC* rpc);
-void proceed_link(MPIRPC* rpc);
-
-
-// void proceed_
-
#endif
Modified: include/mpirpc.h
===================================================================
--- include/mpirpc.h 2011-03-03 23:13:44 UTC (rev 164)
+++ include/mpirpc.h 2011-04-14 14:30:08 UTC (rev 165)
@@ -2,24 +2,8 @@
#ifndef MPIRPC_H
#define MPIRPC_H
-#define _XOPEN_SOURCE 500
-
-#include <stdbool.h>
-#include <sys/types.h>
-#include <unistd.h>
-
#include <cmpi-config.h>
-#include <list.h>
-#include <itable.h>
-#include <hashtable.h>
-
-#include <mpi_tools.h>
-
-extern int unique;
-
-extern useconds_t snooze_max;
-
#define MPIRPC_MAX_NAME 128
#define MPIRPC_MAX_ARGS 256
#define MPIRPC_PROCEED_NULL ((void (*)(MPIRPC*)) 1)
Modified: src/kda-2/kademlia.c
===================================================================
--- src/kda-2/kademlia.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/kda-2/kademlia.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -3,6 +3,11 @@
#include <strings.h>
+/**
+ Uniquify KDA_Operations
+ */
+static int unique = 0;
+
KDA_ID id;
K_BUCKET k_bucket[KDA_SPACE_SIZE];
@@ -53,6 +58,101 @@
*/
int unique_client = 1;
+/**
+ Use node to connect to neighbor.
+*/
+KDA_Neighbor* check_neighbor(MPIRPC_Node node, KDA_Neighbor* neighbor);
+
+
+//// Neighbor management...
+
+/**
+ Add neighbor to the neighbor table.
+ @return false iff n is already in the neighbor table.
+*/
+bool neighbor_add(KDA_Neighbor* neighbor);
+
+/**
+ Add neighbor to the client list.
+*/
+void client_add(KDA_Neighbor* client);
+
+/**
+ Find neighbor in buckets and set its comm.
+*/
+void neighbor_set_node(KDA_Neighbor* neighbor, MPIRPC_Node node);
+
+/**
+ Translate a dummy neighbor that is set to MPI_COMM_NULL to
+ a good one in a bucket.
+ TODO: Speed this up with an index or something.
+*/
+KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
+
+void dump_bucket_ids(void);
+char* bucket_ids_tostring(void);
+void dump_buckets(void);
+char* buckets_tostring(void);
+
+static KDA_ID make_id(int salt);
+static char* id_tostring(void);
+static void listen_loop(void);
+static void bootstrap(MPIRPC_Node node);
+KDA_Neighbor* random_neighbor(void);
+
+int KDA_Neighbor_table_size(void);
+
+//// Handlers...
+
+/**
+ Generate info string for debugging
+*/
+void handle_info(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_join(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_link(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_find_node(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_neighbor(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_ping(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id_k(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_store(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_retrieve(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_shutdown(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+
+/* SPECIFIC TO CONN TYPE
+ void handle_accept(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
+ void handle_connect(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
+*/
+
+// Synchronous methods...
+struct ilist* find_node(KDA_ID id);
+
+// Asynchronous methods and return services...
+void query_id(MPIRPC_Node node, int unique, KDA_ID id);
+void return_query_id(KDA_Operation* op);
+void query_id_k(MPIRPC_Node node, int unique, KDA_ID id);
+void return_query_id_k(KDA_Operation* op);
+
+// RPCs...
+
+void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
+
+// Proceeds...
+void proceed_find(MPIRPC* rpc);
+void proceed_ping(MPIRPC* rpc);
+void proceed_link(MPIRPC* rpc);
+
void
KDA_Data(int alpha_in, int k_in)
{
@@ -371,7 +471,7 @@
NOTE_F;
KDA_Query* query = (KDA_Query*) malloc(sizeof(KDA_Query));
query->caller = caller;
- query->unique = unique;
+ query->unique = unique++;
query->service = service;
return query;
}
@@ -432,7 +532,8 @@
}
void
-handle_shutdown(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_shutdown(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
NOTE_F;
cmpi_quitting = true;
@@ -448,7 +549,8 @@
}
void
-handle_find_node(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_find_node(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
struct ilist_item* item;
NOTE_FS(args);
@@ -472,7 +574,8 @@
}
void
-handle_query_id(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_query_id(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
int object_id;
sscanf(args, "%X", &object_id);
@@ -498,7 +601,8 @@
}
void
-handle_query_id_k(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_query_id_k(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
int object_id;
sscanf(args, "%X", &object_id);
@@ -732,7 +836,7 @@
(KDA_Operation*) malloc(sizeof(KDA_Operation));
op->object_id = object_id;
- op->unique = ++unique;
+ op->unique = unique++;
op->name = name;
op->args = args;
op->k_closest = NULL;
@@ -858,7 +962,8 @@
No native method. Simply return.
*/
void
-handle_ping(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_ping(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
MPIRPC_Null(caller, unique);
}
Modified: src/mpi_tools/mpi_tools.c
===================================================================
--- src/mpi_tools/mpi_tools.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpi_tools/mpi_tools.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -79,6 +79,10 @@
}
*/
+/**
+ Print possibly binary data with nice handling of newline, tab,
+ NULL characters, and misc. non-printing characters
+ */
void
fprintdata(FILE* file, char* tag, char* data, int length)
{
@@ -102,12 +106,19 @@
fprintf(file, "]");
}
+/**
+ Print possibly binary data with nice handling of newline, tab,
+ NULL characters, and misc. non-printing characters
+ */
void
printdata(char* tag, char* data, int length)
{
fprintdata(stdout, tag, data, length);
}
+/**
+ Print the bits of a binary number
+ */
void
printbinary(unsigned int number)
{
@@ -135,10 +146,10 @@
unsigned int
ilog2(unsigned int j)
{
- int r = 0;
+ unsigned int r = 0;
while (j >>= 1)
r++;
- return (unsigned int) r;
+ return r;
}
unsigned int
Modified: src/mpirpc/module.mk.in
===================================================================
--- src/mpirpc/module.mk.in 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpirpc/module.mk.in 2011-04-14 14:30:08 UTC (rev 165)
@@ -3,8 +3,8 @@
MPIRPC_SRC := $(DIR)/mpirpc.c
-MPIRPC_OBJS := $(patsubst %.c, %.o, $(MPIRPC_SRC))
-MPIRPC_OBJS += $(ADTS_OBJS)
+MPIRPC_OBJS := $(patsubst %.c, %.o, $(MPIRPC_SRC))
+MPIRPC_OBJS += $(ADTS_OBJS)
MPIRPC = lib/libmpirpc.a
Modified: src/mpirpc/mpirpc.c
===================================================================
--- src/mpirpc/mpirpc.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpirpc/mpirpc.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -1,82 +1,87 @@
+#include <mpi_tools.h>
+
+#include <stdbool.h>
+#include <unistd.h>
+
+#include <itable.h>
+#include <hashtable.h>
+#include <list.h>
+
#include <mpirpc.h>
/**
- Functions MPIRPC_* may be exported at some point.
-*/
-
-/**
Counter to uniquify RPC calls.
*/
-int unique = 0;
+static int unique = 0;
/**
For MPIRPC_Check() : Irecv()...
*/
-MPI_Request check_request = MPI_REQUEST_NULL;
+static MPI_Request check_request = MPI_REQUEST_NULL;
/**
For MPIRPC_Check() : Irecv()...
*/
-int check_msg;
+static int check_msg;
-// Internal prototypes (just a convenience):
-void* MPIRPC_Remove(int index);
-void MPIRPC_Handle(int msg, MPIRPC_Node caller);
+// Internal prototypes:
+static void* MPIRPC_Remove(int index);
+static void MPIRPC_Handle(int msg, MPIRPC_Node caller);
/**
Sendable call control code.
*/
-int mpirpc_msg_call;
+static int mpirpc_msg_call;
/**
Sendable return control code.
*/
-int mpirpc_msg_return;
+static int mpirpc_msg_return;
/**
Sendable shutdown control code.
*/
-int mpirpc_msg_disconnect;
+static int mpirpc_msg_disconnect;
/**
Sendable OK control code.
*/
-int mpirpc_msg_ok;
+static int mpirpc_msg_ok;
/**
Sendable failure control code.
*/
-int mpirpc_msg_fail;
+static int mpirpc_msg_fail;
/**
Table of registered functions that may be called.
*/
-struct hashtable* portmap;
+static struct hashtable* portmap;
/**
Table of outstanding RPCs.
*/
-struct itable* rpctable;
+static struct itable* rpctable;
/**
Table of known channels.
*/
-struct list* channels;
+static struct list* channels;
/**
Return values to be garbage collected by MPIRPC_Check().
*/
-struct list* garbage_values;
+static struct list* garbage_values;
/**
Time in microseconds to snooze when MPIRPC_Check() finds nothing.
snooze() & reset_snooze() are called by MPIRPC_Wait().
*/
-unsigned int snooze_amount_reset = 0;
-unsigned int snooze_amount = 0;
+static unsigned int snooze_amount_reset = 0;
+static unsigned int snooze_amount = 0;
/**
The maximum amount of time to snooze in microseconds.
Default 500000us.
*/
-useconds_t snooze_max = 500000;
+static useconds_t snooze_max = 500000;
void
MPIRPC_Init()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2011-04-15 20:30:52
|
Revision: 175
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=175&view=rev
Author: jmwozniak
Date: 2011-04-15 20:30:46 +0000 (Fri, 15 Apr 2011)
Log Message:
-----------
Memory leak fixes- test-putgets now has no leaks
Modified Paths:
--------------
include/lru_table.h
src/adts/dpkm_list.c
src/adts/lru_table.c
src/cmpi/cmpi.c
src/dense-1/cmpi_dense.c
src/dense-1/dense.c
Modified: include/lru_table.h
===================================================================
--- include/lru_table.h 2011-04-15 20:29:44 UTC (rev 174)
+++ include/lru_table.h 2011-04-15 20:30:46 UTC (rev 175)
@@ -40,14 +40,16 @@
struct keyvalue* lru_table_poll(struct lru_table* table);
-void lru_table_free(struct lru_table* target);
+void lru_table_printf(char* format, struct lru_table* target);
-void lru_table_printf(char* format, struct lru_table* target);
-
void lru_table_fprintf(FILE* file, char* format, struct lru_table* target);
void lru_table_printdata(struct lru_table* target);
void lru_table_fprintdata(FILE* file, struct lru_table* target);
+void lru_table_destroy(struct lru_table* target);
+
+void lru_table_free(struct lru_table* target);
+
#endif
Modified: src/adts/dpkm_list.c
===================================================================
--- src/adts/dpkm_list.c 2011-04-15 20:29:44 UTC (rev 174)
+++ src/adts/dpkm_list.c 2011-04-15 20:30:46 UTC (rev 175)
@@ -905,7 +905,6 @@
Free this dpkm_list and its data but not its
extra pointers.
*/
-/*
void
dpkm_list_destroy(struct dpkm_list* target)
{
@@ -913,13 +912,14 @@
while (item)
{
struct dpkm_list_item* next = item->next;
- free(item->data);
+ free(item->key);
+ if (item->data)
+ free(item->data);
free(item);
item = next;
}
free(target);
}
-*/
/*
int
Modified: src/adts/lru_table.c
===================================================================
--- src/adts/lru_table.c 2011-04-15 20:29:44 UTC (rev 174)
+++ src/adts/lru_table.c 2011-04-15 20:30:46 UTC (rev 175)
@@ -68,6 +68,24 @@
}
/**
+ Frees structure and the data.
+*/
+void
+lru_table_destroy(struct lru_table* target)
+{
+ NOTE_F;
+ int i;
+ for (i = 0; i < target->capacity; i++)
+ dpkm_list_destroy(target->array[i]);
+ free(target->array);
+ // Do not free the keys or data in this list- they are referred
+ // to by the array entries
+ dpkm_list_free(target->lru);
+ free(target);
+}
+
+
+/**
Adds the key/data pair to the table.
Adds new item to end of table list and lru list.
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2011-04-15 20:29:44 UTC (rev 174)
+++ src/cmpi/cmpi.c 2011-04-15 20:30:46 UTC (rev 175)
@@ -218,7 +218,7 @@
// free(kv);
}
*/
- lru_table_free(cmpi_cache);
+ lru_table_destroy(cmpi_cache);
// NOTE("free cmpi_params");
hashtable_destroy(cmpi_params);
}
Modified: src/dense-1/cmpi_dense.c
===================================================================
--- src/dense-1/cmpi_dense.c 2011-04-15 20:29:44 UTC (rev 174)
+++ src/dense-1/cmpi_dense.c 2011-04-15 20:30:46 UTC (rev 175)
@@ -125,6 +125,8 @@
MPIRPC_Wait(lookup);
struct inlist* ranks = inlist_parse(lookup->result);
+ free(lookup->result);
+ MPIRPC_Free(lookup);
NOTE("got ranks: ");
DEBUG(inlist_printf(ranks));
@@ -194,6 +196,8 @@
struct inlist* ranks = inlist_parse(lookup->result);
int rank = inlist_random(ranks);
inlist_free(ranks);
+ free(lookup->result);
+ MPIRPC_Free(lookup);
MPIRPC_Node_make(MPI_COMM_WORLD, rank, &node);
MPIRPC* rpc = DENSE_Retrieve(node, key);
Modified: src/dense-1/dense.c
===================================================================
--- src/dense-1/dense.c 2011-04-15 20:29:44 UTC (rev 174)
+++ src/dense-1/dense.c 2011-04-15 20:30:46 UTC (rev 175)
@@ -266,6 +266,7 @@
inlist_add(ranks, other_rank);
}
char* result = inlist_serialize(ranks);
+ inlist_free(ranks);
MPIRPC_Return(caller, unique, result, strlen(result)+1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2011-04-15 21:36:54
|
Revision: 178
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=178&view=rev
Author: jmwozniak
Date: 2011-04-15 21:36:48 +0000 (Fri, 15 Apr 2011)
Log Message:
-----------
Remove some debugging output, 1 copy for DENSE
Modified Paths:
--------------
src/cmpi/node.c
src/dense-1/cmpi_dense.c
src/mpirpc/mpirpc.c
Modified: src/cmpi/node.c
===================================================================
--- src/cmpi/node.c 2011-04-15 21:35:14 UTC (rev 177)
+++ src/cmpi/node.c 2011-04-15 21:36:48 UTC (rev 178)
@@ -153,8 +153,8 @@
main(int argc, char* argv[])
{
gossip_debug_init();
- gossip_set_debug_mask(true,MASK_DEBUG|MASK_MPIRPC|MASK_ADTS|
- MASK_CMPI|MASK_DRIVER);
+ // gossip_set_debug_mask(true,MASK_DEBUG|MASK_MPIRPC|MASK_ADTS|
+ // MASK_CMPI|MASK_DRIVER);
gossip_enable_stdout();
// Comment out to achieve deterministic results:
Modified: src/dense-1/cmpi_dense.c
===================================================================
--- src/dense-1/cmpi_dense.c 2011-04-15 21:35:14 UTC (rev 177)
+++ src/dense-1/cmpi_dense.c 2011-04-15 21:36:48 UTC (rev 178)
@@ -23,7 +23,7 @@
DENSE_Read_params();
- DENSE_Init(3, 3);
+ DENSE_Init(1, 3);
return CMPI_SUCCESS;
}
Modified: src/mpirpc/mpirpc.c
===================================================================
--- src/mpirpc/mpirpc.c 2011-04-15 21:35:14 UTC (rev 177)
+++ src/mpirpc/mpirpc.c 2011-04-15 21:36:48 UTC (rev 178)
@@ -391,7 +391,6 @@
MPI_Recv(blob, blob_length, MPI_CHAR, caller.rank,
MPIRPC_TAG_ARGS, caller.comm, &status);
}
- printf("\t %s(%s) from %i \n", name, args, caller.rank);
char* (*handler)(MPIRPC_Node,int,char*,char*,int) =
hashtable_search(portmap, name);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2011-05-03 15:55:25
|
Revision: 202
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=202&view=rev
Author: jmwozniak
Date: 2011-05-03 15:55:18 +0000 (Tue, 03 May 2011)
Log Message:
-----------
Cleanup output
Modified Paths:
--------------
src/adts/list.c
src/kda-2/conn-A.c
src/kda-2/kademlia.c
Modified: src/adts/list.c
===================================================================
--- src/adts/list.c 2011-05-02 22:55:48 UTC (rev 201)
+++ src/adts/list.c 2011-05-03 15:55:18 UTC (rev 202)
@@ -529,7 +529,6 @@
while (head && head != good)
{
struct list_item* next = head->next;
- printf("free: %i \n", *(int*) head->data);
free(head);
target->size--;
head = next;
@@ -582,7 +581,6 @@
/**
Remove and return all elements from the list where
cmp(data,arg) == 0.
- @return true if one or more items were deleted.
*/
struct list*
list_pop_where(struct list* target,
@@ -618,7 +616,6 @@
while (head && head != good)
{
struct list_item* next = head->next;
- printf("free: %i \n", *(int*) head->data);
list_append(result, head);
target->size--;
head = next;
Modified: src/kda-2/conn-A.c
===================================================================
--- src/kda-2/conn-A.c 2011-05-02 22:55:48 UTC (rev 201)
+++ src/kda-2/conn-A.c 2011-05-03 15:55:18 UTC (rev 202)
@@ -43,7 +43,7 @@
free(result);
KDA_Neighbor neighbor;
KDA_Neighbor_make_id(other_id, node, &neighbor);
- bool added = neighbor_add(&neighbor);
+ neighbor_add(&neighbor);
MPIRPC_Node dummy = {0};
KDA_Join(dummy, &neighbor);
}
Modified: src/kda-2/kademlia.c
===================================================================
--- src/kda-2/kademlia.c 2011-05-02 22:55:48 UTC (rev 201)
+++ src/kda-2/kademlia.c 2011-05-03 15:55:18 UTC (rev 202)
@@ -810,8 +810,8 @@
op->k_closest = KDA_Closest(op->object_id);
- printf("local closest: \n");
- ilist_dump(KDA_Neighbor_id_tostring, op->k_closest);
+ DEBUG(printf("local closest: \n");
+ ilist_dump(KDA_Neighbor_id_tostring, op->k_closest););
return KDA_Find_node_again(op);
}
@@ -1037,7 +1037,6 @@
item = item->next)
{
KDA_Neighbor* neighbor = item->data;
- char* string = KDA_Neighbor_name(neighbor);
MPIRPC_Block(neighbor->node, "shutdown", NULL);
}
DONE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jmw...@us...> - 2018-02-02 16:08:21
|
Revision: 207
http://sourceforge.net/p/c-mpi/code/207
Author: jmwozniak
Date: 2018-02-02 16:08:18 +0000 (Fri, 02 Feb 2018)
Log Message:
-----------
Bug fixes
Modified Paths:
--------------
src/cmpi-db/cmpi-db-fifo.c
src/kda-2/kademlia.c
src/mpirpc/mpirpc.c
Modified: src/cmpi-db/cmpi-db-fifo.c
===================================================================
--- src/cmpi-db/cmpi-db-fifo.c 2018-02-02 16:08:01 UTC (rev 206)
+++ src/cmpi-db/cmpi-db-fifo.c 2018-02-02 16:08:18 UTC (rev 207)
@@ -2,7 +2,7 @@
#include <unistd.h>
#include <node.h>
-#include <driver.h>
+#include <cmpi-driver.h>
void
wait_for_notification(void)
Modified: src/kda-2/kademlia.c
===================================================================
--- src/kda-2/kademlia.c 2018-02-02 16:08:01 UTC (rev 206)
+++ src/kda-2/kademlia.c 2018-02-02 16:08:18 UTC (rev 207)
@@ -724,7 +724,7 @@
continue;
int d = XOR(neighbor->id, op->object_id);
- if (d < op->k_closest->tail->key);
+ if (d < op->k_closest->tail->key)
{
NOTE("improved");
op->improved = true;
Modified: src/mpirpc/mpirpc.c
===================================================================
--- src/mpirpc/mpirpc.c 2018-02-02 16:08:01 UTC (rev 206)
+++ src/mpirpc/mpirpc.c 2018-02-02 16:08:18 UTC (rev 207)
@@ -164,8 +164,6 @@
{
gossip_do(MASK_MPIRPC, NOTE_F);
- bool disconnected = false;
-
struct list* matches =
list_pop_where(channels, MPIRPC_Channel_comm_cmp, comm);
assert(matches->size == 1);
@@ -172,7 +170,6 @@
MPIRPC_Node* node = (MPIRPC_Node*) matches->head->data;
MPI_Comm_disconnect(&node->comm);
- disconnected = true;
list_destroy(matches);
return true;
@@ -926,4 +923,3 @@
hashtable_free(portmap);
itable_free(rpctable);
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|