Changeset 745 for trunk/server/source4/smbd/process_model.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/smbd/process_model.c
r414 r745 23 23 #include "param/param.h" 24 24 25 static const struct model_ops *process_model_byname(const char *name); 25 /* the list of currently registered process models */ 26 static struct process_model { 27 const struct model_ops *ops; 28 bool initialised; 29 } *models = NULL; 30 static int num_models; 31 32 33 /* 34 return the operations structure for a named backend of the specified type 35 */ 36 static struct process_model *process_model_byname(const char *name) 37 { 38 int i; 39 40 for (i=0;i<num_models;i++) { 41 if (strcmp(models[i].ops->name, name) == 0) { 42 return &models[i]; 43 } 44 } 45 46 return NULL; 47 } 48 26 49 27 50 /* 28 51 setup the events for the chosen process model 29 52 */ 30 _PUBLIC_ const struct model_ops *process_model_startup( struct tevent_context *ev,const char *model)53 _PUBLIC_ const struct model_ops *process_model_startup(const char *model) 31 54 { 32 const struct model_ops *ops;55 struct process_model *m; 33 56 34 ops= process_model_byname(model);35 if ( !ops) {57 m = process_model_byname(model); 58 if (m == NULL) { 36 59 DEBUG(0,("Unknown process model '%s'\n", model)); 37 60 exit(-1); 38 61 } 39 62 40 ops->model_init(ev); 63 if (!m->initialised) { 64 m->initialised = true; 65 m->ops->model_init(); 66 } 41 67 42 return ops;68 return m->ops; 43 69 } 44 45 /* the list of currently registered process models */46 static struct process_model {47 struct model_ops *ops;48 } *models = NULL;49 static int num_models;50 70 51 71 /* … … 55 75 structure for this backend. 56 76 */ 57 _PUBLIC_ NTSTATUS register_process_model(const void *_ops)77 _PUBLIC_ NTSTATUS register_process_model(const struct model_ops *ops) 58 78 { 59 const struct model_ops *ops = _ops;60 61 79 if (process_model_byname(ops->name) != NULL) { 62 80 /* its already registered! */ … … 66 84 } 67 85 68 models = realloc_p(models, struct process_model, num_models+1);86 models = talloc_realloc(NULL, models, struct process_model, num_models+1); 69 87 if (!models) { 70 88 smb_panic("out of memory in register_process_model"); 71 89 } 72 90 73 models[num_models].ops = smb_xmemdup(ops, sizeof(*ops));74 models[num_models]. ops->name = smb_xstrdup(ops->name);91 models[num_models].ops = ops; 92 models[num_models].initialised = false; 75 93 76 94 num_models++; 77 95 78 DEBUG(3,("PROCESS_MODEL '%s' registered\n", 79 ops->name)); 96 DEBUG(3,("PROCESS_MODEL '%s' registered\n", ops->name)); 80 97 81 98 return NT_STATUS_OK; … … 84 101 _PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx) 85 102 { 86 extern NTSTATUS process_model_thread_init(void); 87 extern NTSTATUS process_model_standard_init(void); 88 extern NTSTATUS process_model_prefork_init(void); 89 extern NTSTATUS process_model_single_init(void); 103 #define _MODULE_PROTO(init) extern NTSTATUS init(void); 104 STATIC_process_model_MODULES_PROTO; 90 105 init_module_fn static_init[] = { STATIC_process_model_MODULES }; 91 init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "process_model"); 106 init_module_fn *shared_init; 107 static bool initialised; 92 108 109 if (initialised) { 110 return NT_STATUS_OK; 111 } 112 initialised = true; 113 114 shared_init = load_samba_modules(NULL, lp_ctx, "process_model"); 115 93 116 run_init_functions(static_init); 94 117 run_init_functions(shared_init); 95 118 96 119 talloc_free(shared_init); 97 120 98 121 return NT_STATUS_OK; 99 }100 101 /*102 return the operations structure for a named backend of the specified type103 */104 static const struct model_ops *process_model_byname(const char *name)105 {106 int i;107 108 for (i=0;i<num_models;i++) {109 if (strcmp(models[i].ops->name, name) == 0) {110 return models[i].ops;111 }112 }113 114 return NULL;115 122 } 116 123
Note:
See TracChangeset
for help on using the changeset viewer.