/[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 1753 by aramv, Wed Jun 9 15:30:28 2010 UTC revision 1754 by aramv, Thu Jun 10 16:35:55 2010 UTC
# Line 4  Line 4 
4    
5  static pthread_key_t           _aos_key;  static pthread_key_t           _aos_key;
6  static pthread_once_t          _aos_key_once = PTHREAD_ONCE_INIT; /* Normally not okay to do initialisation outside of a function, but this way it (hopefully) will only be set one - during compile time */  static pthread_once_t          _aos_key_once = PTHREAD_ONCE_INIT; /* Normally not okay to do initialisation outside of a function, but this way it (hopefully) will only be set one - during compile time */
7  static struct aos_state_s *  _global_state;  static struct aos_state_s *    _global_state;
8    
9  /* internal methods */  /* internal methods */
10    
# Line 45  aos_state_t * aos_get_state(void){ Line 45  aos_state_t * aos_get_state(void){
45        if((state->current_storage = calloc(1, sizeof(aos_storage_t)))){        if((state->current_storage = calloc(1, sizeof(aos_storage_t)))){
46          state->current_storage->list_contexts = NULL;          state->current_storage->list_contexts = NULL;
47          _is_initialized = 1;          _is_initialized = 1;
         pthread_setspecific(_aos_key, state);  
48          state->saved_storage = state->current_storage;          state->saved_storage = state->current_storage;
49            pthread_setspecific(_aos_key, state);
50          return state;          return state;
51        }        }
52      }      }
# Line 344  EES_RC destroyAttribute(aos_context_t* c Line 344  EES_RC destroyAttribute(aos_context_t* c
344   */   */
345  EES_RC setAttributeId(aos_attribute_t* attribute, char* id){  EES_RC setAttributeId(aos_attribute_t* attribute, char* id){
346    free(attribute->id);    free(attribute->id);
347    attribute->id = strdup(id);    attribute->id = NULL;
348      if(id != NULL){
349        attribute->id = strdup(id);
350      } else {
351        EEF_log(LOG_ERR, "setAttributeId(), tried to set NULL id\n");
352      }
353    return EES_SUCCESS;    return EES_SUCCESS;
354  }  }
355    
# Line 353  EES_RC setAttributeId(aos_attribute_t* a Line 358  EES_RC setAttributeId(aos_attribute_t* a
358   */   */
359  EES_RC setAttributeIssuer(aos_attribute_t* attribute, char* issuer){  EES_RC setAttributeIssuer(aos_attribute_t* attribute, char* issuer){
360    free(attribute->issuer);    free(attribute->issuer);
361    attribute->issuer = strdup(issuer);    attribute->issuer = NULL;
362      if(issuer != NULL){
363        printf("setAttributeIssuer() %s!\n", issuer);
364        attribute->issuer = strdup(issuer);
365      } else {
366        /*EEF_log(LOG_ERR, "setAttributeIssuer(), tried to set NULL issuer\n");*/
367      }
368    return EES_SUCCESS;    return EES_SUCCESS;
369  }  }
370    
# Line 426  EES_RC AOS_Init (void){ Line 437  EES_RC AOS_Init (void){
437      _global_state->last_context = NULL;      _global_state->last_context = NULL;
438      if((_global_state->current_storage = calloc(1, sizeof(aos_storage_t)))){      if((_global_state->current_storage = calloc(1, sizeof(aos_storage_t)))){
439        _global_state->current_storage->list_contexts = NULL;        _global_state->current_storage->list_contexts = NULL;
       _is_initialized = 1;  
440        _global_state->saved_storage = _global_state->current_storage;        _global_state->saved_storage = _global_state->current_storage;
441          _is_initialized = 1;
442        return EES_SUCCESS;        return EES_SUCCESS;
443      }      }
444    }    }
# Line 449  void aos_free_key(void* state){ Line 460  void aos_free_key(void* state){
460    pid_t             tid;    pid_t             tid;
461    aos_storage_t*    storage;    aos_storage_t*    storage;
462    aos_state_t*      tmp_state = (aos_state_t*) state;    aos_state_t*      tmp_state = (aos_state_t*) state;
   /*tid = gettid();*/  
463    tid = syscall(SYS_gettid);    tid = syscall(SYS_gettid);
464    EEF_log(LOG_DEBUG, "Killing thread %i\n", tid);    EEF_log(LOG_DEBUG, "Killing thread %i\n", tid);
465    aos_free_state(tmp_state);    aos_free_state(tmp_state);
# Line 460  void aos_free_key(void* state){ Line 470  void aos_free_key(void* state){
470   */   */
471  EES_RC AOS_Clean(void){  EES_RC AOS_Clean(void){
472    pid_t             tid;    pid_t             tid;
   /*tid = gettid();*/  
473    tid = syscall(SYS_gettid);    tid = syscall(SYS_gettid);
474    EEF_log(LOG_DEBUG, "Killing thread %i\n", tid);    EEF_log(LOG_DEBUG, "Killing thread %i\n", tid);
475    if(!_is_threading){    if(_is_threading){
476      return EES_FAILURE;      aos_free_state(aos_get_state());
477    }    }
   aos_free_state(aos_get_state());  
478    return EES_SUCCESS;    return EES_SUCCESS;
479  }  }
480    
481  /**  /**
482   * Terminates AOS, deleting the thread-local storage key   * Terminates AOS, deleting the global storage key
483   */   */
484  EES_RC AOS_Term (void){  EES_RC AOS_Term (void){
485    _is_threading = 0;    _is_threading = 0;

Legend:
Removed from v.1753  
changed lines
  Added in v.1754

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