• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CRYPTO_num_locks函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CRYPTO_num_locks函数的典型用法代码示例。如果您正苦于以下问题:C++ CRYPTO_num_locks函数的具体用法?C++ CRYPTO_num_locks怎么用?C++ CRYPTO_num_locks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CRYPTO_num_locks函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: thread_cleanup

void thread_cleanup ()
{
#ifndef HAVE_CLIENT
  if (!mutex_buf) return;
  CRYPTO_set_id_callback (NULL);
  CRYPTO_set_locking_callback (NULL);
  int i;
  for (i = 0;  i < CRYPTO_num_locks ();  i++)
    MUTEX_CLEANUP (mutex_buf[i]);
  free (mutex_buf);
  mutex_buf = NULL;
#endif
}
开发者ID:bibledit,项目名称:bibledit-windows,代码行数:13,代码来源:locks.c


示例2: init_openssl

static void
init_openssl(void)
{
    int i;

    openssl_mutex_array = g_new0(GMutex *, CRYPTO_num_locks());

    for (i=0; i<CRYPTO_num_locks(); i++) {
	openssl_mutex_array[i] = g_mutex_new();
    }
    CRYPTO_set_locking_callback(openssl_lock_callback);

}
开发者ID:neepher,项目名称:amanda,代码行数:13,代码来源:glib-util.c


示例3: init_openssl_locking

static void init_openssl_locking()
{
  gint i;

  // initialize OpenSSL locking for multi-threaded operation
  openssl_mutexes = g_new(GMutex*, CRYPTO_num_locks());
  for (i = 0; i < CRYPTO_num_locks(); i++)
    openssl_mutexes[i] = g_mutex_new();

  SSL_library_init();
  CRYPTO_set_id_callback(openssl_thread_id_callback);
  CRYPTO_set_locking_callback(openssl_locking_callback);
}
开发者ID:Meticulus,项目名称:megatools,代码行数:13,代码来源:tools.c


示例4: CWSecurityInitLib

CWBool CWSecurityInitLib() {

	int i;

	SSL_load_error_strings();
	SSL_library_init();

	/* setup mutexes for openssl internal locking */
	CW_CREATE_ARRAY_ERR(mutexOpensslBuf,
			    CRYPTO_num_locks() * sizeof(CWThreadMutex),
			    CWThreadMutex,
			    return CWErrorRaise(CW_ERROR_OUT_OF_MEMORY, 
				    		"Cannot create openssl mutexes");)
开发者ID:kvjqzx,项目名称:openCAPWAP,代码行数:13,代码来源:CWSecurity.c


示例5: guac_common_ssh_openssl_init_locks

/**
 * Creates the given number of mutexes, such that OpenSSL will have at least
 * this number of mutexes at its disposal.
 *
 * @param count
 *     The number of mutexes (locks) to create.
 */
static void guac_common_ssh_openssl_init_locks(int count) {

    int i;

    /* Allocate required number of locks */
    guac_common_ssh_openssl_locks =
        malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());

    /* Initialize each lock */
    for (i=0; i < count; i++)
        pthread_mutex_init(&(guac_common_ssh_openssl_locks[i]), NULL);

}
开发者ID:celeron200,项目名称:guacamole-server,代码行数:20,代码来源:guac_ssh.c


示例6: CRYPTO_num_locks

void utils::initialize_ssl_implementation(void) {
#if HAVE_OPENSSL
	openssl_mutexes_size = CRYPTO_num_locks();
	openssl_mutexes = new mutex[openssl_mutexes_size];
	CRYPTO_set_id_callback(openssl_mth_id_function);
	CRYPTO_set_locking_callback(openssl_mth_locking_function);
#endif

#if HAVE_GCRYPT
	gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
	gnutls_global_init();
#endif
}
开发者ID:KaduNovoK,项目名称:newsbeuter,代码行数:13,代码来源:utils.cpp


示例7: ff_openssl_init

void ff_openssl_init(void)
{
    avpriv_lock_avformat();
    if (!openssl_init) {
        SSL_library_init();
        SSL_load_error_strings();
#if HAVE_THREADS
        if (!CRYPTO_get_locking_callback()) {
            int i;
            openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks());
            for (i = 0; i < CRYPTO_num_locks(); i++)
                pthread_mutex_init(&openssl_mutexes[i], NULL);
            CRYPTO_set_locking_callback(openssl_lock);
#if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000
            CRYPTO_set_id_callback(openssl_thread_id);
#endif
        }
#endif
    }
    openssl_init++;
    avpriv_unlock_avformat();
}
开发者ID:AVLeo,项目名称:libav,代码行数:22,代码来源:tls_openssl.c


示例8: CRYPTO_thread_setup

void CRYPTO_thread_setup(void)
{
    int i;

    lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
    lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
    if (!lock_cs || !lock_count) {
        /* Nothing we can do about this...void function! */
        if (lock_cs)
            OPENSSL_free(lock_cs);
        if (lock_count)
            OPENSSL_free(lock_count);
        return;
    }
    for (i = 0; i < CRYPTO_num_locks(); i++) {
        lock_count[i] = 0;
        pthread_mutex_init(&(lock_cs[i]), NULL);
    }

    CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
    CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
}
开发者ID:03050903,项目名称:godot,代码行数:22,代码来源:th-lock.c


示例9: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	WSADATA wsaData = {0};
	WSAStartup(MAKEWORD(2, 2), &wsaData);
	SSLeay_add_all_algorithms();
	pthread_t pid;
	
	ERR_load_BIO_strings();
	SSL_library_init(); 
	SSL_load_error_strings();

	SSL *ssl = NULL;
	SSL_CTX *ctx = NULL;
	//这里要注意是client
	ctx = SSL_CTX_new(TLSv1_client_method());
	if (ctx == NULL)
	{
		printf("ssl ctx new eer\n");
		exit(-1);
	}

	transf_lock_cs = (pthread_mutex_t *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
	transf_lock_count = (long *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
	for (int i = 0; i < CRYPTO_num_locks(); i++)
	{
		transf_lock_count[i] = 0;
		pthread_mutex_init(&(transf_lock_cs[i]), NULL);
	}
	CRYPTO_set_id_callback((unsigned long(*)())transf_pthreads_thread_id);
	CRYPTO_set_locking_callback(transf_client_locking_callback);
	pthread_create(&pid, NULL, tcp_forwardlistenthread, ctx);

	pthread_join(pid, NULL);
	system("pause");
	getchar();
	SSL_CTX_free(ctx);
	WSACleanup();
	return 0;
}
开发者ID:atlantiswang,项目名称:examples,代码行数:39,代码来源:sslclient.cpp


示例10: pthreads_locking_callback

void pthreads_locking_callback( int mode, int n,
    const char *caller_file, int caller_line )
{
  (void)caller_file;
  (void)caller_line;

  if(!crypto_locks)
  {
    VLOG(1) << "Allocating " << CRYPTO_num_locks() << " locks for OpenSSL";
    crypto_locks = new pthread_mutex_t[ CRYPTO_num_locks() ];
    for(int i=0; i<CRYPTO_num_locks(); ++i)
      pthread_mutex_init( crypto_locks+i, 0 );
  }

  if(mode & CRYPTO_LOCK)
  {
    pthread_mutex_lock( crypto_locks + n );
  } else
  {
    pthread_mutex_unlock( crypto_locks + n );
  }
}
开发者ID:tarruda,项目名称:encfs,代码行数:22,代码来源:openssl.cpp


示例11: stop_ssl

/**
 * Stop SSL support library
 * @return TRUE, or FALSE if an error has occured.
 */
void stop_ssl() {
        if (ssl_initialized) {
                int i;
                ssl_initialized = FALSE;
                ERR_free_strings();
                CRYPTO_set_id_callback(NULL);
                CRYPTO_set_locking_callback(NULL);
                for (i = 0; i < CRYPTO_num_locks(); i++)
                        assert(pthread_mutex_destroy(&ssl_mutex_table[i]) == 0);
                FREE(ssl_mutex_table);
                RAND_cleanup();
        }
}
开发者ID:AsydSolutions,项目名称:monit,代码行数:17,代码来源:ssl.c


示例12: thread_cleanup

static void thread_cleanup(void)
{
	int i;

	CRYPTO_set_locking_callback(NULL);

	for (i=0; i<CRYPTO_num_locks(); i++) {
		pthread_mutex_destroy(&(lock_cs[i]));
	}
	OPENSSL_free(lock_cs);
	OPENSSL_free(lock_count);

}
开发者ID:davehorton,项目名称:sofia-sip,代码行数:13,代码来源:ws.c


示例13: thread_cleanup

int thread_cleanup(void)
{
  int i;
  if (!mutex_buf)
    return 0;
  CRYPTO_set_id_callback(NULL);
  CRYPTO_set_locking_callback(NULL);
  for (i = 0; i < CRYPTO_num_locks();  i++)
    MUTEX_CLEANUP(mutex_buf[i]);
  free(mutex_buf);
  mutex_buf = NULL;
  return 1;
}
开发者ID:InfoHunter,项目名称:keyless,代码行数:13,代码来源:testclient.c


示例14: init_ssl

static void init_ssl(void)
{
#ifdef GIT_SSL
	SSL_load_error_strings();
	OpenSSL_add_ssl_algorithms();
	/*
	 * Load SSLv{2,3} and TLSv1 so that we can talk with servers
	 * which use the SSL hellos, which are often used for
	 * compatibility. We then disable SSL so we only allow OpenSSL
	 * to speak TLSv1 to perform the encryption itself.
	 */
	git__ssl_ctx = SSL_CTX_new(SSLv23_method());
	SSL_CTX_set_options(git__ssl_ctx,
			    SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3
	/* Older OpenSSL and MacOS OpenSSL doesn't have this */
# ifdef SSL_OP_NO_COMPRESSION
			    | SSL_OP_NO_COMPRESSION
# endif
		);
	SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY);
	SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL);
	if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) {
		SSL_CTX_free(git__ssl_ctx);
		git__ssl_ctx = NULL;
	}

# ifdef GIT_THREADS
	{
		int num_locks, i;

		num_locks = CRYPTO_num_locks();
		openssl_locks = git__calloc(num_locks, sizeof(git_mutex));
		if (openssl_locks == NULL) {
			SSL_CTX_free(git__ssl_ctx);
			git__ssl_ctx = NULL;
		}

		for (i = 0; i < num_locks; i++) {
			if (git_mutex_init(&openssl_locks[i]) != 0) {
				SSL_CTX_free(git__ssl_ctx);
				git__ssl_ctx = NULL;
			}
		}

		CRYPTO_set_locking_callback(openssl_locking_function);
	}

	git__on_shutdown(shutdown_ssl);
# endif
#endif
}
开发者ID:junmei,项目名称:libgit2,代码行数:51,代码来源:global.c


示例15: CRYPTO_thread_cleanup

void CRYPTO_thread_cleanup()
{ int i;
  if (!mutex_buf)
    return;
  CRYPTO_set_id_callback(NULL);
  CRYPTO_set_locking_callback(NULL);
  CRYPTO_set_dynlock_create_callback(NULL);
  CRYPTO_set_dynlock_lock_callback(NULL);
  CRYPTO_set_dynlock_destroy_callback(NULL);
  for (i = 0; i < CRYPTO_num_locks(); i++)
    MUTEX_CLEANUP(mutex_buf[i]);
  free(mutex_buf);
  mutex_buf = NULL;
}
开发者ID:JinpengLI,项目名称:gsoap,代码行数:14,代码来源:sslclient.c


示例16: thread_cleanup

void thread_cleanup(void)
{
    int i;

    CRYPTO_set_locking_callback(NULL);
    for (i = 0; i < CRYPTO_num_locks(); i++) {
        char buf[10];

        sprintf(buf, "%2d:", i);
        usdumpsema(lock_cs[i], stdout, buf);
        usfreesema(lock_cs[i], arena);
    }
    OPENSSL_free(lock_cs);
}
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:14,代码来源:mttest.c


示例17: CRYPTO_thread_setup

void CRYPTO_thread_setup(void)
	{
	int i;

#ifdef USE_MUTEX
	lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t));
#else
	lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(rwlock_t));
#endif
	lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
	for (i=0; i<CRYPTO_num_locks(); i++)
		{
		lock_count[i]=0;
#ifdef USE_MUTEX
		mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
#else
		rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL);
#endif
		}

	CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
	CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
	}
开发者ID:ayufan,项目名称:openssl-win32,代码行数:23,代码来源:th-lock.c


示例18: thread_setup

void thread_setup(void)
{
    int i;
    char filename[20];

    sgx_strcpy(filename, "/tmp/mttest.XXXXXX");
    mktemp(filename);

    usconfig(CONF_STHREADIOOFF);
    usconfig(CONF_STHREADMALLOCOFF);
    usconfig(CONF_INITUSERS, 100);
    usconfig(CONF_LOCKTYPE, US_DEBUGPLUS);
    arena = usinit(filename);
    unlink(filename);

    lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *));
    for (i = 0; i < CRYPTO_num_locks(); i++) {
        lock_cs[i] = usnewsema(arena, 1);
    }

    CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id);
    CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
}
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:23,代码来源:mttest.c


示例19: ub_openssl_lock_delete

void ub_openssl_lock_delete(void)
{
#if defined(HAVE_SSL) && defined(OPENSSL_THREADS) && !defined(THREADS_DISABLED) && defined(CRYPTO_LOCK) && OPENSSL_VERSION_NUMBER < 0x10100000L
	int i;
	if(!ub_openssl_locks)
		return;
	CRYPTO_set_id_callback(NULL);
	CRYPTO_set_locking_callback(NULL);
	for(i=0; i<CRYPTO_num_locks(); i++) {
		lock_basic_destroy(&ub_openssl_locks[i]);
	}
	free(ub_openssl_locks);
#endif /* OPENSSL_THREADS */
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:14,代码来源:net_help.c


示例20: thread_setup

/**
 * thread_setup
 *
 * Set up multi-thread protection used by the SSL library
 *
 * Return value: 0 for success, -1 for failure
 **/
static int      thread_setup(void)
{
        int             i;

        /* First, create and initialize the necessary mutexes */
        if (! (mutexes = (pthread_mutex_t *)g_malloc(CRYPTO_num_locks() *
                                            sizeof(pthread_mutex_t)))) {
                err("out of memory");
                return(-1);
        }
        for (i = 0; i < CRYPTO_num_locks(); i++) {
                pthread_mutex_init(& (mutexes[i]), NULL);
        }

        /* Register our locking functions with the SSL library */
        CRYPTO_set_id_callback(id_function);
        CRYPTO_set_locking_callback(lock_function);
        CRYPTO_set_dynlock_create_callback(dyn_create_function);
        CRYPTO_set_dynlock_lock_callback(dyn_lock_function);
        CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function);

        return(0);                      /* No errors */
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:30,代码来源:oa_soap_ssl.c



注:本文中的CRYPTO_num_locks函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CRYPTO_r_lock函数代码示例发布时间:2022-05-30
下一篇:
C++ CRYPTO_new_ex_data函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap