[C-MPI-commits] SF.net SVN: c-mpi:[152] src
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
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
===================================================================
--- src/mpirpc/mpirpc.c 2010-05-24 19:20:40 UTC (rev 151)
+++ src/mpirpc/mpirpc.c 2010-05-27 20:43:12 UTC (rev 152)
@@ -191,7 +191,7 @@
MPIRPC*
MPIRPC_Create(MPIRPC_Node target, char* name, char* args,
- char* blob, int blob_length,
+ void* blob, int blob_length,
void* extras, void (*proceed)(MPIRPC*))
{
// gossip_do(MASK_MPIRPC, NOTE_F);
@@ -254,7 +254,7 @@
*/
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* rpc))
{
assert(target.comm != MPI_COMM_NULL);
@@ -295,7 +295,8 @@
MPIRPC_TAG_ARGS, target.comm, &rpc->request[7]);
rpc->status = MPIRPC_STATUS_CALLED;
- itable_add(rpctable, rpc->unique, rpc);
+ bool result = itable_add(rpctable, rpc->unique, rpc);
+ assert(result);
return rpc;
}
@@ -307,18 +308,18 @@
Copied into MPIRPC.
@param args The args to send. Copied into MPIRPC.
*/
-char*
+void*
MPIRPC_Block(MPIRPC_Node target, char* name, char* args)
{
//gossip_do(MASK_MPIRPC, NOTE_FS(name));
return MPIRPC_Block_blob(target, name, args, NULL, 0);
}
-char*
+void*
MPIRPC_Block_blob(MPIRPC_Node target, char* name, char* args,
- char* blob, int blob_length)
+ void* blob, int blob_length)
{
- char* result;
+ void* result;
gossip_do(MASK_MPIRPC, NOTE_FS(name));
MPIRPC* rpc = MPIRPC_Call_blob(target, name, args,
blob, blob_length, NULL, NULL);
@@ -408,6 +409,8 @@
MPIRPC_Return(caller, unique, NULL, -1);
}
+MPIRPC_Value* MPIRPC_Value_create(int unique, void* result, int length);
+
/**
Return result to caller for unique RPC.
result is asynchronously freed upon completion.
@@ -415,7 +418,7 @@
*/
void
MPIRPC_Return(MPIRPC_Node caller, int unique,
- char* result, int length)
+ void* result, int length)
{
gossip_do(MASK_MPIRPC, SHOW_FIII(caller.rank, unique, length));
@@ -551,7 +554,7 @@
}
MPIRPC_Value*
-MPIRPC_Value_create(int unique, char* result, int length)
+MPIRPC_Value_create(int unique, void* result, int length)
{
MPIRPC_Value* value = malloc(sizeof(MPIRPC_Value));
@@ -592,7 +595,7 @@
MPIRPC_Free() or MPIRPC_Destroy() as proceed-functions.
@return rpc's result when obtained.
*/
-char*
+void*
MPIRPC_Wait(MPIRPC* rpc)
{
int unique = rpc->unique;
@@ -626,11 +629,13 @@
/**
Lookup an outstanding function.
*/
+/*
MPIRPC*
MPIRPC_Lookup(int index)
{
return itable_search(rpctable, index);
}
+*/
/**
Called by MPIRPC_Retrieve().
@@ -668,6 +673,8 @@
while (MPIRPC_Garbage_collect_value());
}
+void MPIRPC_Value_free(MPIRPC_Value* value);
+
/**
@return true iff we found and freed a sent value.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|