Changeset e77a1934 in rtems


Ignore:
Timestamp:
Jul 15, 2010, 9:31:10 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
17ecd5a0
Parents:
bbe6a5fe
Message:

2010-07-15 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/privateenv.c: Fix bug.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    rbbe6a5fe re77a1934  
     12010-07-15      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libcsupport/src/privateenv.c: Fix bug.
     4
    152010-07-15      Sebastian Huber <Sebastian.Huber@embedded-brains.de>
    26
  • cpukit/libcsupport/src/privateenv.c

    rbbe6a5fe re77a1934  
    44 *  Submitted by: fernando.ruiz@ctv.es (correo@fernando-ruiz.com)
    55 *
    6  *  COPYRIGHT (c) 1989-2000.
     6 *  COPYRIGHT (c) 1989-2010.
    77 *  On-Line Applications Research Corporation (OAR).
    88 *
     
    1818#endif
    1919
    20 #include <stdlib.h>     /* free */
     20#include <stdlib.h> /* free */
    2121
    2222#include <rtems.h>
     
    3434  rtems_user_env_t *env = (rtems_user_env_t*) venv ;
    3535
    36         if (env != &rtems_global_user_env
     36 if (env != &rtems_global_user_env
    3737#ifdef HAVE_USERENV_REFCNT
    38                 && --env->refcnt <= 0
     38  && --env->refcnt <= 0
    3939#endif
    40                 ) {
    41                 rtems_filesystem_freenode( &env->current_directory);
    42                 rtems_filesystem_freenode( &env->root_directory);
    43                 free(env);
    44         }
     40  ) {
     41  rtems_filesystem_freenode( &env->current_directory);
     42  rtems_filesystem_freenode( &env->root_directory);
     43  free(env);
     44 }
    4545}
    4646
    47 rtems_status_code rtems_libio_set_private_env(void) {
    48   rtems_status_code                                     sc;
    49   rtems_id                                              task_id;
    50   rtems_filesystem_location_info_t              loc;
     47rtems_status_code rtems_libio_set_private_env(void)
     48{
     49  rtems_status_code      sc;
     50  rtems_id               task_id;
     51  rtems_filesystem_location_info_t  loc;
    5152
    5253  sc=rtems_task_ident(RTEMS_SELF,0,&task_id);
     
    5556  /* Only for the first time a malloc is necesary */
    5657  if (rtems_current_user_env==&rtems_global_user_env) {
    57    rtems_user_env_t     *tmp = malloc(sizeof(rtems_user_env_t));
     58   rtems_user_env_t *tmp = malloc(sizeof(rtems_user_env_t));
    5859   if (!tmp)
    5960     return RTEMS_NO_MEMORY;
     
    6364#endif
    6465
    65    sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,(void(*)(void *))free_user_env);
     66   sc = rtems_task_variable_add(
     67    RTEMS_SELF,
     68    (void*)&rtems_current_user_env,
     69    (void(*)(void *))free_user_env
     70   );
    6671   if (sc != RTEMS_SUCCESSFUL) {
    67         /* don't use free_user_env because the pathlocs are
    68           * not initialized yet
    69           */
     72    /* don't use free_user_env because the pathlocs are
     73     * not initialized yet
     74     */
    7075     free(tmp);
    7176     return sc;
    7277   }
    7378   rtems_current_user_env = tmp;
    74   };
     79  }
    7580
    7681  *rtems_current_user_env = rtems_global_user_env; /* get the global values*/
     
    112117
    113118#ifndef HAVE_USERENV_REFCNT
    114 rtems_status_code rtems_libio_share_private_env(rtems_id task_id) {
     119rtems_status_code rtems_libio_share_private_env(rtems_id task_id)
     120{
    115121  rtems_status_code  sc;
    116122  rtems_user_env_t * shared_user_env;
     
    122128  if (rtems_current_user_env->task_id==current_task_id) {
    123129   /* kill the current user env & task_var*/
    124         rtems_user_env_t        *tmp = rtems_current_user_env;
     130   rtems_user_env_t  *tmp = rtems_current_user_env;
    125131   sc = rtems_task_variable_delete(RTEMS_SELF,(void*)&rtems_current_user_env);
    126132   if (sc != RTEMS_SUCCESSFUL) return sc;
    127133   free_user_env(tmp);
    128   };
     134  } else {
     135    sc = rtems_task_variable_get(
     136      task_id,(void*)&rtems_current_user_env, (void*)&shared_user_env );
     137    if (sc != RTEMS_SUCCESSFUL)
     138      goto bailout;
     139  }
    129140
    130141  /* AT THIS POINT, rtems_current_user_env is DANGLING */
    131142
    132   sc = rtems_task_variable_get(task_id,(void*)&rtems_current_user_env,
    133                                        (void*)&shared_user_env       );
    134   if (sc != RTEMS_SUCCESSFUL)
    135     goto bailout;
    136 
    137   sc = rtems_task_variable_add(RTEMS_SELF,(void*)&rtems_current_user_env,free_user_env);
     143  sc = rtems_task_variable_add(
     144    RTEMS_SELF,(void*)&rtems_current_user_env,free_user_env);
    138145  if (sc != RTEMS_SUCCESSFUL)
    139146    goto bailout;
Note: See TracChangeset for help on using the changeset viewer.