本文整理汇总了C++中CRYPTO_thread_id函数的典型用法代码示例。如果您正苦于以下问题:C++ CRYPTO_thread_id函数的具体用法?C++ CRYPTO_thread_id怎么用?C++ CRYPTO_thread_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CRYPTO_thread_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pthreads_locking_callback
void pthreads_locking_callback(int mode, int type, char *file,
int line)
{
#if 0
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"thread=%4d mode=%s lock=%s %s:%d\n",
CRYPTO_thread_id(),
(mode&CRYPTO_LOCK)?"l":"u",
(type&CRYPTO_READ)?"r":"w",file,line);
#endif
#if 0
if (CRYPTO_LOCK_SSL_CERT == type)
TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"(t,m,f,l) %ld %d %s %d\n",
CRYPTO_thread_id(),
mode,file,line);
#endif
if (mode & CRYPTO_LOCK)
{
pthread_mutex_lock(&(lock_cs[type]));
lock_count[type]++;
}
else
{
pthread_mutex_unlock(&(lock_cs[type]));
}
}
示例2: pthreads_locking_callback
void pthreads_locking_callback(int mode, int type, char *file,
int line)
{
#if 0
fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
CRYPTO_thread_id(),
(mode&CRYPTO_LOCK)?"l":"u",
(type&CRYPTO_READ)?"r":"w",file,line);
#endif
#if 0
if (CRYPTO_LOCK_SSL_CERT == type)
fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
CRYPTO_thread_id(),
mode,file,line);
#endif
if (mode & CRYPTO_LOCK)
{
pthread_mutex_lock(&(lock_cs[type]));
lock_count[type]++;
}
else
{
pthread_mutex_unlock(&(lock_cs[type]));
}
}
示例3: solaris_locking_callback
void solaris_locking_callback(int mode, int type, char *file, int line)
{
# ifdef undef
fprintf(stderr, "thread=%4d mode=%s lock=%s %s:%d\n",
CRYPTO_thread_id(),
(mode & CRYPTO_LOCK) ? "l" : "u",
(type & CRYPTO_READ) ? "r" : "w", file, line);
# endif
/*-
if (CRYPTO_LOCK_SSL_CERT == type)
fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
CRYPTO_thread_id(),
mode,file,line);
*/
if (mode & CRYPTO_LOCK) {
/*-
if (mode & CRYPTO_READ)
rw_rdlock(&(lock_cs[type]));
else
rw_wrlock(&(lock_cs[type])); */
mutex_lock(&(lock_cs[type]));
lock_count[type]++;
} else {
/* rw_unlock(&(lock_cs[type])); */
mutex_unlock(&(lock_cs[type]));
}
}
示例4: CRYPTO_lock
void CRYPTO_lock(int mode, int type, const char *file, int line)
{
#ifdef LOCK_DEBUG
{
char *rw_text,*operation_text;
if (mode & CRYPTO_LOCK)
operation_text="lock ";
else if (mode & CRYPTO_UNLOCK)
operation_text="unlock";
else
operation_text="ERROR ";
if (mode & CRYPTO_READ)
rw_text="r";
else if (mode & CRYPTO_WRITE)
rw_text="w";
else
rw_text="ERROR";
fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
CRYPTO_thread_id(), rw_text, operation_text,
CRYPTO_get_lock_name(type), file, line);
}
#endif
if (type < 0)
{
if (do_dynlock_cb)
do_dynlock_cb(mode, type, file, line);
}
else
if (locking_callback != NULL)
locking_callback(mode,type,file,line);
}
示例5: CRYPTO_r_lock
static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
{
BN_BLINDING *ret;
int got_write_lock = 0;
CRYPTO_r_lock(CRYPTO_LOCK_RSA);
if (rsa->blinding == NULL)
{
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
got_write_lock = 1;
if (rsa->blinding == NULL)
rsa->blinding = RSA_setup_blinding(rsa, ctx);
}
ret = rsa->blinding;
if (ret == NULL)
goto err;
if (BN_BLINDING_get_thread_id(ret) == CRYPTO_thread_id())
{
/* rsa->blinding is ours! */
*local = 1;
}
else
{
/* resort to rsa->mt_blinding instead */
*local = 0; /* instructs rsa_blinding_convert(), rsa_blinding_invert()
* that the BN_BLINDING is shared, meaning that accesses
* require locks, and that the blinding factor must be
* stored outside the BN_BLINDING
*/
if (rsa->mt_blinding == NULL)
{
if (!got_write_lock)
{
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
CRYPTO_w_lock(CRYPTO_LOCK_RSA);
got_write_lock = 1;
}
if (rsa->mt_blinding == NULL)
rsa->mt_blinding = RSA_setup_blinding(rsa, ctx);
}
ret = rsa->mt_blinding;
}
err:
if (got_write_lock)
CRYPTO_w_unlock(CRYPTO_LOCK_RSA);
else
CRYPTO_r_unlock(CRYPTO_LOCK_RSA);
return ret;
}
示例6: ssleay_rand_status
static int ssleay_rand_status(void)
{
int ret;
int do_not_lock;
/* check if we already have the lock
* (could happen if a RAND_poll() implementation calls RAND_status()) */
if (crypto_lock_rand)
{
CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
do_not_lock = (locking_thread == CRYPTO_thread_id());
CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
}
else
do_not_lock = 0;
if (!do_not_lock)
{
CRYPTO_w_lock(CRYPTO_LOCK_RAND);
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
locking_thread = CRYPTO_thread_id();
CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
crypto_lock_rand = 1;
}
if (!initialized)
{
RAND_poll();
initialized = 1;
}
ret = entropy >= ENTROPY_NEEDED;
if (!do_not_lock)
{
/* before unlocking, we must clear 'crypto_lock_rand' */
crypto_lock_rand = 0;
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
}
return ret;
}
示例7:
ERR_STATE *ERR_get_state(void)
{
ERR_STATE *ret=NULL,tmp,*tmpp;
int i;
unsigned long pid;
pid=(unsigned long)CRYPTO_thread_id();
CRYPTO_r_lock(CRYPTO_LOCK_ERR);
if (thread_hash == NULL)
{
CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
if (thread_hash == NULL)
{
MemCheck_off();
thread_hash=lh_new(pid_hash,pid_cmp);
MemCheck_on();
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
if (thread_hash == NULL) return(getFallback());
}
else
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
}
else
{
tmp.pid=pid;
ret=(ERR_STATE *)lh_retrieve(thread_hash,&tmp);
CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
}
/* ret == the error state, if NULL, make a new one */
if (ret == NULL)
{
ret=(ERR_STATE *)Malloc(sizeof(ERR_STATE));
if (ret == NULL) return(getFallback());
ret->pid=pid;
ret->top=0;
ret->bottom=0;
for (i=0; i<ERR_NUM_ERRORS; i++)
{
ret->err_data[i]=NULL;
ret->err_data_flags[i]=0;
}
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
tmpp=(ERR_STATE *)lh_insert(thread_hash,ret);
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
if (tmpp != NULL) /* old entry - should not happen */
{
ERR_STATE_free(tmpp);
}
}
return(ret);
}
示例8: ERR_remove_state
void ERR_remove_state(unsigned long pid)
{
ERR_STATE tmp;
err_fns_check();
if (pid == 0)
pid=(unsigned long)CRYPTO_thread_id();
tmp.pid=pid;
/* thread_del_item automatically destroys the LHASH if the number of
* items reaches zero. */
ERRFN(thread_del_item)(&tmp);
}
示例9: fips_is_owning_thread
int fips_is_owning_thread(void)
{
int ret = 0;
if (fips_is_started())
{
CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
if (fips_thread != 0 && fips_thread == CRYPTO_thread_id())
ret = 1;
CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
}
return ret;
}
示例10: ssl_pthreads_locking_callback
static void
ssl_pthreads_locking_callback (int mode, int type, char *file, int line)
{
dmsg (D_OPENSSL_LOCK, "SSL LOCK thread=%4lu mode=%s lock=%s %s:%d",
CRYPTO_thread_id (),
(mode & CRYPTO_LOCK) ? "l" : "u",
(type & CRYPTO_READ) ? "r" : "w", file, line);
if (mode & CRYPTO_LOCK)
pthread_mutex_lock (&ssl_mutex[type].mutex);
else
pthread_mutex_unlock (&ssl_mutex[type].mutex);
}
示例11: CRYPTO_add_lock
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
int line)
{
int ret = 0;
if (add_lock_callback != NULL)
{
#ifdef LOCK_DEBUG
int before= *pointer;
#endif
ret=add_lock_callback(pointer,amount,type,file,line);
#ifdef LOCK_DEBUG
fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
CRYPTO_thread_id(),
before,amount,ret,
CRYPTO_get_lock_name(type),
file,line);
#endif
}
else
{
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line);
ret= *pointer+amount;
#ifdef LOCK_DEBUG
fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n",
CRYPTO_thread_id(),
*pointer,amount,ret,
CRYPTO_get_lock_name(type),
file,line);
#endif
*pointer=ret;
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
}
return(ret);
}
示例12: ERR_remove_state
void ERR_remove_state(unsigned long pid)
{
ERR_STATE *p,tmp;
if (thread_hash == NULL)
return;
if (pid == 0)
pid=(unsigned long)CRYPTO_thread_id();
tmp.pid=pid;
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
p=(ERR_STATE *)lh_delete(thread_hash,&tmp);
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
if (p != NULL) ERR_STATE_free(p);
}
示例13: solaris_locking_callback
static void solaris_locking_callback(int mode, int type, const char *file, int line)
{
#if 0
fprintf(stderr, "thread=%4d mode=%s lock=%s %s:%d\n",
CRYPTO_thread_id(),
(mode & CRYPTO_LOCK) ? "l" : "u",
(type & CRYPTO_READ) ? "r" : "w", file, line);
#endif
#if 0
if (CRYPTO_LOCK_SSL_CERT == type)
fprintf(stderr, "(t,m,f,l) %ld %d %s %d\n",
CRYPTO_thread_id(),
mode, file, line);
#endif
if (mode & CRYPTO_LOCK)
{
#ifdef USE_MUTEX
mutex_lock(&(lock_cs[type]));
#else
if (mode & CRYPTO_READ)
rw_rdlock(&(lock_cs[type]));
else
rw_wrlock(&(lock_cs[type]));
#endif
lock_count[type]++;
}
else
{
#ifdef USE_MUTEX
mutex_unlock(&(lock_cs[type]));
#else
rw_unlock(&(lock_cs[type]));
#endif
}
}
示例14: beos_locking_callback
void beos_locking_callback(int mode, int type, const char *file, int line)
{
# if 0
fprintf(stderr, "thread=%4d mode=%s lock=%s %s:%d\n",
CRYPTO_thread_id(),
(mode & CRYPTO_LOCK) ? "l" : "u",
(type & CRYPTO_READ) ? "r" : "w", file, line);
# endif
if (mode & CRYPTO_LOCK) {
lock_cs[type]->Lock();
lock_count[type]++;
} else {
lock_cs[type]->Unlock();
}
}
示例15: ERR_print_errors_fp
void ERR_print_errors_fp(FILE *fp)
{
unsigned long l;
char buf[200];
const char *file,*data;
int line,flags;
unsigned long es;
es=CRYPTO_thread_id();
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
{
fprintf(fp,"%lu:%s:%s:%d:%s\n",es,ERR_error_string(l,buf),
file,line,(flags&ERR_TXT_STRING)?data:"");
}
}