mirror of
https://github.com/nginx/nginx.git
synced 2025-06-15 15:40:38 +08:00
nginx-0.0.1-2003-05-07-21:32:45 import
This commit is contained in:
parent
3d09c8df72
commit
4fe262b682
@ -11,6 +11,8 @@ extern int __isthreaded;
|
|||||||
|
|
||||||
typedef int ngx_tid_t;
|
typedef int ngx_tid_t;
|
||||||
|
|
||||||
|
#define NGX_MAX_THREADS 10
|
||||||
|
|
||||||
|
|
||||||
static inline int ngx_gettid();
|
static inline int ngx_gettid();
|
||||||
|
|
||||||
@ -23,22 +25,18 @@ static int last_thread;
|
|||||||
|
|
||||||
static ngx_log_t *log;
|
static ngx_log_t *log;
|
||||||
|
|
||||||
static ngx_tid_t *tids;
|
static ngx_tid_t tids[NGX_MAX_THREADS];
|
||||||
|
|
||||||
static int red_zone = 4096;
|
static int red_zone = 4096;
|
||||||
|
|
||||||
|
|
||||||
/* the thread-safe errno */
|
/* the thread-safe errno */
|
||||||
|
|
||||||
static int errno0; /* the main thread's errno */
|
static int errnos[NGX_MAX_THREADS];
|
||||||
static int *errnos;
|
|
||||||
|
|
||||||
int *__error()
|
int *__error()
|
||||||
{
|
{
|
||||||
int tid;
|
return &errnos[ngx_gettid()];
|
||||||
|
|
||||||
tid = ngx_gettid();
|
|
||||||
return tid ? &errnos[tid] : &errno0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,8 +54,10 @@ int ngx_create_thread(ngx_tid_t *tid, int (*func)(void *arg), void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
id = rfork_thread(RFPROC|RFMEM|RFFDG|RFCFDG, stack_top, func, arg);
|
id = rfork(RFFDG|RFCFDG);
|
||||||
#elif 1
|
#elif 0
|
||||||
|
id = rfork_thread(RFFDG|RFCFDG, stack_top, func, arg);
|
||||||
|
#elif 0
|
||||||
id = rfork_thread(RFPROC|RFMEM, stack_top, func, arg);
|
id = rfork_thread(RFPROC|RFMEM, stack_top, func, arg);
|
||||||
#else
|
#else
|
||||||
id = rfork_thread(RFPROC|RFTHREAD|RFMEM, stack_top, func, arg);
|
id = rfork_thread(RFPROC|RFTHREAD|RFMEM, stack_top, func, arg);
|
||||||
@ -129,12 +129,6 @@ printf("stack: %08X\n", last_stack);
|
|||||||
stack_size = size + red_zone;
|
stack_size = size + red_zone;
|
||||||
stacks_end = stacks_start + n * stack_size;
|
stacks_end = stacks_start + n * stack_size;
|
||||||
|
|
||||||
/* create the thread errno array */
|
|
||||||
ngx_test_null(errnos, ngx_calloc(n * sizeof(int), log), NGX_ERROR);
|
|
||||||
|
|
||||||
/* create the thread tid array */
|
|
||||||
ngx_test_null(tids, ngx_calloc(n * sizeof(ngx_tid_t), log), NGX_ERROR);
|
|
||||||
|
|
||||||
tids[0] = ngx_getpid();
|
tids[0] = ngx_getpid();
|
||||||
last_thread = 1;
|
last_thread = 1;
|
||||||
|
|
||||||
@ -154,5 +148,5 @@ static inline int ngx_gettid()
|
|||||||
|
|
||||||
__asm__ ("mov %%esp, %0" : "=q" (sp));
|
__asm__ ("mov %%esp, %0" : "=q" (sp));
|
||||||
|
|
||||||
return (sp > stacks_end) ? 0: ((sp - stacks_start) / stack_size + 1);
|
return (sp > stacks_end) ? 0 : ((sp - stacks_start) / stack_size + 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user