/[pdpsoft]/trunk/grid-mw-security/ees/src/aos/aos.c
ViewVC logotype

Diff of /trunk/grid-mw-security/ees/src/aos/aos.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1568 by aramv, Mon Mar 15 17:17:18 2010 UTC revision 1569 by aramv, Tue Mar 16 17:35:17 2010 UTC
# Line 33  aos_storage_t * aos_get_storage(){ Line 33  aos_storage_t * aos_get_storage(){
33    }    }
34    
35    /*  Try to get TLS */    /*  Try to get TLS */
36    if((storage = pthread_getspecific(_aos_key)) == 0) {    storage = pthread_getspecific(_aos_key);
37      if(storage == 0) {
38      /* Create new TLS */      /* Create new TLS */
39      if((storage = calloc(1, sizeof(aos_storage_t)))){      if((storage = calloc(1, sizeof(aos_storage_t)))){
40        storage->last_context = NULL;        storage->last_context = NULL;
41        pthread_setspecific(_aos_key, storage);        pthread_setspecific(_aos_key, storage);
42          return storage;
43      }      }
44      } else {
45        return storage;
46    }    }
47    return storage;    return NULL;
48  }  }
49    
50  /**  /**
# Line 64  EES_RC aos_free_storage(aos_storage_t* s Line 68  EES_RC aos_free_storage(aos_storage_t* s
68      attribute = context->list_attributes;      attribute = context->list_attributes;
69      while(attribute){      while(attribute){
70        next_attribute = attribute->next;        next_attribute = attribute->next;
71          /*free(attribute->id);*/
72          free(attribute->issuer);
73          /*free(attribute->type);*/
74        if(attribute->needs_free){        if(attribute->needs_free){
75          eef_log(LOG_DEBUG, "Freeing arg data %i at %p\n",attribute_count, attribute->data);          eef_log(LOG_DEBUG, "Freeing arg data %i at %p\n",attribute_count, attribute->data);
76          free(attribute->data);          free(attribute->data);
         free(attribute);  
       } else {  
         free(attribute);  
77        }        }
78          free(attribute);
79        attribute = next_attribute;        attribute = next_attribute;
80        attribute_count++;        attribute_count++;
81      }      }
# Line 119  EES_RC addContext(aos_context_t* context Line 124  EES_RC addContext(aos_context_t* context
124  }  }
125    
126  EES_RC rewindContexts(aos_storage_t* storage){  EES_RC rewindContexts(aos_storage_t* storage){
127      if(storage == NULL){
128        storage = aos_get_storage();
129      }
130    storage->last_context = NULL;    storage->last_context = NULL;
131    return EES_SUCCESS;    return EES_SUCCESS;
132  }  }
# Line 130  aos_context_t * getNextContext(aos_conte Line 138  aos_context_t * getNextContext(aos_conte
138    aos_context_t* current_context = NULL;    aos_context_t* current_context = NULL;
139    aos_storage_t* current_storage = NULL;    aos_storage_t* current_storage = NULL;
140    
141    if(storage){    if(storage != NULL){
142      /* Using passed storage */      /* Using passed storage */
143      current_storage = storage;      current_storage = storage;
144    } else {    } else {
145      /* Using TLS getter */      /* Using TLS getter */
146      current_storage = aos_get_storage();      current_storage = aos_get_storage();
147    }    }
148      
149    if(current_storage->last_context != NULL){    if(current_storage != NULL){
150      /* Pick up from last context */      printf("Got storage\n");
151      current_context = current_storage->last_context->next;      if(current_storage->last_context != NULL){
152    } else {        /* Pick up from last context */
153      /* Reset current_context to start of list */        current_context = current_storage->last_context->next;
154      current_context = current_storage->list_contexts;      } else {
155          /* Reset current_context to start of list */
156          current_context = current_storage->list_contexts;
157        }
158    }    }
159    
160    if(context_class != ANY){    if(current_context != NULL){
161      while(current_context){      printf("Got context\n");
162        if((current_context->context_class == context_class)){      if(context_class != ANY){
163          /* Found context */        printf("Looking for context with class %i\n", context_class);
164          break;        while(current_context != NULL){
165            printf("Checking context at %p\n", current_context);
166            printf("This one has %i\n", current_context->context_class);
167            if((current_context->context_class == context_class)){
168              /* Found context */
169              printf("Found context\n");
170              break;
171            }
172            current_context = current_context->next;
173        }        }
       current_context = current_context->next;  
174      }      }
175    }    }
176    
177    current_storage->last_context = current_context;    current_storage->last_context = current_context;
178    
179    if(current_context){    if(current_context != NULL){
180      /* Found something on the first go */      /* Found something on the first go */
181      return current_context;      return current_context;
182    } else {    } else {
# Line 433  EES_RC AOS_Term (void){ Line 452  EES_RC AOS_Term (void){
452  EES_RC aos_dump_argslist (void) {  EES_RC aos_dump_argslist (void) {
453    aos_context_t  * context;    aos_context_t  * context;
454    aos_attribute_t* attribute;    aos_attribute_t* attribute;
455    char* log_str = "aos_dump";    char *log_str = "aos_dump";
456      char *attribute_name = "", *attribute_value = "";
457    eef_log(LOG_DEBUG, "Dumping aos");    eef_log(LOG_DEBUG, "Dumping aos");
458    rewindContexts(aos_get_storage());    rewindContexts(aos_get_storage());
459    while((context = getNextContext(ANY, NULL)) != NULL){    while((context = getNextContext(ANY, NULL)) != NULL){
# Line 442  EES_RC aos_dump_argslist (void) { Line 462  EES_RC aos_dump_argslist (void) {
462      }      }
463      rewindAttributes(context);      rewindAttributes(context);
464      while((attribute = getNextAttribute(context))){      while((attribute = getNextAttribute(context))){
465        eef_log(LOG_DEBUG, "Attribute: %s with value: %s\n", strdup(getAttributeId(attribute)), getAttributeValueAsString(attribute));        attribute_name = getAttributeId(attribute);
466          attribute_value = getAttributeValueAsString(attribute);
467          eef_log(LOG_DEBUG, "Attribute: %s with value: %s\n", attribute_name, attribute_value);
468      }      }
469    }    }
470    return EES_SUCCESS;    return EES_SUCCESS;

Legend:
Removed from v.1568  
changed lines
  Added in v.1569

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28