Skip to content

Commit

Permalink
Wrote one of the callback functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil Samith Bysani committed Jan 20, 2009
1 parent 9304cfb commit 6450897
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/base/bang-module.c
Expand Up @@ -261,3 +261,19 @@ void* BANG_get_symbol(BANG_module *module, char *symbol) {
} else
return NULL;
}

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->outgoing_job(module->info,i);
}
}
}
}
19 changes: 18 additions & 1 deletion src/base/bang-module.h
Expand Up @@ -38,6 +38,23 @@ void* BANG_get_symbol(BANG_module *module, char *symbol);
*/
void BANG_run_module(BANG_module *module);

void BANG_module_callback_jobs_available(const BANG_module *module, uuid_t auth, uuid_t peer);
/**
* \param module The module of the peer.
* \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
* by auth.
*/
void BANG_module_callback_job_available(const BANG_module *module, uuid_t auth, uuid_t peer);

/**
* \param module The module of the auth.
* \param auth The authority getting asked for a job.
* \param peer The peer requesting a job.
*
* \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
3 changes: 2 additions & 1 deletion src/base/bang-routing.c
Expand Up @@ -102,6 +102,7 @@ void BANG_route_request_job(uuid_t peer, uuid_t authority) {
/* TODO: Make a request to peer. */
} else {
const BANG_module *module = sqlite3_column_blob(get_auth_route,2);
BANG_module_callback_job_request(module,authority,peer);
}
}
}
Expand All @@ -117,7 +118,7 @@ void BANG_route_assertion_of_authority(uuid_t authority, uuid_t peer) {
/* TODO: Make a request to peer. */
} else {
const BANG_module *module = sqlite3_column_blob(get_peer_route,2);
BANG_module_callback_jobs_available(module,authority,peer);
BANG_module_callback_job_available(module,authority,peer);
}
}
}
Expand Down

0 comments on commit 6450897

Please sign in to comment.