Changeset 138 for trunk/src


Ignore:
Timestamp:
Oct 28, 2007, 4:55:19 PM (17 years ago)
Author:
rainer
Message:

More fixes for compile and runtime errors.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_entropy.c

    r135 r138  
    333333
    334334#ifdef NAME_OF_DEV_URANDOM
    335   m_count = read_mbytes (30, NAME_OF_DEV_RANDOM, nbuf, nbytes);
     335  m_count = read_mbytes (  1, NAME_OF_DEV_RANDOM, nbuf, nbytes);
    336336#else
    337337  m_count = read_mbytes (300, NAME_OF_DEV_RANDOM, nbuf, nbytes);
  • trunk/src/sh_err_log.c

    r137 r138  
    947947      log_msg.timestamp[0] = '\0';
    948948      (void) sl_strlcpy (sigkey_new,
    949                          sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN, hashbuf, sizeof(hashbuf)),
     949                         sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN,
     950                                        hashbuf, sizeof(hashbuf)),
    950951                         KEY_LEN+1);
    951952    }
     
    953954  /* --- Sign the message with the signature key. ---
    954955   */
    955   sh_tiger_hash (log_msg.msg, -1, 10, hashbuf, 10);
    956956  sh_tiger_hash (log_msg.msg, TIGER_DATA,
    957                  (unsigned long)(status + KEY_LEN), (char *) hashbuf, (size_t) sizeof(hashbuf));
     957                 (unsigned long)(status + KEY_LEN),
     958                 (char *) hashbuf, (size_t) sizeof(hashbuf));
    958959
    959960  (void) sl_strlcat (log_msg.msg, sigkey_new, (size_t)(status + KEY_LEN + 2));
    960961  (void) sl_strlcpy (log_msg.signature,
    961962                     sh_tiger_hash (log_msg.msg, (TigerType) TIGER_DATA,
    962                                     (unsigned long)(status + KEY_LEN), hashbuf, sizeof(hashbuf)),
     963                                    (unsigned long)(status + KEY_LEN),
     964                                    hashbuf, sizeof(hashbuf)),
    963965                     KEY_LEN+1);
    964966  (void) sl_strlcpy (sigkey_old, sigkey_new, KEY_LEN+1);
  • trunk/src/sh_mem.c

    r137 r138  
    2020#include "config_xor.h"
    2121
    22 /* With glibc, _XOPEN_SOURCE 500 is required for
    23  * pthread_mutexattr_settype/PTHREAD_MUTEX_RECURSIVE
    24  */
    25 #if defined(HAVE_PTHREAD) && defined(MEM_DEBUG)
    26 #define _XOPEN_SOURCE 500
    27 #endif
    28 
    2922#include <stdio.h>
    3023#include <stdlib.h>
     
    111104
    112105#ifdef HAVE_PTHREAD
    113 static pthread_once_t mem_is_initialized = PTHREAD_ONCE_INIT;
    114 static pthread_mutex_t mutex_mem;
    115 
    116 static void initialize_mem(void)
    117 {
    118   pthread_mutexattr_t   mta;
    119   pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE);
    120   pthread_mutex_init(&mutex_mem, &mta);
    121   pthread_mutexattr_destroy(&mta);
    122   return;
    123 }
    124 #define MEM_MUTEX_INIT  (void) pthread_once(&mem_is_initialized, initialize_mem)
     106
     107SH_MUTEX_RECURSIVE(mutex_mem);
     108
    125109#else
    126110#define MEM_MUTEX_INIT ((void)0)
     
    135119  FILE * fd;
    136120
    137   MEM_MUTEX_INIT;
    138   SH_MUTEX_LOCK(mutex_mem);
     121  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
     122  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    139123
    140124  fd = fopen(MEM_LOG, "w");
     
    146130    }
    147131  fclose(fd);
    148   SH_MUTEX_UNLOCK(mutex_mem);
     132  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    149133  return;
    150134}
     
    163147  SL_ENTER(_("sh_mem_stat"));
    164148
    165   MEM_MUTEX_INIT;
    166   SH_MUTEX_LOCK(mutex_mem);
     149  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
     150  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    167151
    168152  if (Alloc_Count == Free_Count)
     
    201185    }
    202186 out:
    203   SH_MUTEX_UNLOCK(mutex_mem);
     187  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    204188  SL_RET0(_("sh_mem_stat"));
    205189}
     
    212196  SL_ENTER(_("sh_mem_check"));
    213197
    214   MEM_MUTEX_INIT;
    215   SH_MUTEX_LOCK(mutex_mem);
     198  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
     199  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    216200  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP,
    217201                   Mem_Max, Mem_Current);
     
    246230  /* if (nerr > 0) abort(); */
    247231
    248   SH_MUTEX_UNLOCK(mutex_mem);
     232  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    249233  SL_RET0(_("sh_mem_check"));
    250234}
     
    258242  SL_ENTER(_("sh_mem_malloc"));
    259243
    260   MEM_MUTEX_INIT;
    261   SH_MUTEX_LOCK(mutex_mem);
     244  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
     245  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    262246  the_realAddress = malloc(size + 2 * SH_MEMMULT);
    263247 
     
    368352      _exit(42);
    369353    }
    370 
    371   /* make list entry */
    372 
    373   this->real_address = the_realAddress;
    374   this->address      = theAddress;
    375   this->size         = size;
    376   this->line         = line;
    377   sl_strlcpy(this->file, file, 20);
    378 
    379   this->next = memlist;
    380   memlist = this;
    381 
    382   SH_MUTEX_UNLOCK(mutex_mem);
     354  else
     355    {
     356      /* make list entry */
     357
     358      this->real_address = the_realAddress;
     359      this->address      = theAddress;
     360      this->size         = size;
     361      this->line         = line;
     362      sl_strlcpy(this->file, file, 20);
     363
     364      this->next = memlist;
     365      memlist = this;
     366    }
     367
     368  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    383369  SL_RETURN( theAddress, _("sh_mem_malloc"));
    384370}
     
    393379  SL_ENTER(_("sh_mem_free"));
    394380
    395   MEM_MUTEX_INIT;
    396   SH_MUTEX_LOCK(mutex_mem);
     381  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
     382  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    397383  if ( a == NULL )
    398384    {
     
    466452  Mem_Current -= size;
    467453 out:
    468   SH_MUTEX_UNLOCK(mutex_mem);
     454  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    469455  SL_RET0(_("sh_mem_free"));
    470456}
  • trunk/src/sh_pthread.c

    r136 r138  
    1414  return;
    1515}
     16
     17
     18/**
     19 * libxml2 threads.c: set of generic threading related routines
     20 *
     21 * Gary Pennington <Gary.Pennington@uk.sun.com>
     22 * daniel@veillard.com
     23 */
     24
     25void sh_InitRMutex(struct sh_RMutex * tok)
     26{
     27  pthread_mutex_init(&tok->lock, NULL);
     28  tok->held = 0;
     29  tok->waiters = 0;
     30  pthread_cond_init(&tok->cv, NULL);
     31
     32  return;
     33}
     34
     35void sh_RMutexLock(struct sh_RMutex * tok)
     36{
     37  if (tok == NULL)
     38    return;
     39
     40  pthread_mutex_lock(&tok->lock);
     41  if (tok->held) {
     42    if (pthread_equal(tok->tid, pthread_self())) {
     43      tok->held++;
     44      pthread_mutex_unlock(&tok->lock);
     45      return;
     46    } else {
     47      tok->waiters++;
     48      while (tok->held)
     49        pthread_cond_wait(&tok->cv, &tok->lock);
     50      tok->waiters--;
     51    }
     52  }
     53  tok->tid = pthread_self();
     54  tok->held = 1;
     55  pthread_mutex_unlock(&tok->lock);
     56}
     57
     58void sh_RMutexUnlock(void * arg)
     59{
     60  struct sh_RMutex * tok = (struct sh_RMutex *) arg;
     61
     62  if (tok == NULL)
     63    return;
     64   
     65  pthread_mutex_lock(&tok->lock);
     66  tok->held--;
     67  if (tok->held == 0) {
     68    if (tok->waiters)
     69      pthread_cond_signal(&tok->cv);
     70    tok->tid = 0;
     71  }
     72  pthread_mutex_unlock(&tok->lock);
     73}
    1674#endif
  • trunk/src/sh_srp.c

    r137 r138  
    337337  int    res;
    338338  char   hash[KEY_LEN+1];
     339  char hashbuf[KEYBUF_SIZE];
    339340
    340341  SL_ENTER(_("sh_srp_make_a"));
     
    345346  (void) sl_strlcpy (hash,
    346347                     sh_tiger_hash((char *)&randl[0], TIGER_DATA,
    347                                    (unsigned long) 6*sizeof(UINT32)),
     348                                   (unsigned long) 6*sizeof(UINT32),
     349                                   hashbuf, sizeof(hashbuf)),
    348350                     KEY_LEN+1);
    349351
  • trunk/src/sh_suidchk.c

    r137 r138  
    10101010           
    10111011            status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_RO],
    1012                                       thisEntry->d_name,
     1012                                      dirlist->sh_d_name,
    10131013                                      &theFile, fileHash, 0);
    10141014           
  • trunk/src/sh_unix.c

    r137 r138  
    36113611          SL_RETURN((-1),_("sh_unix_getinfo"));
    36123612        }
    3613    
     3613
    36143614    if (linknamebuf[0] == '/')
    36153615      {
Note: See TracChangeset for help on using the changeset viewer.