comparison src/os/unix/ngx_user.c @ 6029:e284f3ff6831

Removed old pthread implementation.
author Ruslan Ermilov <ru@nginx.com>
date Fri, 20 Mar 2015 06:43:19 +0300
parents 457ec43dd8d5
children 4a670c18e5e6
comparison
equal deleted inserted replaced
6028:fa77496b1df2 6029:e284f3ff6831
62 { 62 {
63 char *value; 63 char *value;
64 size_t len; 64 size_t len;
65 ngx_err_t err; 65 ngx_err_t err;
66 66
67 #if (NGX_OLD_THREADS && NGX_NONREENTRANT_CRYPT)
68
69 /* crypt() is a time consuming function, so we only try to lock */
70
71 if (ngx_mutex_trylock(ngx_crypt_mutex) != NGX_OK) {
72 return NGX_AGAIN;
73 }
74
75 #endif
76
77 value = crypt((char *) key, (char *) salt); 67 value = crypt((char *) key, (char *) salt);
78 68
79 if (value) { 69 if (value) {
80 len = ngx_strlen(value) + 1; 70 len = ngx_strlen(value) + 1;
81 71
82 *encrypted = ngx_pnalloc(pool, len); 72 *encrypted = ngx_pnalloc(pool, len);
83 if (*encrypted == NULL) { 73 if (*encrypted == NULL) {
84 #if (NGX_OLD_THREADS && NGX_NONREENTRANT_CRYPT)
85 ngx_mutex_unlock(ngx_crypt_mutex);
86 #endif
87 return NGX_ERROR; 74 return NGX_ERROR;
88 } 75 }
89 76
90 ngx_memcpy(*encrypted, value, len); 77 ngx_memcpy(*encrypted, value, len);
91 #if (NGX_OLD_THREADS && NGX_NONREENTRANT_CRYPT)
92 ngx_mutex_unlock(ngx_crypt_mutex);
93 #endif
94 return NGX_OK; 78 return NGX_OK;
95 } 79 }
96 80
97 err = ngx_errno; 81 err = ngx_errno;
98
99 #if (NGX_OLD_THREADS && NGX_NONREENTRANT_CRYPT)
100 ngx_mutex_unlock(ngx_crypt_mutex);
101 #endif
102 82
103 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed"); 83 ngx_log_error(NGX_LOG_CRIT, pool->log, err, "crypt() failed");
104 84
105 return NGX_ERROR; 85 return NGX_ERROR;
106 } 86 }