|
|
| version 1.127.2.22.2.30, 2003/04/03 11:32:09 | version 1.130, 2003/09/25 09:15:02 |
|---|---|
| Line 50 static const String exception_var_name(E | Line 50 static const String exception_var_name(E |
| // helpers | // helpers |
| class Untaint_lang_name2enum: public Hash<const StringBody, String::Language> { | class Untaint_lang_name2enum: public Hash<const String::Body, String::Language> { |
| public: | public: |
| Untaint_lang_name2enum() { | Untaint_lang_name2enum() { |
| #define ULN(name, LANG) \ | #define ULN(name, LANG) \ |
| put(StringBody(name), (value_type)(String::L_##LANG)); | put(String::Body(name), (value_type)(String::L_##LANG)); |
| ULN("as-is", AS_IS); | ULN("as-is", AS_IS); |
| ULN("optimized-as-is", AS_IS|String::L_OPTIMIZE_BIT); | ULN("optimized-as-is", AS_IS|String::L_OPTIMIZE_BIT); |
| ULN("file-spec", FILE_SPEC); | ULN("file-spec", FILE_SPEC); |
| Line 298 r.sql_connect_time+=t[1]-t[0]; | Line 298 r.sql_connect_time+=t[1]-t[0]; |
| // execute body | // execute body |
| try { | try { |
| r.write_assign_lang(r.process(body_code)); | r.write_assign_lang(r.process(body_code)); |
| connection->commit(); | |
| connection->close(); | |
| } catch(...) { // process problem | } catch(...) { // process problem |
| connection->mark_to_rollback(); | connection->rollback(); |
| rethrow; | connection->close(); |
| rethrow; | |
| } | } |
| } | } |
| Line 318 public: | Line 321 public: |
| #endif | #endif |
| static void _switch(Request& r, MethodParams& params) { | static void _switch(Request& r, MethodParams& params) { |
| Switch_data* data=new Switch_data(r, r.process_to_value(params[0])); | Switch_data* data=new Switch_data(r, r.process_to_value(params[0])); |
| Temp_hash_value<const StringBody, PA_Object*> | Temp_hash_value<const String::Body, PA_Object*> |
| switch_data_setter(r.classes_conf, switch_data_name, data); | switch_data_setter(r.classes_conf, switch_data_name, data); |
| Value& cases_code=params.as_junction(1, "switch cases must be code"); | Value& cases_code=params.as_junction(1, "switch cases must be code"); |
| Line 416 static void locked_process_and_cache_put | Line 419 static void locked_process_and_cache_put |
| // expiration time not spoiled by ^cache(0) or something? | // expiration time not spoiled by ^cache(0) or something? |
| if(info.data->expires > time(0)) { | if(info.data->expires > time(0)) { |
| // string -serialize> buffer | // string -serialize> buffer |
| String::C serialized=info.evaluated_body->serialize( | String::Cm serialized=info.evaluated_body->serialize( |
| sizeof(Data_string_serialized_prolog)); | sizeof(Data_string_serialized_prolog)); |
| Data_string_serialized_prolog& prolog= | Data_string_serialized_prolog& prolog= |
| *reinterpret_cast<Data_string_serialized_prolog *>(serialized.str); | *reinterpret_cast<Data_string_serialized_prolog *>(serialized.str); |
| Line 432 const String* locked_process_and_cache_p | Line 435 const String* locked_process_and_cache_p |
| Value& body_code, | Value& body_code, |
| Cache_data& data, | Cache_data& data, |
| const String& file_spec) { | const String& file_spec) { |
| Locked_process_and_cache_put_action_info info; | Locked_process_and_cache_put_action_info info={0}; |
| info.r=&r; | info.r=&r; |
| info.data=&data; | info.data=&data; |
| info.body_code=&body_code; | info.body_code=&body_code; |
| Line 449 const String* locked_process_and_cache_p | Line 452 const String* locked_process_and_cache_p |
| cache_delete(file_spec); | cache_delete(file_spec); |
| return result; | return result; |
| } | } |
| const String* cache_get(Charset& charset, const String& file_spec, time_t now) { | const String* cache_get(Request_charsets& charsets, const String& file_spec, time_t now) { |
| File_read_result file=file_read(charset, file_spec, | File_read_result file=file_read(charsets, file_spec, |
| false/*as_text*/, | false/*as_text*/, |
| 0, //no params | 0, //no params |
| false/*fail_on_read_problem*/); | false/*fail_on_read_problem*/); |
| Line 512 static void _cache(Request& r, MethodPar | Line 515 static void _cache(Request& r, MethodPar |
| const String& file_spec=r.absolute(params.as_string(0, "filespec must be string")); | const String& file_spec=r.absolute(params.as_string(0, "filespec must be string")); |
| Cache_data* data=new Cache_data; | Cache_data* data=new Cache_data; |
| Temp_hash_value<const StringBody, PA_Object*> | Temp_hash_value<const String::Body, PA_Object*> |
| cache_data_setter(r.classes_conf, cache_data_name, data); | cache_data_setter(r.classes_conf, cache_data_name, data); |
| data->expires=as_expires(r, params, 1, now); | data->expires=as_expires(r, params, 1, now); |
| Value& body_code=params.as_junction(2, "body must be code"); | Value& body_code=params.as_junction(2, "body must be code"); |
| Line 535 static void _cache(Request& r, MethodPar | Line 538 static void _cache(Request& r, MethodPar |
| // |lockSH succeeds; ... | // |lockSH succeeds; ... |
| for(int retry=0; retry<2; retry++) { | for(int retry=0; retry<2; retry++) { |
| if(const String* cached_body=cache_get(r.charsets.source(), file_spec, now)) { // have cached copy? | if(const String* cached_body=cache_get(r.charsets, file_spec, now)) { // have cached copy? |
| // write it out | // write it out |
| r.write_assign_lang(*cached_body); | r.write_assign_lang(*cached_body); |
| // happy with it | // happy with it |