Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_process_cycle.c @ 381:02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Jul 2004 15:01:00 +0000 |
parents | 5ce6561246a5 |
children | 449c4885dcd1 |
comparison
equal
deleted
inserted
replaced
380:5ce6561246a5 | 381:02a511569afb |
---|---|
524 | 524 |
525 | 525 |
526 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) | 526 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) |
527 { | 527 { |
528 sigset_t set; | 528 sigset_t set; |
529 ngx_err_t err; | |
529 ngx_int_t n; | 530 ngx_int_t n; |
530 ngx_uint_t i; | 531 ngx_uint_t i; |
531 ngx_listening_t *ls; | 532 ngx_listening_t *ls; |
532 ngx_core_conf_t *ccf; | 533 ngx_core_conf_t *ccf; |
533 ngx_connection_t *c; | 534 ngx_connection_t *c; |
635 { | 636 { |
636 /* fatal */ | 637 /* fatal */ |
637 exit(2); | 638 exit(2); |
638 } | 639 } |
639 | 640 |
641 err = ngx_thread_key_create(&ngx_core_tls_key); | |
642 if (err != 0) { | |
643 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, | |
644 ngx_thread_key_create_n " failed"); | |
645 /* fatal */ | |
646 exit(2); | |
647 } | |
648 | |
640 for (n = 0; n < ngx_threads_n; n++) { | 649 for (n = 0; n < ngx_threads_n; n++) { |
641 | 650 |
642 if (!(ngx_threads[n].cv = ngx_cond_init(cycle->log))) { | 651 if (!(ngx_threads[n].cv = ngx_cond_init(cycle->log))) { |
643 /* fatal */ | 652 /* fatal */ |
644 exit(2); | 653 exit(2); |
827 { | 836 { |
828 ngx_thread_t *thr = data; | 837 ngx_thread_t *thr = data; |
829 | 838 |
830 sigset_t set; | 839 sigset_t set; |
831 ngx_err_t err; | 840 ngx_err_t err; |
832 ngx_tls_t *tls; | 841 ngx_core_tls_t *tls; |
833 ngx_cycle_t *cycle; | 842 ngx_cycle_t *cycle; |
834 struct timeval tv; | 843 struct timeval tv; |
835 | 844 |
836 thr->cv->tid = ngx_thread_self(); | 845 thr->cv->tid = ngx_thread_self(); |
837 | 846 |
852 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, ngx_errno, | 861 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, ngx_errno, |
853 "thread " TID_T_FMT " started", ngx_thread_self()); | 862 "thread " TID_T_FMT " started", ngx_thread_self()); |
854 | 863 |
855 ngx_setthrtitle("worker thread"); | 864 ngx_setthrtitle("worker thread"); |
856 | 865 |
857 if (!(tls = ngx_calloc(sizeof(ngx_tls_t), cycle->log))) { | 866 if (!(tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log))) { |
858 return (void *) 1; | 867 return (void *) 1; |
859 } | 868 } |
860 | 869 |
861 err = ngx_thread_create_tls(); | 870 err = ngx_thread_set_tls(ngx_core_tls_key, tls); |
862 if (err != 0) { | 871 if (err != 0) { |
863 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, | 872 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
864 ngx_thread_create_tls_n " failed"); | 873 ngx_thread_set_tls_n " failed"); |
865 return (void *) 1; | 874 return (void *) 1; |
866 } | 875 } |
867 | |
868 ngx_thread_set_tls(tls); | |
869 | 876 |
870 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { | 877 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { |
871 return (void *) 1; | 878 return (void *) 1; |
872 } | 879 } |
873 | 880 |
881 if (ngx_terminate) { | 888 if (ngx_terminate) { |
882 thr->state = NGX_THREAD_EXIT; | 889 thr->state = NGX_THREAD_EXIT; |
883 | 890 |
884 ngx_mutex_unlock(ngx_posted_events_mutex); | 891 ngx_mutex_unlock(ngx_posted_events_mutex); |
885 | 892 |
886 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, ngx_errno, | 893 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
887 "thread %d is done", ngx_thread_self()); | 894 "thread %d is done", ngx_thread_self()); |
888 | 895 |
889 return (void *) 0; | 896 return (void *) 0; |
890 } | 897 } |
891 | 898 |
897 | 904 |
898 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) { | 905 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) { |
899 return (void *) 1; | 906 return (void *) 1; |
900 } | 907 } |
901 | 908 |
902 if (ngx_process_changes(cycle, 1) == NGX_ERROR) { | 909 if (ngx_process_changes) { |
903 return (void *) 1; | 910 if (ngx_process_changes(cycle, 1) == NGX_ERROR) { |
911 return (void *) 1; | |
912 } | |
904 } | 913 } |
905 } | 914 } |
906 } | 915 } |
907 | 916 |
908 #endif | 917 #endif |