From 05edd53fa814f54aadd72b68c772e777e8de1f52 Mon Sep 17 00:00:00 2001 From: Nikhil Samith Bysani Date: Mon, 19 Jan 2009 23:45:55 -0600 Subject: [PATCH] Library now compiles, I dunno what it would do if you actual ran it though. Anyway, modules no longer compile. --- src/base/bang-module.c | 21 +++++++++++++++++++-- src/base/bang-module.h | 3 +-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/base/bang-module.c b/src/base/bang-module.c index ecc6086..da8f490 100644 --- a/src/base/bang-module.c +++ b/src/base/bang-module.c @@ -48,7 +48,7 @@ static unsigned char* module_hash(char *path) { unsigned char *md = (unsigned char*) calloc(SHA_DIGEST_LENGTH,sizeof(unsigned char)); - static EVP_MD_CTX *ctx = NULL; + static EVP_MD_CTX *ctx = NULL; ctx = (ctx == NULL) ? EVP_MD_CTX_create() : ctx; EVP_MD_CTX_init(ctx); @@ -83,7 +83,7 @@ static BANG_api* get_BANG_api() { if (api == NULL) { /*If we forget to do something in this function, this will force * the program to segfault when a module calls a function - * we were susposed to give them. + * we were susposed to give them. * calloc sets everything to zero*/ /* This is memory will 'leak' we will let the OS clean it up, because @@ -265,6 +265,23 @@ void* BANG_get_symbol(BANG_module *module, char *symbol) { void BANG_module_callback_job_available(const BANG_module *module, uuid_t auth, uuid_t peer) { assert(module != NULL); + /* Make sure they have the right module. */ + if (uuid_compare(module->info->peers_info->uuids[module->info->my_id],auth) == 0) { + + /* TODO: USE LOCKS! */ + int i = 0; + for (i = 0; i < module->info->peers_info->peer_number; ++i) { + if (uuid_compare(module->info->peers_info->uuids[i],peer) == 0) { + module->callbacks->jobs_available(module->info,i); + } + } + } +} + + +void BANG_module_callback_job_request(const BANG_module *module, uuid_t auth, uuid_t peer) { + assert(module != NULL); + /* Make sure they have the right module. */ if (uuid_compare(module->info->peers_info->uuids[module->info->my_id],auth) == 0) { diff --git a/src/base/bang-module.h b/src/base/bang-module.h index 8429a0a..c0994cb 100644 --- a/src/base/bang-module.h +++ b/src/base/bang-module.h @@ -43,7 +43,7 @@ void BANG_run_module(BANG_module *module); * \param auth The uuid of the authority saying a job is available. * \param peer The uuid of the peer being told that a job is available at auth. * - * \brief A callback to tell peer with module that there is a job availabel held + * \brief A callback to tell peer with module that there is a job available held * by auth. */ void BANG_module_callback_job_available(const BANG_module *module, uuid_t auth, uuid_t peer); @@ -56,5 +56,4 @@ void BANG_module_callback_job_available(const BANG_module *module, uuid_t auth, * \brief A callback to tell the authority that the uuid peer wants a job. */ void BANG_module_callback_job_request(const BANG_module *module, uuid_t auth, uuid_t peer); - #endif