120 ServerConfiguration *cfg = session->config; |
120 ServerConfiguration *cfg = session->config; |
121 |
121 |
122 ResourceDataPrivate *resource = NULL; |
122 ResourceDataPrivate *resource = NULL; |
123 |
123 |
124 // was this resource already used by this request? |
124 // was this resource already used by this request? |
125 if(request->resources) { |
125 if(request && request->resources) { |
126 resource = ucx_map_cstr_get(request->resources, name); |
126 resource = ucx_map_cstr_get(request->resources, name); |
127 if(resource) { |
127 if(resource) { |
128 return &resource->data; |
128 return &resource->data; |
129 } |
129 } |
130 } |
130 } |
168 |
168 |
169 // save the resource in the request object, for caching and also |
169 // save the resource in the request object, for caching and also |
170 // for cleanup later |
170 // for cleanup later |
171 int err = 0; |
171 int err = 0; |
172 if(resource) { |
172 if(resource) { |
173 if(!request->resources) { |
173 if(request) { |
174 request->resources = ucx_map_new_a(&session->allocator, 8); |
174 if(!request->resources) { |
175 } |
175 request->resources = ucx_map_new_a(&session->allocator, 8); |
176 |
176 } |
177 if(request->resources) { |
177 |
178 if(ucx_map_cstr_put(request->resources, name, resource)) { |
178 if(request->resources) { |
|
179 if(ucx_map_cstr_put(request->resources, name, resource)) { |
|
180 err = 1; |
|
181 } |
|
182 } else { |
179 err = 1; |
183 err = 1; |
180 } |
184 } |
181 } else { |
185 } // else: lookup is outside of any request context |
182 err = 1; |
|
183 } |
|
184 |
186 |
185 if(respool->type->prepare(respool->data, resource->resdata)) { |
187 if(respool->type->prepare(respool->data, resource->resdata)) { |
186 err = -1; |
188 err = -1; |
187 } |
189 } |
188 } |
190 } |