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.6 and 1.7

version 1.6, 2007/05/29 03:35:25 version 1.7, 2007/05/31 22:04:19
Line 28  void *recvthread(void *arg) { Line 28  void *recvthread(void *arg) {
     swaplinks_p swp = (swaplinks_p)arg;      swaplinks_p swp = (swaplinks_p)arg;
     struct sockaddr_ns peer;      struct sockaddr_ns peer;
     socklen_t len = sizeof(peer);      socklen_t len = sizeof(peer);
   flow_t *flows, *newflow, *ptr;    flow_t *flows= NULL, *newflow= NULL, *ptr= NULL;
   char tmp[128];    char tmp[128], buf[2048];
     int time = 0, load = 0, delta;      int time = 0, load = 0, delta;
   
       buf[0] = 0;
   
     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++; delta = 0;              time++; delta = 0;
Line 39  void *recvthread(void *arg) { Line 41  void *recvthread(void *arg) {
             newflow->duration = atoi(strtok(tmp,";"));              newflow->duration = atoi(strtok(tmp,";"));
             newflow->weight = atoi(strtok(NULL,";"));              newflow->weight = atoi(strtok(NULL,";"));
             strncpy(newflow->source,peer.user+4,sizeof(newflow->source));              strncpy(newflow->source,peer.user+4,sizeof(newflow->source));
           if(s) fprintf(s,"%d ACCEPTED FLOW from %s: d%d/w%d\n",num,newflow->source,newflow->duration,newflow->weight);            sprintf(buf,"->%d/%d<->",newflow->duration,newflow->weight);
           for(ptr = flows; ptr; ptr = ptr->next) {            for(ptr = flows; ptr; ptr = ptr->next) {
 sprintf(buf,"%s%d:%d<->",buf,ptr->duration,ptr->weight);
                 if(--ptr->duration == 0) {                  if(--ptr->duration == 0) {
                     load -= ptr->weight;                      load -= ptr->weight;
                     delta -= ptr->weight;                      delta -= ptr->weight;
          if(ptr->last)ptr->last->next = ptr->next;           if(ptr->last){
elseflows = ptr->next;      ptr->last->next = ptr->next;
 ptr->next->last = ptr->last;
            }
                     else{
       flows = ptr->next;
 flows->last = NULL;
            }
            if(s) fprintf(s,"%d EXPIRED FLOW from %s:d%d/w%d\n",num,ptr->source,ptr->duration,ptr->weight);             if(s) fprintf(s,"%d EXPIRED FLOW from %s:d%d/w%d\n",num,ptr->source,ptr->duration,ptr->weight);
            free(ptr);             free(ptr);
                 }                  }
             }              }
               sprintf(buf,"%s||\n",buf);
   
               if(s) fprintf(s,"%d ACCEPTED FLOW from %s: d%d/w%d\n",num,newflow->source,newflow->duration,newflow->weight);
               if(s) fprintf(s,"%s",buf);
   
             load += newflow->weight;              load += newflow->weight;
             delta += newflow->weight;              delta += newflow->weight;
             newflow->next = flows;              newflow->next = flows;
               if(newflow->next) newflow->next->last = newflow;
             flows = newflow;              flows = newflow;
             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,delta);
         }          }
Line 89  int main(int argc, char **argv) { Line 104  int main(int argc, char **argv) {
     nutss_config_set(NUTSS_CONFIG_SIGPROXY, tmp, strlen(tmp));      nutss_config_set(NUTSS_CONFIG_SIGPROXY, tmp, strlen(tmp));
   
     sprintf(tmp, "output/data_node%d.txt", num); f = fopen(tmp,"w");      sprintf(tmp, "output/data_node%d.txt", num); f = fopen(tmp,"w");
   sprintf(tmp, "output/output_node%d.txt", num); s = fopen(tmp,"w");//    sprintf(tmp, "output/output_node%d.txt", num); s = fopen(tmp,"w");
     if (f == NULL) f = stderr;      if (f == NULL) f = stderr;
     if (s == NULL) s = stdout;      if (s == NULL) s = stdout;
   

Removed from v.1.6  
changed lines
  Added in v.1.7


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