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

« back to all changes in this revision

Viewing changes to libgearman/structs.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2009-08-11 10:06:22 UTC
  • mto: (1.2.3 upstream) (6.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20090811100622-6ig4iknanc73olum
ImportĀ upstreamĀ versionĀ 0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
struct gearman_st
25
25
{
26
26
  gearman_options_t options;
 
27
  gearman_verbose_t verbose;
 
28
  uint32_t con_count;
 
29
  uint32_t job_count;
 
30
  uint32_t task_count;
 
31
  uint32_t packet_count;
 
32
  uint32_t pfds_size;
 
33
  uint32_t sending;
 
34
  int last_errno;
27
35
  gearman_con_st *con_list;
28
 
  uint32_t con_count;
29
36
  gearman_job_st *job_list;
30
 
  uint32_t job_count;
31
37
  gearman_task_st *task_list;
32
 
  uint32_t task_count;
33
38
  gearman_packet_st *packet_list;
34
 
  uint32_t packet_count;
35
39
  struct pollfd *pfds;
36
 
  uint32_t pfds_size;
37
 
  uint32_t sending;
38
 
  int last_errno;
39
 
  char last_error[GEARMAN_MAX_ERROR_SIZE];
40
 
  gearman_verbose_t verbose;
41
40
  gearman_log_fn *log_fn;
42
41
  void *log_fn_arg;
43
42
  gearman_event_watch_fn *event_watch;
52
51
  gearman_queue_flush_fn *queue_flush_fn;
53
52
  gearman_queue_done_fn *queue_done_fn;
54
53
  gearman_queue_replay_fn *queue_replay_fn;
 
54
  char last_error[GEARMAN_MAX_ERROR_SIZE];
55
55
};
56
56
 
57
57
/**
59
59
 */
60
60
struct gearman_packet_st
61
61
{
62
 
  gearman_st *gearman;
63
 
  gearman_packet_st *next;
64
 
  gearman_packet_st *prev;
65
62
  gearman_packet_options_t options;
66
63
  gearman_magic_t magic;
67
64
  gearman_command_t command;
68
65
  uint8_t argc;
 
66
  size_t args_size;
 
67
  size_t data_size;
 
68
  gearman_st *gearman;
 
69
  gearman_packet_st *next;
 
70
  gearman_packet_st *prev;
 
71
  uint8_t *args;
 
72
  const void *data;
69
73
  uint8_t *arg[GEARMAN_MAX_COMMAND_ARGS];
70
74
  size_t arg_size[GEARMAN_MAX_COMMAND_ARGS];
71
 
  uint8_t *args;
72
75
  uint8_t args_buffer[GEARMAN_ARGS_BUFFER_SIZE];
73
 
  size_t args_size;
74
 
  const void *data;
75
 
  size_t data_size;
76
76
};
77
77
 
78
78
/**
90
90
 */
91
91
struct gearman_con_st
92
92
{
93
 
  gearman_st *gearman;
94
 
  gearman_con_st *next;
95
 
  gearman_con_st *prev;
 
93
  gearman_con_options_t options;
96
94
  gearman_con_state_t state;
97
 
  gearman_con_options_t options;
98
 
  void *data;
99
 
  char host[NI_MAXHOST];
 
95
  gearman_con_send_state_t send_state;
 
96
  gearman_con_recv_state_t recv_state;
100
97
  in_port_t port;
101
 
  struct addrinfo *addrinfo;
102
 
  struct addrinfo *addrinfo_next;
103
 
  int fd;
104
98
  short events;
105
99
  short revents;
 
100
  int fd;
106
101
  uint32_t created_id;
107
102
  uint32_t created_id_next;
108
 
  gearman_packet_st packet;
109
 
 
110
 
  gearman_con_send_state_t send_state;
111
 
  uint8_t send_buffer[GEARMAN_SEND_BUFFER_SIZE];
112
 
  uint8_t *send_buffer_ptr;
113
103
  size_t send_buffer_size;
114
104
  size_t send_data_size;
115
105
  size_t send_data_offset;
116
 
 
117
 
  gearman_con_recv_state_t recv_state;
118
 
  gearman_packet_st *recv_packet;
119
 
  uint8_t recv_buffer[GEARMAN_RECV_BUFFER_SIZE];
120
 
  uint8_t *recv_buffer_ptr;
121
106
  size_t recv_buffer_size;
122
107
  size_t recv_data_size;
123
108
  size_t recv_data_offset;
 
109
  gearman_st *gearman;
 
110
  gearman_con_st *next;
 
111
  gearman_con_st *prev;
 
112
  void *data;
 
113
  struct addrinfo *addrinfo;
 
114
  struct addrinfo *addrinfo_next;
 
115
  uint8_t *send_buffer_ptr;
 
116
  gearman_packet_st *recv_packet;
 
117
  uint8_t *recv_buffer_ptr;
 
118
  void *protocol_data;
 
119
  gearman_con_protocol_data_free_fn *protocol_data_free_fn;
 
120
  gearman_con_recv_fn *recv_fn;
 
121
  gearman_con_recv_data_fn *recv_data_fn;
 
122
  gearman_con_send_fn *send_fn;
 
123
  gearman_con_send_data_fn *send_data_fn;
 
124
  gearman_packet_pack_fn *packet_pack_fn;
 
125
  gearman_packet_unpack_fn *packet_unpack_fn;
 
126
  gearman_packet_st packet;
 
127
  char host[NI_MAXHOST];
 
128
  uint8_t send_buffer[GEARMAN_SEND_BUFFER_SIZE];
 
129
  uint8_t recv_buffer[GEARMAN_RECV_BUFFER_SIZE];
124
130
};
125
131
 
126
132
/**
128
134
 */
129
135
struct gearman_task_st
130
136
{
131
 
  gearman_st *gearman;
132
 
  gearman_task_st *next;
133
 
  gearman_task_st *prev;
134
137
  gearman_task_options_t options;
135
138
  gearman_task_state_t state;
136
 
  const void *fn_arg;
137
 
  gearman_con_st *con;
138
 
  uint32_t created_id;
139
 
  gearman_packet_st send;
140
 
  gearman_packet_st *recv;
141
 
  char job_handle[GEARMAN_JOB_HANDLE_SIZE];
142
139
  bool is_known;
143
140
  bool is_running;
 
141
  uint32_t created_id;
144
142
  uint32_t numerator;
145
143
  uint32_t denominator;
 
144
  gearman_st *gearman;
 
145
  gearman_task_st *next;
 
146
  gearman_task_st *prev;
 
147
  const void *fn_arg;
 
148
  gearman_con_st *con;
 
149
  gearman_packet_st *recv;
 
150
  gearman_packet_st send;
 
151
  char job_handle[GEARMAN_JOB_HANDLE_SIZE];
146
152
};
147
153
 
148
154
/**
150
156
 */
151
157
struct gearman_job_st
152
158
{
 
159
  gearman_job_options_t options;
153
160
  gearman_st *gearman;
154
161
  gearman_job_st *next;
155
162
  gearman_job_st *prev;
156
 
  gearman_job_options_t options;
157
163
  gearman_con_st *con;
158
164
  gearman_packet_st assigned;
159
165
  gearman_packet_st work;
164
170
 */
165
171
struct gearman_client_st
166
172
{
167
 
  gearman_st *gearman;
168
 
  gearman_st gearman_static;
 
173
  gearman_client_options_t options;
169
174
  gearman_client_state_t state;
170
 
  gearman_client_options_t options;
171
 
  const void *data;
 
175
  gearman_return_t do_ret;
172
176
  uint32_t new_tasks;
173
177
  uint32_t running_tasks;
 
178
  size_t do_data_size;
 
179
  gearman_st *gearman;
 
180
  const void *data;
174
181
  gearman_con_st *con;
175
182
  gearman_task_st *task;
176
 
  gearman_task_st do_task;
177
183
  void *do_data;
178
 
  size_t do_data_size;
179
 
  gearman_return_t do_ret;
180
184
  gearman_workload_fn *workload_fn;
181
185
  gearman_created_fn *created_fn;
182
186
  gearman_data_fn *data_fn;
185
189
  gearman_complete_fn *complete_fn;
186
190
  gearman_exception_fn *exception_fn;
187
191
  gearman_fail_fn *fail_fn;
 
192
  gearman_st gearman_static;
 
193
  gearman_task_st do_task;
188
194
};
189
195
 
190
196
/**
192
198
 */
193
199
struct gearman_worker_st
194
200
{
195
 
  gearman_st *gearman;
196
 
  gearman_st gearman_static;
197
201
  gearman_worker_options_t options;
198
202
  gearman_worker_state_t state;
199
 
  gearman_packet_st grab_job;
200
 
  gearman_packet_st pre_sleep;
 
203
  gearman_worker_work_state_t work_state;
 
204
  uint32_t function_count;
 
205
  size_t work_result_size;
 
206
  gearman_st *gearman;
201
207
  gearman_con_st *con;
202
208
  gearman_job_st *job;
203
209
  gearman_worker_function_st *function;
204
210
  gearman_worker_function_st *function_list;
205
 
  uint32_t function_count;
206
 
  gearman_worker_work_state_t work_state;
207
 
  gearman_job_st work_job;
208
211
  gearman_worker_function_st *work_function;
209
212
  void *work_result;
210
 
  size_t work_result_size;
 
213
  gearman_st gearman_static;
 
214
  gearman_packet_st grab_job;
 
215
  gearman_packet_st pre_sleep;
 
216
  gearman_job_st work_job;
211
217
};
212
218
 
213
219
/**
215
221
 */
216
222
struct gearman_worker_function_st
217
223
{
 
224
  gearman_worker_function_options_t options;
218
225
  gearman_worker_function_st *next;
219
226
  gearman_worker_function_st *prev;
220
 
  gearman_worker_function_options_t options;
221
227
  char *function_name;
222
228
  gearman_worker_fn *worker_fn;
223
229
  const void *fn_arg;
230
236
struct gearman_server_st
231
237
{
232
238
  gearman_server_options_t options;
233
 
  char job_handle_prefix[GEARMAN_JOB_HANDLE_SIZE];
234
 
  uint32_t job_handle_count;
235
239
  bool shutdown;
236
240
  bool shutdown_graceful;
 
241
  bool proc_wakeup;
 
242
  bool proc_shutdown;
 
243
  uint32_t job_handle_count;
 
244
  uint32_t thread_count;
 
245
  uint32_t function_count;
 
246
  uint32_t job_count;
 
247
  uint32_t unique_count;
 
248
  uint32_t free_packet_count;
 
249
  uint32_t free_job_count;
 
250
  uint32_t free_client_count;
 
251
  uint32_t free_worker_count;
 
252
  gearman_st *gearman;
237
253
  gearman_server_thread_st *thread_list;
238
 
  uint32_t thread_count;
239
 
  gearman_server_packet_st *free_packet_list;
240
 
  uint32_t free_packet_count;
241
254
  gearman_server_function_st *function_list;
242
 
  uint32_t function_count;
243
 
  gearman_server_job_st *job_hash[GEARMAN_JOB_HASH_SIZE];
244
 
  uint32_t job_count;
245
 
  gearman_server_job_st *unique_hash[GEARMAN_JOB_HASH_SIZE];
246
 
  uint32_t unique_count;
 
255
  gearman_server_packet_st *free_packet_list;
247
256
  gearman_server_job_st *free_job_list;
248
 
  uint32_t free_job_count;
249
257
  gearman_server_client_st *free_client_list;
250
 
  uint32_t free_client_count;
251
258
  gearman_server_worker_st *free_worker_list;
252
 
  uint32_t free_worker_count;
 
259
  gearman_server_log_fn *log_fn;
 
260
  void *log_fn_arg;
 
261
  gearman_st gearman_static;
253
262
  pthread_mutex_t proc_lock;
254
263
  pthread_cond_t proc_cond;
255
264
  pthread_t proc_id;
256
 
  bool proc_wakeup;
257
 
  bool proc_shutdown;
258
 
  gearman_st *gearman;
259
 
  gearman_st gearman_static;
260
 
  gearman_server_log_fn *log_fn;
261
 
  void *log_fn_arg;
 
265
  char job_handle_prefix[GEARMAN_JOB_HANDLE_SIZE];
 
266
  gearman_server_job_st *job_hash[GEARMAN_JOB_HASH_SIZE];
 
267
  gearman_server_job_st *unique_hash[GEARMAN_JOB_HASH_SIZE];
262
268
};
263
269
 
264
270
/**
267
273
struct gearman_server_thread_st
268
274
{
269
275
  gearman_server_thread_options_t options;
 
276
  uint32_t con_count;
 
277
  uint32_t io_count;
 
278
  uint32_t proc_count;
 
279
  uint32_t free_con_count;
 
280
  uint32_t free_packet_count;
 
281
  gearman_st *gearman;
270
282
  gearman_server_st *server;
271
283
  gearman_server_thread_st *next;
272
284
  gearman_server_thread_st *prev;
273
 
  pthread_mutex_t lock;
274
285
  gearman_server_thread_log_fn *log_fn;
275
286
  void *log_fn_arg;
276
287
  gearman_server_thread_run_fn *run_fn;
277
 
  void *run_arg;
278
 
  gearman_st *gearman;
279
 
  gearman_st gearman_static;
 
288
  void *run_fn_arg;
280
289
  gearman_server_con_st *con_list;
281
 
  uint32_t con_count;
282
290
  gearman_server_con_st *io_list;
283
 
  uint32_t io_count;
284
291
  gearman_server_con_st *proc_list;
285
 
  uint32_t proc_count;
286
292
  gearman_server_con_st *free_con_list;
287
 
  uint32_t free_con_count;
288
293
  gearman_server_packet_st *free_packet_list;
289
 
  uint32_t free_packet_count;
 
294
  gearman_st gearman_static;
 
295
  pthread_mutex_t lock;
290
296
};
291
297
 
292
298
/**
295
301
struct gearman_server_con_st
296
302
{
297
303
  gearman_con_st con; /* This must be the first struct member. */
 
304
  gearman_server_con_options_t options;
 
305
  gearman_return_t ret;
 
306
  bool noop_queued;
 
307
  bool io_list;
 
308
  bool proc_list;
 
309
  bool proc_removed;
 
310
  uint32_t io_packet_count;
 
311
  uint32_t proc_packet_count;
 
312
  uint32_t worker_count;
 
313
  uint32_t client_count;
298
314
  gearman_server_thread_st *thread;
299
315
  gearman_server_con_st *next;
300
316
  gearman_server_con_st *prev;
301
 
  gearman_server_con_options_t options;
302
 
  gearman_return_t ret;
303
317
  gearman_server_packet_st *packet;
304
318
  gearman_server_packet_st *io_packet_list;
305
319
  gearman_server_packet_st *io_packet_end;
306
 
  uint32_t io_packet_count;
307
320
  gearman_server_packet_st *proc_packet_list;
308
321
  gearman_server_packet_st *proc_packet_end;
309
 
  uint32_t proc_packet_count;
310
322
  gearman_server_con_st *io_next;
311
323
  gearman_server_con_st *io_prev;
312
324
  gearman_server_con_st *proc_next;
313
325
  gearman_server_con_st *proc_prev;
314
326
  gearman_server_worker_st *worker_list;
315
 
  uint32_t worker_count;
316
327
  gearman_server_client_st *client_list;
317
 
  uint32_t client_count;
318
328
  const char *host;
319
329
  const char *port;
320
330
  char id[GEARMAN_SERVER_CON_ID_SIZE];
321
 
  bool noop_queued;
322
 
  bool io_list;
323
 
  bool proc_list;
324
 
  bool proc_removed;
325
331
};
326
332
 
327
333
/**
338
344
 */
339
345
struct gearman_server_function_st
340
346
{
 
347
  gearman_server_function_options_t options;
 
348
  uint32_t worker_count;
 
349
  uint32_t job_count;
 
350
  uint32_t job_total;
 
351
  uint32_t job_running;
 
352
  uint32_t max_queue_size;
 
353
  size_t function_name_size;
341
354
  gearman_server_st *server;
342
355
  gearman_server_function_st *next;
343
356
  gearman_server_function_st *prev;
344
 
  gearman_server_function_options_t options;
345
357
  char *function_name;
346
 
  size_t function_name_size;
347
358
  gearman_server_worker_st *worker_list;
348
 
  uint32_t worker_count;
349
359
  gearman_server_job_st *job_list[GEARMAN_JOB_PRIORITY_MAX];
350
360
  gearman_server_job_st *job_end[GEARMAN_JOB_PRIORITY_MAX];
351
 
  uint32_t job_count;
352
 
  uint32_t job_total;
353
 
  uint32_t job_running;
354
 
  uint32_t max_queue_size;
355
361
};
356
362
 
357
363
/**
374
380
struct gearman_server_worker_st
375
381
{
376
382
  gearman_server_worker_options_t options;
 
383
  uint32_t timeout;
377
384
  gearman_server_con_st *con;
378
385
  gearman_server_worker_st *con_next;
379
386
  gearman_server_worker_st *con_prev;
380
387
  gearman_server_function_st *function;
381
388
  gearman_server_worker_st *function_next;
382
389
  gearman_server_worker_st *function_prev;
383
 
  uint32_t timeout;
384
390
  gearman_server_job_st *job;
385
391
};
386
392
 
389
395
 */
390
396
struct gearman_server_job_st
391
397
{
 
398
  gearman_server_job_options_t options;
 
399
  gearman_job_priority_t priority;
 
400
  uint32_t job_handle_key;
 
401
  uint32_t unique_key;
 
402
  uint32_t client_count;
 
403
  uint32_t numerator;
 
404
  uint32_t denominator;
 
405
  size_t data_size;
392
406
  gearman_server_st *server;
393
407
  gearman_server_job_st *next;
394
408
  gearman_server_job_st *prev;
396
410
  gearman_server_job_st *unique_prev;
397
411
  gearman_server_function_st *function;
398
412
  gearman_server_job_st *function_next;
399
 
  gearman_server_job_options_t options;
400
 
  gearman_job_priority_t priority;
 
413
  const void *data;
 
414
  gearman_server_client_st *client_list;
 
415
  gearman_server_worker_st *worker;
401
416
  char job_handle[GEARMAN_JOB_HANDLE_SIZE];
402
 
  uint32_t job_handle_key;
403
417
  char unique[GEARMAN_UNIQUE_SIZE];
404
 
  uint32_t unique_key;
405
 
  const void *data;
406
 
  size_t data_size;
407
 
  gearman_server_client_st *client_list;
408
 
  uint32_t client_count;
409
 
  gearman_server_worker_st *worker;
410
 
  uint32_t numerator;
411
 
  uint32_t denominator;
412
418
};
413
419
 
414
420
/**
417
423
struct gearmand_st
418
424
{
419
425
  gearmand_options_t options;
420
 
  const char *host;
421
 
  in_port_t port;
 
426
  gearman_verbose_t verbose;
 
427
  gearman_return_t ret;
422
428
  int backlog;
 
429
  uint32_t port_count;
423
430
  uint32_t threads;
424
 
  gearman_verbose_t verbose;
 
431
  uint32_t thread_count;
 
432
  uint32_t free_dcon_count;
 
433
  uint32_t max_thread_free_dcon_count;
 
434
  int wakeup_fd[2];
 
435
  const char *host;
425
436
  gearmand_log_fn *log_fn;
426
437
  void *log_fn_arg;
427
 
  gearman_return_t ret;
 
438
  struct event_base *base;
 
439
  gearmand_port_st *port_list;
 
440
  gearmand_thread_st *thread_list;
 
441
  gearmand_thread_st *thread_add_next;
 
442
  gearmand_con_st *free_dcon_list;
428
443
  gearman_server_st server;
429
 
  struct event_base *base;
430
 
  struct addrinfo *addrinfo;
431
 
  struct addrinfo *addrinfo_next;
 
444
  struct event wakeup_event;
 
445
};
 
446
 
 
447
/**
 
448
 * @ingroup gearmand
 
449
 */
 
450
struct gearmand_port_st
 
451
{
 
452
  in_port_t port;
432
453
  uint32_t listen_count;
 
454
  gearmand_st *gearmand;
 
455
  gearman_con_add_fn *add_fn;
433
456
  int *listen_fd;
434
457
  struct event *listen_event;
435
 
  int wakeup_fd[2];
436
 
  struct event wakeup_event;
437
 
  gearmand_thread_st *thread_list;
438
 
  uint32_t thread_count;
439
 
  gearmand_thread_st *thread_add_next;
440
 
  gearmand_con_st *free_dcon_list;
441
 
  uint32_t free_dcon_count;
442
 
  uint32_t max_thread_free_dcon_count;
443
458
};
444
459
 
445
460
/**
448
463
struct gearmand_thread_st
449
464
{
450
465
  gearmand_thread_options_t options;
 
466
  uint32_t count;
 
467
  uint32_t dcon_count;
 
468
  uint32_t dcon_add_count;
 
469
  uint32_t free_dcon_count;
 
470
  int wakeup_fd[2];
451
471
  gearmand_thread_st *next;
452
472
  gearmand_thread_st *prev;
453
473
  gearmand_st *gearmand;
 
474
  struct event_base *base;
 
475
  gearmand_con_st *dcon_list;
 
476
  gearmand_con_st *dcon_add_list;
 
477
  gearmand_con_st *free_dcon_list;
454
478
  gearman_server_thread_st server_thread;
455
 
  uint32_t count;
 
479
  struct event wakeup_event;
456
480
  pthread_t id;
457
481
  pthread_mutex_t lock;
458
 
  struct event_base *base;
459
 
  int wakeup_fd[2];
460
 
  struct event wakeup_event;
461
 
  gearmand_con_st *dcon_list;
462
 
  uint32_t dcon_count;
463
 
  gearmand_con_st *dcon_add_list;
464
 
  uint32_t dcon_add_count;
465
 
  gearmand_con_st *free_dcon_list;
466
 
  uint32_t free_dcon_count;
467
482
};
468
483
 
469
484
/**
471
486
 */
472
487
struct gearmand_con_st
473
488
{
 
489
  short last_events;
 
490
  int fd;
 
491
  gearmand_thread_st *thread;
474
492
  gearmand_con_st *next;
475
493
  gearmand_con_st *prev;
476
 
  gearmand_thread_st *thread;
477
 
  int fd;
478
 
  char host[NI_MAXHOST];
479
 
  char port[NI_MAXSERV];
480
494
  gearman_server_con_st *server_con;
481
495
  gearman_con_st *con;
482
 
  short last_events;
 
496
  gearman_con_add_fn *add_fn;
483
497
  struct event event;
 
498
  char host[NI_MAXHOST];
 
499
  char port[NI_MAXSERV];
 
500
};
 
501
 
 
502
/**
 
503
 * @ingroup gearman_conf
 
504
 */
 
505
struct gearman_conf_st
 
506
{
 
507
  gearman_conf_options_t options;
 
508
  gearman_return_t last_return;
 
509
  int last_errno;
 
510
  size_t module_count;
 
511
  size_t option_count;
 
512
  size_t short_count;
 
513
  gearman_conf_module_st **module_list;
 
514
  gearman_conf_option_st *option_list;
 
515
  struct option *option_getopt;
 
516
  char option_short[GEARMAN_CONF_MAX_OPTION_SHORT];
 
517
  char last_error[GEARMAN_MAX_ERROR_SIZE];
 
518
};
 
519
 
 
520
/**
 
521
 * @ingroup gearman_conf
 
522
 */
 
523
struct gearman_conf_option_st
 
524
{
 
525
  size_t value_count;
 
526
  gearman_conf_module_st *module;
 
527
  const char *name;
 
528
  const char *value_name;
 
529
  const char *help;
 
530
  char **value_list;
 
531
};
 
532
 
 
533
/**
 
534
 * @ingroup gearman_conf_module
 
535
 */
 
536
struct gearman_conf_module_st
 
537
{
 
538
  gearman_conf_module_options_t options;
 
539
  size_t current_option;
 
540
  size_t current_value;
 
541
  gearman_conf_st *conf;
 
542
  const char *name;
484
543
};
485
544
 
486
545
#ifdef __cplusplus