Log In
New Account
  
 
Home My Page Project Tree Code Snippets Project Openings NUTSS
 
 
Summary Tracker Lists CVS Files
 

CVS | Administration

Diff for /libnutss/examples/slinks_variable_load.c between versions 1.3 and 1.4

version 1.3, 2007/05/28 22:30:50 version 1.4, 2007/05/29 02:06:25
Line 16 Line 16
 typedef struct flow {  typedef struct flow {
     int duration;      int duration;
     int weight;      int weight;
       char source[256];
     struct flow *next, *last;      struct flow *next, *last;
 } flow_t;  } flow_t;
   
Line 29  void *recvthread(void *arg) { Line 30  void *recvthread(void *arg) {
     socklen_t len = sizeof(peer);      socklen_t len = sizeof(peer);
     flow_t *flows, *newflow, *ptr;      flow_t *flows, *newflow, *ptr;
     char tmp[128];      char tmp[128];
   int time = 0, load = 0;    int time = 0, load = 0, delta;
   
     while(time < limit) {      while(time < limit) {
         if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {          if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {
           time++;            time++;delta = 0;
             newflow = (flow_t*)calloc(1,sizeof(flow_t));              newflow = (flow_t*)calloc(1,sizeof(flow_t));
             newflow->duration = atoi(strtok(tmp,";"));              newflow->duration = atoi(strtok(tmp,";"));
             newflow->weight = atoi(strtok(NULL,";"));              newflow->weight = atoi(strtok(NULL,";"));
           fprintf(s,"%d ACCEPTED FLOW from %s:%d/%d\n",num,peer.user+4,newflow->duration,newflow->weight);            strncpy(newflow->source,peer.user+4,256);
             fprintf(s,"%d ACCEPTED FLOW from %s:d%d/w%d\n",num,newflow->source,newflow->duration,newflow->weight);
             for(ptr = flows; ptr; ptr = ptr->next) {              for(ptr = flows; ptr; ptr = ptr->next) {
                 if(--ptr->duration == 0) {                  if(--ptr->duration == 0) {
                     load -= ptr->weight;                      load -= ptr->weight;
                   if(ptr->last) ptr->last->next = ptr->next;                    delta -= ptr->weight;
            if(ptr->last) ptr->last->next = ptr->next;
                     else          flows = ptr->next;                      else          flows = ptr->next;
          if(f) fprintf(f,"%d\t%d\t-%d\n",time,load,ptr->weight);           if(s) fprintf(s,"%d EXPIRED FLOW from%s:s%s/w%d\n",num,newflow->source,newflow->duration,
// want to see that things are expiring when they should        newflow->weight);
//           if(s) fprintf(s,"%d EXPIRED FLOW from 
            free(ptr);             free(ptr);
                 }                  }
             }              }
             load += newflow->weight;              load += newflow->weight;
               delta += newflow->weight;
             newflow->next = flows;              newflow->next = flows;
             flows = newflow;              flows = newflow;
           if(s) fprintf(s,"Node: %d Time: %d Load: %d\n",num,time,load);            if(f) fprintf(f,"%d\t%d\t%d\n",time,load,delta);
           if(f) fprintf(f,"%d\t%d\t+%d\n",time,load,newflow->weight); 
         }          }
     }      }
     fprintf(s,"RECV THREAD DONE\n");      fprintf(s,"RECV THREAD DONE\n");

Removed from v.1.3  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
 

GForge.cis.cornell.edu is brought to you by

Cornell Computing and Information Science


Powered By GForge Collaborative Development Environment