~clint-fewbar/ubuntu/precise/gearmand/drop-unneeded-patches

« back to all changes in this revision

Viewing changes to libgearman-server/structs.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2009-09-28 21:43:31 UTC
  • mto: (1.2.3 upstream) (6.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20090928214331-9bku0d3v1b1ypgp4
ImportĀ upstreamĀ versionĀ 0.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Gearman server and library
 
2
 * Copyright (C) 2008 Brian Aker, Eric Day
 
3
 * All rights reserved.
 
4
 *
 
5
 * Use and distribution licensed under the BSD license.  See
 
6
 * the COPYING file in the parent directory for full text.
 
7
 */
 
8
 
 
9
/**
 
10
 * @file
 
11
 * @brief Struct definitions
 
12
 */
 
13
 
 
14
#ifndef __GEARMAN_SERVER_STRUCTS_H__
 
15
#define __GEARMAN_SERVER_STRUCTS_H__
 
16
 
 
17
#ifdef __cplusplus
 
18
extern "C" {
 
19
#endif
 
20
 
 
21
/**
 
22
 * @ingroup gearman_server
 
23
 */
 
24
struct gearman_server_st
 
25
{
 
26
  gearman_server_options_t options;
 
27
  bool shutdown;
 
28
  bool shutdown_graceful;
 
29
  bool proc_wakeup;
 
30
  bool proc_shutdown;
 
31
  uint8_t job_retries;
 
32
  uint32_t job_handle_count;
 
33
  uint32_t thread_count;
 
34
  uint32_t function_count;
 
35
  uint32_t job_count;
 
36
  uint32_t unique_count;
 
37
  uint32_t free_packet_count;
 
38
  uint32_t free_job_count;
 
39
  uint32_t free_client_count;
 
40
  uint32_t free_worker_count;
 
41
  gearman_st *gearman;
 
42
  gearman_server_thread_st *thread_list;
 
43
  gearman_server_function_st *function_list;
 
44
  gearman_server_packet_st *free_packet_list;
 
45
  gearman_server_job_st *free_job_list;
 
46
  gearman_server_client_st *free_client_list;
 
47
  gearman_server_worker_st *free_worker_list;
 
48
  gearman_log_fn *log_fn;
 
49
  const void *log_context;
 
50
  const void *queue_context;
 
51
  gearman_queue_add_fn *queue_add_fn;
 
52
  gearman_queue_flush_fn *queue_flush_fn;
 
53
  gearman_queue_done_fn *queue_done_fn;
 
54
  gearman_queue_replay_fn *queue_replay_fn;
 
55
  gearman_st gearman_static;
 
56
  pthread_mutex_t proc_lock;
 
57
  pthread_cond_t proc_cond;
 
58
  pthread_t proc_id;
 
59
  char job_handle_prefix[GEARMAN_JOB_HANDLE_SIZE];
 
60
  gearman_server_job_st *job_hash[GEARMAN_JOB_HASH_SIZE];
 
61
  gearman_server_job_st *unique_hash[GEARMAN_JOB_HASH_SIZE];
 
62
};
 
63
 
 
64
/**
 
65
 * @ingroup gearman_server_thread
 
66
 */
 
67
struct gearman_server_thread_st
 
68
{
 
69
  gearman_server_thread_options_t options;
 
70
  uint32_t con_count;
 
71
  uint32_t io_count;
 
72
  uint32_t proc_count;
 
73
  uint32_t free_con_count;
 
74
  uint32_t free_packet_count;
 
75
  gearman_st *gearman;
 
76
  gearman_server_st *server;
 
77
  gearman_server_thread_st *next;
 
78
  gearman_server_thread_st *prev;
 
79
  gearman_log_fn *log_fn;
 
80
  const void *log_context;
 
81
  gearman_server_thread_run_fn *run_fn;
 
82
  void *run_fn_arg;
 
83
  gearman_server_con_st *con_list;
 
84
  gearman_server_con_st *io_list;
 
85
  gearman_server_con_st *proc_list;
 
86
  gearman_server_con_st *free_con_list;
 
87
  gearman_server_packet_st *free_packet_list;
 
88
  gearman_st gearman_static;
 
89
  pthread_mutex_t lock;
 
90
};
 
91
 
 
92
/**
 
93
 * @ingroup gearman_server_con
 
94
 */
 
95
struct gearman_server_con_st
 
96
{
 
97
  gearman_con_st con; /* This must be the first struct member. */
 
98
  gearman_server_con_options_t options;
 
99
  gearman_return_t ret;
 
100
  bool io_list;
 
101
  bool proc_list;
 
102
  bool proc_removed;
 
103
  uint32_t io_packet_count;
 
104
  uint32_t proc_packet_count;
 
105
  uint32_t worker_count;
 
106
  uint32_t client_count;
 
107
  gearman_server_thread_st *thread;
 
108
  gearman_server_con_st *next;
 
109
  gearman_server_con_st *prev;
 
110
  gearman_server_packet_st *packet;
 
111
  gearman_server_packet_st *io_packet_list;
 
112
  gearman_server_packet_st *io_packet_end;
 
113
  gearman_server_packet_st *proc_packet_list;
 
114
  gearman_server_packet_st *proc_packet_end;
 
115
  gearman_server_con_st *io_next;
 
116
  gearman_server_con_st *io_prev;
 
117
  gearman_server_con_st *proc_next;
 
118
  gearman_server_con_st *proc_prev;
 
119
  gearman_server_worker_st *worker_list;
 
120
  gearman_server_client_st *client_list;
 
121
  const char *host;
 
122
  const char *port;
 
123
  char id[GEARMAN_SERVER_CON_ID_SIZE];
 
124
};
 
125
 
 
126
/**
 
127
 * @ingroup gearman_server_con
 
128
 */
 
129
struct gearman_server_packet_st
 
130
{
 
131
  gearman_packet_st packet;
 
132
  gearman_server_packet_st *next;
 
133
};
 
134
 
 
135
/**
 
136
 * @ingroup gearman_server_function
 
137
 */
 
138
struct gearman_server_function_st
 
139
{
 
140
  gearman_server_function_options_t options;
 
141
  uint32_t worker_count;
 
142
  uint32_t job_count;
 
143
  uint32_t job_total;
 
144
  uint32_t job_running;
 
145
  uint32_t max_queue_size;
 
146
  size_t function_name_size;
 
147
  gearman_server_st *server;
 
148
  gearman_server_function_st *next;
 
149
  gearman_server_function_st *prev;
 
150
  char *function_name;
 
151
  gearman_server_worker_st *worker_list;
 
152
  gearman_server_job_st *job_list[GEARMAN_JOB_PRIORITY_MAX];
 
153
  gearman_server_job_st *job_end[GEARMAN_JOB_PRIORITY_MAX];
 
154
};
 
155
 
 
156
/**
 
157
 * @ingroup gearman_server_client
 
158
 */
 
159
struct gearman_server_client_st
 
160
{
 
161
  gearman_server_client_options_t options;
 
162
  gearman_server_con_st *con;
 
163
  gearman_server_client_st *con_next;
 
164
  gearman_server_client_st *con_prev;
 
165
  gearman_server_job_st *job;
 
166
  gearman_server_client_st *job_next;
 
167
  gearman_server_client_st *job_prev;
 
168
};
 
169
 
 
170
/**
 
171
 * @ingroup gearman_server_worker
 
172
 */
 
173
struct gearman_server_worker_st
 
174
{
 
175
  gearman_server_worker_options_t options;
 
176
  uint32_t job_count;
 
177
  uint32_t timeout;
 
178
  gearman_server_con_st *con;
 
179
  gearman_server_worker_st *con_next;
 
180
  gearman_server_worker_st *con_prev;
 
181
  gearman_server_function_st *function;
 
182
  gearman_server_worker_st *function_next;
 
183
  gearman_server_worker_st *function_prev;
 
184
  gearman_server_job_st *job_list;
 
185
};
 
186
 
 
187
/**
 
188
 * @ingroup gearman_server_job
 
189
 */
 
190
struct gearman_server_job_st
 
191
{
 
192
  uint8_t retries;
 
193
  gearman_server_job_options_t options;
 
194
  gearman_job_priority_t priority;
 
195
  uint32_t job_handle_key;
 
196
  uint32_t unique_key;
 
197
  uint32_t client_count;
 
198
  uint32_t numerator;
 
199
  uint32_t denominator;
 
200
  size_t data_size;
 
201
  gearman_server_st *server;
 
202
  gearman_server_job_st *next;
 
203
  gearman_server_job_st *prev;
 
204
  gearman_server_job_st *unique_next;
 
205
  gearman_server_job_st *unique_prev;
 
206
  gearman_server_job_st *worker_next;
 
207
  gearman_server_job_st *worker_prev;
 
208
  gearman_server_function_st *function;
 
209
  gearman_server_job_st *function_next;
 
210
  const void *data;
 
211
  gearman_server_client_st *client_list;
 
212
  gearman_server_worker_st *worker;
 
213
  char job_handle[GEARMAN_JOB_HANDLE_SIZE];
 
214
  char unique[GEARMAN_UNIQUE_SIZE];
 
215
};
 
216
 
 
217
/**
 
218
 * @ingroup gearmand
 
219
 */
 
220
struct gearmand_st
 
221
{
 
222
  gearmand_options_t options;
 
223
  gearman_verbose_t verbose;
 
224
  gearman_return_t ret;
 
225
  int backlog;
 
226
  uint32_t port_count;
 
227
  uint32_t threads;
 
228
  uint32_t thread_count;
 
229
  uint32_t free_dcon_count;
 
230
  uint32_t max_thread_free_dcon_count;
 
231
  int wakeup_fd[2];
 
232
  const char *host;
 
233
  gearman_log_fn *log_fn;
 
234
  const void *log_context;
 
235
  struct event_base *base;
 
236
  gearmand_port_st *port_list;
 
237
  gearmand_thread_st *thread_list;
 
238
  gearmand_thread_st *thread_add_next;
 
239
  gearmand_con_st *free_dcon_list;
 
240
  gearman_server_st server;
 
241
  struct event wakeup_event;
 
242
};
 
243
 
 
244
/**
 
245
 * @ingroup gearmand
 
246
 */
 
247
struct gearmand_port_st
 
248
{
 
249
  in_port_t port;
 
250
  uint32_t listen_count;
 
251
  gearmand_st *gearmand;
 
252
  gearman_con_add_fn *add_fn;
 
253
  int *listen_fd;
 
254
  struct event *listen_event;
 
255
};
 
256
 
 
257
/**
 
258
 * @ingroup gearmand_thread
 
259
 */
 
260
struct gearmand_thread_st
 
261
{
 
262
  gearmand_thread_options_t options;
 
263
  uint32_t count;
 
264
  uint32_t dcon_count;
 
265
  uint32_t dcon_add_count;
 
266
  uint32_t free_dcon_count;
 
267
  int wakeup_fd[2];
 
268
  gearmand_thread_st *next;
 
269
  gearmand_thread_st *prev;
 
270
  gearmand_st *gearmand;
 
271
  struct event_base *base;
 
272
  gearmand_con_st *dcon_list;
 
273
  gearmand_con_st *dcon_add_list;
 
274
  gearmand_con_st *free_dcon_list;
 
275
  gearman_server_thread_st server_thread;
 
276
  struct event wakeup_event;
 
277
  pthread_t id;
 
278
  pthread_mutex_t lock;
 
279
};
 
280
 
 
281
/**
 
282
 * @ingroup gearmand_con
 
283
 */
 
284
struct gearmand_con_st
 
285
{
 
286
  short last_events;
 
287
  int fd;
 
288
  gearmand_thread_st *thread;
 
289
  gearmand_con_st *next;
 
290
  gearmand_con_st *prev;
 
291
  gearman_server_con_st *server_con;
 
292
  gearman_con_st *con;
 
293
  gearman_con_add_fn *add_fn;
 
294
  struct event event;
 
295
  char host[NI_MAXHOST];
 
296
  char port[NI_MAXSERV];
 
297
};
 
298
 
 
299
/**
 
300
 * @ingroup gearman_conf
 
301
 */
 
302
struct gearman_conf_st
 
303
{
 
304
  gearman_conf_options_t options;
 
305
  gearman_return_t last_return;
 
306
  int last_errno;
 
307
  size_t module_count;
 
308
  size_t option_count;
 
309
  size_t short_count;
 
310
  gearman_conf_module_st **module_list;
 
311
  gearman_conf_option_st *option_list;
 
312
  struct option *option_getopt;
 
313
  char option_short[GEARMAN_CONF_MAX_OPTION_SHORT];
 
314
  char last_error[GEARMAN_MAX_ERROR_SIZE];
 
315
};
 
316
 
 
317
/**
 
318
 * @ingroup gearman_conf
 
319
 */
 
320
struct gearman_conf_option_st
 
321
{
 
322
  size_t value_count;
 
323
  gearman_conf_module_st *module;
 
324
  const char *name;
 
325
  const char *value_name;
 
326
  const char *help;
 
327
  char **value_list;
 
328
};
 
329
 
 
330
/**
 
331
 * @ingroup gearman_conf_module
 
332
 */
 
333
struct gearman_conf_module_st
 
334
{
 
335
  gearman_conf_module_options_t options;
 
336
  size_t current_option;
 
337
  size_t current_value;
 
338
  gearman_conf_st *conf;
 
339
  const char *name;
 
340
};
 
341
 
 
342
#ifdef __cplusplus
 
343
}
 
344
#endif
 
345
 
 
346
#endif /* __GEARMAN_SERVER_STRUCTS_H__ */