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.8 and 1.9

version 1.8, 2007/05/31 22:42:53 version 1.9, 2007/06/01 01:31:43
Line 30  void *recvthread(void *arg) { Line 30  void *recvthread(void *arg) {
     socklen_t len = sizeof(peer);      socklen_t len = sizeof(peer);
     flow_t *flows = NULL, *newflow = NULL, *ptr = NULL;      flow_t *flows = NULL, *newflow = NULL, *ptr = NULL;
     char tmp[128], buf[2048];      char tmp[128], buf[2048];
   int time = 0, load = 0, delta;    int time = 0, load = 0, delta, expiration;
   
     buf[0] = 0;      buf[0] = 0;
   
Line 43  void *recvthread(void *arg) { Line 43  void *recvthread(void *arg) {
             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));
             snprintf(buf,2048,"->%d:%d<->",newflow->duration,newflow->weight);              snprintf(buf,2048,"->%d:%d<->",newflow->duration,newflow->weight);
           for(ptr = flows; ptr;ptr = ptr->next) {            for(ptr = flows; ptr;) {
        sprintf(buf,"%s%d:%d<->",buf,ptr->duration,ptr->weight);         sprintf(buf,"%s%d:%d<->",buf,ptr->duration,ptr->weight);
          expiration = 0;
                 if(--ptr->duration == 0) {                  if(--ptr->duration == 0) {
                     load -= ptr->weight;                      load -= ptr->weight;
                     delta -= ptr->weight;                      delta -= ptr->weight;
Line 52  void *recvthread(void *arg) { Line 53  void *recvthread(void *arg) {
       ptr->last->next = ptr->next;        ptr->last->next = ptr->next;
                     else {                      else {
       flows = ptr->next;        flows = ptr->next;
     flows->last = NULL;      if(flows) flows->last = NULL;
            }             }
            if(ptr->next)             if(ptr->next)
       ptr->next->last = ptr->last;        ptr->next->last = ptr->last;
   
          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);expiration = 1;
                 }                  }
          ptr = ptr->next;
          if(expiration) free(ptr);
   
             }              }
             sprintf(buf,"%s||\n",buf);              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,"%d ACCEPTED FLOW from %s:d%d/w%d\n",num,newflow->source,newflow->duration,newflow->weight);
if(s) fprintf(s,"%s",buf);//            if(s) fprintf(s,"%s",buf);
   
             load += newflow->weight;              load += newflow->weight;
             delta += newflow->weight;              delta += newflow->weight;
Line 108  int main(int argc, char **argv) { Line 112  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;
   
Line 130  int main(int argc, char **argv) { Line 134  int main(int argc, char **argv) {
   
     snprintf(tmp, sizeof(tmp), "%d;%d;", duration, weight);      snprintf(tmp, sizeof(tmp), "%d;%d;", duration, weight);
   
   while (time++ <limit) { // (i-- != 0) {    while (time++ <2*limit) { // (i-- != 0) {
         swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0);          swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0);
       sleep(1);        sleep(5);
     }      }
   
     if(s) fprintf(s,"%d DONE SENDING\n",num);      if(s) fprintf(s,"%d DONE SENDING\n",num);
Line 142  int main(int argc, char **argv) { Line 146  int main(int argc, char **argv) {
     if(f) fclose(f);      if(f) fclose(f);
     if(s) fclose(s);      if(s) fclose(s);
   
//    if(num == 1) system("echo \" \" | mail -s\"experiment done!\" ths22@cs.cornell.edu");    if(num == 1) system("echo \" \" | mail -s\"experiment done!\" ths22@cs.cornell.edu");
   
     return 0;      return 0;
 }  }

Removed from v.1.8  
changed lines
  Added in v.1.9


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