ntp_worker.h (293423) | ntp_worker.h (294554) |
---|---|
1/* 2 * ntp_worker.h 3 */ 4 5#ifndef NTP_WORKER_H 6#define NTP_WORKER_H 7 8#include "ntp_workimpl.h" --- 46 unchanged lines hidden (view full) --- 55# endif 56 57/* 58 * 59 */ 60#if defined(WORK_FORK) 61 62typedef struct blocking_child_tag { | 1/* 2 * ntp_worker.h 3 */ 4 5#ifndef NTP_WORKER_H 6#define NTP_WORKER_H 7 8#include "ntp_workimpl.h" --- 46 unchanged lines hidden (view full) --- 55# endif 56 57/* 58 * 59 */ 60#if defined(WORK_FORK) 61 62typedef struct blocking_child_tag { |
63 int reusable; 64 int pid; 65 int req_write_pipe; /* parent */ 66 int resp_read_pipe; 67 void * resp_read_ctx; 68 int req_read_pipe; /* child */ 69 int resp_write_pipe; 70 int ispipe; | 63 int reusable; 64 int pid; 65 int req_write_pipe; /* parent */ 66 int resp_read_pipe; 67 void * resp_read_ctx; 68 int req_read_pipe; /* child */ 69 int resp_write_pipe; 70 int ispipe; 71 volatile u_int resp_ready_seen; /* signal/scan */ 72 volatile u_int resp_ready_done; /* consumer/mainloop */ |
71} blocking_child; 72 73#elif defined(WORK_THREAD) 74 75typedef struct blocking_child_tag { | 73} blocking_child; 74 75#elif defined(WORK_THREAD) 76 77typedef struct blocking_child_tag { |
76/* 77 * blocking workitems and blocking_responses are dynamically-sized 78 * one-dimensional arrays of pointers to blocking worker requests and 79 * responses. 80 * 81 * IMPORTANT: This structure is shared between threads, and all access 82 * that is not atomic (especially queue operations) must hold the 83 * 'accesslock' semaphore to avoid data races. 84 * 85 * The resource management (thread/semaphore creation/destruction) 86 * functions and functions just testing a handle are safe because these 87 * are only changed by the main thread when no worker is running on the 88 * same data structure. 89 */ | 78 /* 79 * blocking workitems and blocking_responses are 80 * dynamically-sized one-dimensional arrays of pointers to 81 * blocking worker requests and responses. 82 * 83 * IMPORTANT: This structure is shared between threads, and all 84 * access that is not atomic (especially queue operations) must 85 * hold the 'accesslock' semaphore to avoid data races. 86 * 87 * The resource management (thread/semaphore 88 * creation/destruction) functions and functions just testing a 89 * handle are safe because these are only changed by the main 90 * thread when no worker is running on the same data structure. 91 */ |
90 int reusable; 91 sem_ref accesslock; /* shared access lock */ 92 thr_ref thread_ref; /* thread 'handle' */ 93 94 /* the reuest queue */ 95 blocking_pipe_header ** volatile 96 workitems; 97 volatile size_t workitems_alloc; --- 14 unchanged lines hidden (view full) --- 112 /* some systems use a pipe for notification, others a semaphore. 113 * Both employ the queue above for the actual data transfer. 114 */ 115#ifdef WORK_PIPE 116 int resp_read_pipe; /* parent */ 117 int resp_write_pipe; /* child */ 118 int ispipe; 119 void * resp_read_ctx; /* child */ | 92 int reusable; 93 sem_ref accesslock; /* shared access lock */ 94 thr_ref thread_ref; /* thread 'handle' */ 95 96 /* the reuest queue */ 97 blocking_pipe_header ** volatile 98 workitems; 99 volatile size_t workitems_alloc; --- 14 unchanged lines hidden (view full) --- 114 /* some systems use a pipe for notification, others a semaphore. 115 * Both employ the queue above for the actual data transfer. 116 */ 117#ifdef WORK_PIPE 118 int resp_read_pipe; /* parent */ 119 int resp_write_pipe; /* child */ 120 int ispipe; 121 void * resp_read_ctx; /* child */ |
122 volatile u_int resp_ready_seen; /* signal/scan */ 123 volatile u_int resp_ready_done; /* consumer/mainloop */ |
|
120#else 121 sem_ref responses_pending; /* signalling */ 122#endif 123 sema_type sem_table[4]; 124 thread_type thr_table[1]; 125} blocking_child; 126 127#endif /* WORK_THREAD */ 128 | 124#else 125 sem_ref responses_pending; /* signalling */ 126#endif 127 sema_type sem_table[4]; 128 thread_type thr_table[1]; 129} blocking_child; 130 131#endif /* WORK_THREAD */ 132 |
133/* we need some global tag to indicate any blocking child may be ready: */ 134extern volatile u_int blocking_child_ready_seen;/* signal/scan */ 135extern volatile u_int blocking_child_ready_done;/* consumer/mainloop */ 136 |
|
129extern blocking_child ** blocking_children; 130extern size_t blocking_children_alloc; 131extern int worker_per_query; /* boolean */ 132extern int intres_req_pending; 133 134extern u_int available_blocking_child_slot(void); 135extern int queue_blocking_request(blocking_work_req, void *, 136 size_t, blocking_work_callback, 137 void *); 138extern int queue_blocking_response(blocking_child *, 139 blocking_pipe_header *, size_t, 140 const blocking_pipe_header *); 141extern void process_blocking_resp(blocking_child *); | 137extern blocking_child ** blocking_children; 138extern size_t blocking_children_alloc; 139extern int worker_per_query; /* boolean */ 140extern int intres_req_pending; 141 142extern u_int available_blocking_child_slot(void); 143extern int queue_blocking_request(blocking_work_req, void *, 144 size_t, blocking_work_callback, 145 void *); 146extern int queue_blocking_response(blocking_child *, 147 blocking_pipe_header *, size_t, 148 const blocking_pipe_header *); 149extern void process_blocking_resp(blocking_child *); |
150extern void harvest_blocking_responses(void); |
|
142extern int send_blocking_req_internal(blocking_child *, 143 blocking_pipe_header *, 144 void *); 145extern int send_blocking_resp_internal(blocking_child *, 146 blocking_pipe_header *); 147extern blocking_pipe_header * 148 receive_blocking_req_internal(blocking_child *); 149extern blocking_pipe_header * --- 37 unchanged lines hidden --- | 151extern int send_blocking_req_internal(blocking_child *, 152 blocking_pipe_header *, 153 void *); 154extern int send_blocking_resp_internal(blocking_child *, 155 blocking_pipe_header *); 156extern blocking_pipe_header * 157 receive_blocking_req_internal(blocking_child *); 158extern blocking_pipe_header * --- 37 unchanged lines hidden --- |