- Timestamp:
- Oct 28, 2007, 4:55:19 PM (17 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_entropy.c
r135 r138 333 333 334 334 #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); 336 336 #else 337 337 m_count = read_mbytes (300, NAME_OF_DEV_RANDOM, nbuf, nbytes); -
trunk/src/sh_err_log.c
r137 r138 947 947 log_msg.timestamp[0] = '\0'; 948 948 (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)), 950 951 KEY_LEN+1); 951 952 } … … 953 954 /* --- Sign the message with the signature key. --- 954 955 */ 955 sh_tiger_hash (log_msg.msg, -1, 10, hashbuf, 10);956 956 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)); 958 959 959 960 (void) sl_strlcat (log_msg.msg, sigkey_new, (size_t)(status + KEY_LEN + 2)); 960 961 (void) sl_strlcpy (log_msg.signature, 961 962 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)), 963 965 KEY_LEN+1); 964 966 (void) sl_strlcpy (sigkey_old, sigkey_new, KEY_LEN+1); -
trunk/src/sh_mem.c
r137 r138 20 20 #include "config_xor.h" 21 21 22 /* With glibc, _XOPEN_SOURCE 500 is required for23 * pthread_mutexattr_settype/PTHREAD_MUTEX_RECURSIVE24 */25 #if defined(HAVE_PTHREAD) && defined(MEM_DEBUG)26 #define _XOPEN_SOURCE 50027 #endif28 29 22 #include <stdio.h> 30 23 #include <stdlib.h> … … 111 104 112 105 #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 107 SH_MUTEX_RECURSIVE(mutex_mem); 108 125 109 #else 126 110 #define MEM_MUTEX_INIT ((void)0) … … 135 119 FILE * fd; 136 120 137 MEM_MUTEX_INIT;138 SH_MUTEX_ LOCK(mutex_mem);121 SH_MUTEX_RECURSIVE_INIT(mutex_mem); 122 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 139 123 140 124 fd = fopen(MEM_LOG, "w"); … … 146 130 } 147 131 fclose(fd); 148 SH_MUTEX_ UNLOCK(mutex_mem);132 SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem); 149 133 return; 150 134 } … … 163 147 SL_ENTER(_("sh_mem_stat")); 164 148 165 MEM_MUTEX_INIT;166 SH_MUTEX_ LOCK(mutex_mem);149 SH_MUTEX_RECURSIVE_INIT(mutex_mem); 150 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 167 151 168 152 if (Alloc_Count == Free_Count) … … 201 185 } 202 186 out: 203 SH_MUTEX_ UNLOCK(mutex_mem);187 SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem); 204 188 SL_RET0(_("sh_mem_stat")); 205 189 } … … 212 196 SL_ENTER(_("sh_mem_check")); 213 197 214 MEM_MUTEX_INIT;215 SH_MUTEX_ LOCK(mutex_mem);198 SH_MUTEX_RECURSIVE_INIT(mutex_mem); 199 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 216 200 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP, 217 201 Mem_Max, Mem_Current); … … 246 230 /* if (nerr > 0) abort(); */ 247 231 248 SH_MUTEX_ UNLOCK(mutex_mem);232 SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem); 249 233 SL_RET0(_("sh_mem_check")); 250 234 } … … 258 242 SL_ENTER(_("sh_mem_malloc")); 259 243 260 MEM_MUTEX_INIT;261 SH_MUTEX_ LOCK(mutex_mem);244 SH_MUTEX_RECURSIVE_INIT(mutex_mem); 245 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 262 246 the_realAddress = malloc(size + 2 * SH_MEMMULT); 263 247 … … 368 352 _exit(42); 369 353 } 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); 383 369 SL_RETURN( theAddress, _("sh_mem_malloc")); 384 370 } … … 393 379 SL_ENTER(_("sh_mem_free")); 394 380 395 MEM_MUTEX_INIT;396 SH_MUTEX_ LOCK(mutex_mem);381 SH_MUTEX_RECURSIVE_INIT(mutex_mem); 382 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 397 383 if ( a == NULL ) 398 384 { … … 466 452 Mem_Current -= size; 467 453 out: 468 SH_MUTEX_ UNLOCK(mutex_mem);454 SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem); 469 455 SL_RET0(_("sh_mem_free")); 470 456 } -
trunk/src/sh_pthread.c
r136 r138 14 14 return; 15 15 } 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 25 void 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 35 void 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 58 void 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 } 16 74 #endif -
trunk/src/sh_srp.c
r137 r138 337 337 int res; 338 338 char hash[KEY_LEN+1]; 339 char hashbuf[KEYBUF_SIZE]; 339 340 340 341 SL_ENTER(_("sh_srp_make_a")); … … 345 346 (void) sl_strlcpy (hash, 346 347 sh_tiger_hash((char *)&randl[0], TIGER_DATA, 347 (unsigned long) 6*sizeof(UINT32)), 348 (unsigned long) 6*sizeof(UINT32), 349 hashbuf, sizeof(hashbuf)), 348 350 KEY_LEN+1); 349 351 -
trunk/src/sh_suidchk.c
r137 r138 1010 1010 1011 1011 status = sh_unix_getinfo (ShDFLevel[SH_ERR_T_RO], 1012 thisEntry->d_name,1012 dirlist->sh_d_name, 1013 1013 &theFile, fileHash, 0); 1014 1014 -
trunk/src/sh_unix.c
r137 r138 3611 3611 SL_RETURN((-1),_("sh_unix_getinfo")); 3612 3612 } 3613 3613 3614 3614 if (linknamebuf[0] == '/') 3615 3615 {
Note:
See TracChangeset
for help on using the changeset viewer.