Skip to content

Commit

Permalink
Fixed conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
basilkohler committed May 27, 2014
2 parents 0a4c914 + 12a7a4c commit e395714
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
14 changes: 12 additions & 2 deletions ccnl-ext-nfn.c
Expand Up @@ -38,7 +38,7 @@ ccnl_nfn_count_required_thunks(char *str)
tok += 4;
++num;
}
DEBUGMSG(99, "Number of required Thunks is: %d\n", num);
DEBUGMSG(99, "Number of required Thunks is: %d\n", num);
return num;
}

Expand All @@ -65,6 +65,11 @@ ccnl_nfn_continue_computation(struct ccnl_relay_s *ccnl, int configid){
}
}


if(!config->start_request){
//this is not the node to continue the computation
return;
}
if(config->thunk && CCNL_NOW() > config->endtime){
DEBUGMSG(49, "NFN: Exit computation: timeout when resolving thunk\n");
DBL_LINKED_LIST_REMOVE(configuration_list, config);
Expand Down Expand Up @@ -111,12 +116,17 @@ ccnl_nfn(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
struct ccnl_prefix_s *original_prefix;
ccnl_nfn_copy_prefix(prefix, &original_prefix);
int thunk_request = 0;
int start_request = 0;
int num_of_required_thunks = 0;

if(!memcmp(prefix->comp[prefix->compcnt-2], "THUNK", 5))
{
thunk_request = 1;
}
else if(!memcmp(prefix->comp[prefix->compcnt-2], "USETHUNK", 8)){
thunk_request = 1;
start_request = 1;
}
char str[CCNL_MAX_PACKET_SIZE];
int i, len = 0;

Expand All @@ -138,7 +148,7 @@ ccnl_nfn(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,

++numOfRunningComputations;
restart:
res = Krivine_reduction(ccnl, str, thunk_request,
res = Krivine_reduction(ccnl, str, thunk_request, start_request,
num_of_required_thunks, &config, original_prefix);

//stores result if computed
Expand Down
3 changes: 2 additions & 1 deletion krivine-common.c
Expand Up @@ -54,7 +54,7 @@ new_machine_state(int thunk_request, int num_of_required_thunks){
}

struct configuration_s *
new_config(char *prog, struct environment_s *global_dict, int thunk_request,
new_config(char *prog, struct environment_s *global_dict, int thunk_request, int start_request,
int num_of_required_thunks, struct ccnl_prefix_s *prefix, int configid){
struct configuration_s *ret = malloc(sizeof(struct configuration_s));
ret->prog = prog;
Expand All @@ -64,6 +64,7 @@ new_config(char *prog, struct environment_s *global_dict, int thunk_request,
ret->global_dict = global_dict;
ret->fox_state = new_machine_state(thunk_request, num_of_required_thunks);
ret->configid = configid;
ret->start_request = start_request;
ret->prefix = prefix;
ret->thunk = 0;
ret->thunk_time = NFN_DEFAULT_WAITING_TIME;
Expand Down
1 change: 1 addition & 0 deletions krivine-common.h
Expand Up @@ -56,6 +56,7 @@ struct fox_machine_state_s{

struct configuration_s{
int configid;
int start_request;
char *prog;
struct stack_s *result_stack;
struct stack_s *argument_stack;
Expand Down
8 changes: 6 additions & 2 deletions krivine.c
Expand Up @@ -908,7 +908,7 @@ setup_global_environment(struct environment_s **env){

unsigned char *
Krivine_reduction(struct ccnl_relay_s *ccnl, char *expression, int thunk_request,
int num_of_required_thunks, struct configuration_s **config,
int start_request, int num_of_required_thunks, struct configuration_s **config,
struct ccnl_prefix_s *prefix){
DEBUGMSG(99, "Krivine_reduction()\n");
int steps = 0;
Expand All @@ -923,12 +923,16 @@ Krivine_reduction(struct ccnl_relay_s *ccnl, char *expression, int thunk_request
prog = malloc(len*sizeof(char));
sprintf(prog, "CLOSURE(halt);RESOLVENAME(%s)", expression);
if(!*config){
*config = new_config(prog, global_dict, thunk_request,
DEBUGMSG(99, "PREFIX %s", ccnl_prefix_to_path2(prefix));
*config = new_config(prog, global_dict, thunk_request, start_request,
num_of_required_thunks, prefix, configid);
DBL_LINKED_LIST_ADD(configuration_list, *config);
restart = 0;
--configid;
}
if(num_of_required_thunks == 0){
ccnl_nfn_reply_thunk(ccnl, *config);
}
DEBUGMSG(99, "Prog: %s\n", (*config)->prog);

while ((*config)->prog && !halt && (*config)->prog != 1){
Expand Down

0 comments on commit e395714

Please sign in to comment.